Skip to content

Commit

Permalink
remove description from applicationset crd
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Jennings <richardjennings@gmail.com>
  • Loading branch information
richardjennings committed Oct 6, 2022
1 parent b77a752 commit a31eb52
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 22,162 deletions.
26 changes: 24 additions & 2 deletions hack/gen-crd-spec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func getCustomResourceDefinitions() map[string]*extensionsobj.CustomResourceDefi
removeValidation(un, "status")
}

crd := toCRD(un)
crd := toCRD(un, un.GetName() == "applicationsets.argoproj.io")
crd.Labels = map[string]string{
"app.kubernetes.io/name": crd.Name,
"app.kubernetes.io/part-of": "argocd",
Expand All @@ -82,7 +82,10 @@ func removeValidation(un *unstructured.Unstructured, path string) {
unstructured.RemoveNestedField(un.Object, schemaPath...)
}

func toCRD(un *unstructured.Unstructured) *extensionsobj.CustomResourceDefinition {
func toCRD(un *unstructured.Unstructured, removeDesc bool) *extensionsobj.CustomResourceDefinition {
if removeDesc {
removeDescription(un.Object)
}
unBytes, err := json.Marshal(un)
checkErr(err)

Expand All @@ -93,6 +96,25 @@ func toCRD(un *unstructured.Unstructured) *extensionsobj.CustomResourceDefinitio
return &crd
}

func removeDescription(v interface{}) {
switch v := v.(type) {
case []interface{}:
for _, v := range v {
removeDescription(v)
}
case map[string]interface{}:
if _, ok := v["description"]; ok {
_, ok := v["description"].(string)
if ok {
delete(v, "description")
}
}
for _, v := range v {
removeDescription(v)
}
}
}

func checkErr(err error) {
if err != nil {
panic(err)
Expand Down

0 comments on commit a31eb52

Please sign in to comment.