diff --git a/pkg/collect/cluster_resources.go b/pkg/collect/cluster_resources.go index 283c8a985..6928d1262 100644 --- a/pkg/collect/cluster_resources.go +++ b/pkg/collect/cluster_resources.go @@ -14,7 +14,6 @@ import ( troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2" "github.com/replicatedhq/troubleshoot/pkg/constants" "github.com/replicatedhq/troubleshoot/pkg/k8sutil" - "gopkg.in/yaml.v2" authorizationv1 "k8s.io/api/authorization/v1" corev1 "k8s.io/api/core/v1" rbacv1 "k8s.io/api/rbac/v1" @@ -1319,12 +1318,12 @@ func crsV1(ctx context.Context, client dynamic.Interface, config *rest.Config, n for _, item := range customResourceList.Items { objects = append(objects, item.Object) } - b, err := yaml.Marshal(objects) + b, err := json.Marshal(objects) if err != nil { errorList[crd.Name] = err.Error() continue } - customResources[fmt.Sprintf("%s.yaml", crd.Name)] = b + customResources[fmt.Sprintf("%s.json", crd.Name)] = b } else { // Group fetched resources by the namespace perNamespace := map[string][]map[string]interface{}{} @@ -1353,13 +1352,13 @@ func crsV1(ctx context.Context, client dynamic.Interface, config *rest.Config, n } namespacedName := fmt.Sprintf("%s/%s", crd.Name, ns) - b, err := yaml.Marshal(perNamespace[ns]) + b, err := json.Marshal(perNamespace[ns]) if err != nil { errorList[namespacedName] = err.Error() continue } - customResources[fmt.Sprintf("%s.yaml", namespacedName)] = b + customResources[fmt.Sprintf("%s.json", namespacedName)] = b } } } @@ -1430,12 +1429,13 @@ func crsV1beta(ctx context.Context, client dynamic.Interface, config *rest.Confi for _, item := range customResourceList.Items { objects = append(objects, item.Object) } - b, err := yaml.Marshal(customResourceList.Items) + b, err := json.Marshal(objects) // TODO: Check if this is the correct way to do this + // b, err := json.Marshal(customResourceList.Items) if err != nil { errorList[crd.Name] = err.Error() continue } - customResources[fmt.Sprintf("%s.yaml", crd.Name)] = b + customResources[fmt.Sprintf("%s.json", crd.Name)] = b } else { // Group fetched resources by the namespace perNamespace := map[string][]map[string]interface{}{} @@ -1464,13 +1464,14 @@ func crsV1beta(ctx context.Context, client dynamic.Interface, config *rest.Confi } namespacedName := fmt.Sprintf("%s/%s", crd.Name, ns) - b, err := yaml.Marshal(perNamespace[ns]) + b, err := json.Marshal(perNamespace[ns]) if err != nil { errorList[namespacedName] = err.Error() continue } - customResources[fmt.Sprintf("%s.yaml", namespacedName)] = b + // TODO: Store in YAML format to preserve (perhaps broken) backwards compatibility + customResources[fmt.Sprintf("%s.json", namespacedName)] = b } } }