util: only add shortName if it is not empty
@@ -63,10 +63,12 @@ func CreateCRD(clientset apiextensionsclient.Interface, crdName, rkind, rplural,
Names: apiextensionsv1beta1.CustomResourceDefinitionNames{
Plural: rplural,
Kind: rkind,
- ShortNames: []string{shortName},
},
},
}
+ if len(shortName) != 0 {
+ crd.Spec.Names.ShortNames = []string{shortName}
+ }
_, err := clientset.ApiextensionsV1beta1().CustomResourceDefinitions().Create(crd)
if err != nil && !IsKubernetesResourceAlreadyExistError(err) {
return err
