Skip to content

Commit

Permalink
refactor: convert slices to []interface before inserion into VendorEx…
Browse files Browse the repository at this point in the history
…tensible
  • Loading branch information
Alexander Zielenski committed Jul 18, 2023
1 parent 9ee6d97 commit 635875a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, ou
out.VendorExtensible.AddExtension("x-kubernetes-embedded-resource", true)
}
if len(in.XListMapKeys) != 0 {
out.VendorExtensible.AddExtension("x-kubernetes-list-map-keys", in.XListMapKeys)
out.VendorExtensible.AddExtension("x-kubernetes-list-map-keys", convertSliceToInterfaceSlice(in.XListMapKeys))
}
if in.XListType != nil {
out.VendorExtensible.AddExtension("x-kubernetes-list-type", *in.XListType)
Expand All @@ -354,11 +354,19 @@ func ConvertJSONSchemaPropsWithPostProcess(in *apiextensions.JSONSchemaProps, ou
if err := apiextensionsv1.Convert_apiextensions_ValidationRules_To_v1_ValidationRules(&in.XValidations, &serializationValidationRules, nil); err != nil {
return err
}
out.VendorExtensible.AddExtension("x-kubernetes-validations", serializationValidationRules)
out.VendorExtensible.AddExtension("x-kubernetes-validations", convertSliceToInterfaceSlice(serializationValidationRules))
}
return nil
}

func convertSliceToInterfaceSlice[T any](in []T) []interface{} {
var res []interface{}
for _, v := range in {
res = append(res, v)
}
return res
}

func convertSliceOfJSONSchemaProps(in *[]apiextensions.JSONSchemaProps, out *[]spec.Schema, postProcess PostProcessFunc) error {
if in != nil {
for _, jsonSchemaProps := range *in {
Expand Down

0 comments on commit 635875a

Please sign in to comment.