diff --git a/modules/api/pkg/resource/customresourcedefinition/types/types.go b/modules/api/pkg/resource/customresourcedefinition/types/types.go index ab401d4ea039..a8d1ccd61619 100644 --- a/modules/api/pkg/resource/customresourcedefinition/types/types.go +++ b/modules/api/pkg/resource/customresourcedefinition/types/types.go @@ -72,17 +72,12 @@ type CustomResourceDefinitionVersion struct { AdditionalPrinterColumns []AdditionalPrinterColumn `json:"additionalPrinterColumns"` } -type AdditionalPrinterColumnWithValue struct { - Name string `json:"name"` - Value string `json:"value"` -} - // CustomResourceObject represents a custom resource object. type CustomResourceObject struct { - AdditionalPrinterColumns []AdditionalPrinterColumnWithValue `json:"additionalPrinterColumns,omitempty"` - RawObject unstructured.Unstructured `json:"-"` // the raw object as map[string]interface{} to grep the value for AdditionalPrinterColumnWithValue which is present on the CRD Details - TypeMeta api.TypeMeta `json:"typeMeta"` - ObjectMeta api.ObjectMeta `json:"objectMeta"` + AdditionalPrinterColumns map[string]interface{} `json:"additionalPrinterColumns,omitempty"` + RawObject unstructured.Unstructured `json:"-"` // the raw object as map[string]interface{} to grep the value for AdditionalPrinterColumnWithValue which is present on the CRD Details + TypeMeta api.TypeMeta `json:"typeMeta"` + ObjectMeta api.ObjectMeta `json:"objectMeta"` } func (r *CustomResourceObject) UnmarshalJSON(data []byte) error { diff --git a/modules/api/pkg/resource/customresourcedefinition/v1/objects.go b/modules/api/pkg/resource/customresourcedefinition/v1/objects.go index 5fd4677e45b7..5a8367561100 100644 --- a/modules/api/pkg/resource/customresourcedefinition/v1/objects.go +++ b/modules/api/pkg/resource/customresourcedefinition/v1/objects.go @@ -129,14 +129,10 @@ func toCRDObject(object *types.CustomResourceObject, crd *apiextensionsv1.Custom object.TypeMeta.Kind = api.ResourceKind(crd.Name) crdSubresources := crd.Spec.Versions[0].Subresources object.TypeMeta.Scalable = crdSubresources != nil && crdSubresources.Scale != nil + object.AdditionalPrinterColumns = make(map[string]interface{}) for _, col := range crd.Spec.Versions[0].AdditionalPrinterColumns { val, _, _ := unstructured.NestedString(object.RawObject.Object, splitJsonPath(col.JSONPath)...) - //if val != "" { - object.AdditionalPrinterColumns = append(object.AdditionalPrinterColumns, types.AdditionalPrinterColumnWithValue{ - Name: col.Name, - Value: val, - }) - //} + object.AdditionalPrinterColumns[col.Name] = val } }