diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go index e87b40b4178..ed26337dc9b 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go @@ -85,7 +85,7 @@ func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap { res = append(res, fmt.Sprintf(resourceCodeFragment, f.Resource.QualifiedGroup(), f.Resource.Plural)) suffix := f.Resource.Plural - if f.MultiGroup { + if f.MultiGroup && f.Resource.Group != "" { suffix = f.Resource.Group + "_" + f.Resource.Plural } // Generate resource code fragments diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go index 5a734dc6af3..526f17da52a 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go @@ -34,7 +34,7 @@ type EnableCAInjectionPatch struct { // SetTemplateDefaults implements file.Template func (f *EnableCAInjectionPatch) SetTemplateDefaults() error { if f.Path == "" { - if f.MultiGroup { + if f.MultiGroup && f.Resource.Group != "" { f.Path = filepath.Join("config", "crd", "patches", "cainjection_in_%[group]_%[plural].yaml") } else { f.Path = filepath.Join("config", "crd", "patches", "cainjection_in_%[plural].yaml") diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go index 19d8df5d8cb..28452cc968b 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go @@ -34,7 +34,7 @@ type EnableWebhookPatch struct { // SetTemplateDefaults implements file.Template func (f *EnableWebhookPatch) SetTemplateDefaults() error { if f.Path == "" { - if f.MultiGroup { + if f.MultiGroup && f.Resource.Group != "" { f.Path = filepath.Join("config", "crd", "patches", "webhook_in_%[group]_%[plural].yaml") } else { f.Path = filepath.Join("config", "crd", "patches", "webhook_in_%[plural].yaml") diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go index 6e122f3629d..d5ca4f924cd 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go @@ -35,7 +35,7 @@ type CRDEditorRole struct { // SetTemplateDefaults implements file.Template func (f *CRDEditorRole) SetTemplateDefaults() error { if f.Path == "" { - if f.MultiGroup { + if f.MultiGroup && f.Resource.Group != "" { f.Path = filepath.Join("config", "rbac", "%[group]_%[kind]_editor_role.yaml") } else { f.Path = filepath.Join("config", "rbac", "%[kind]_editor_role.yaml") diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go index ed75bb88b36..233fc763300 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go @@ -35,7 +35,7 @@ type CRDViewerRole struct { // SetTemplateDefaults implements file.Template func (f *CRDViewerRole) SetTemplateDefaults() error { if f.Path == "" { - if f.MultiGroup { + if f.MultiGroup && f.Resource.Group != "" { f.Path = filepath.Join("config", "rbac", "%[group]_%[kind]_viewer_role.yaml") } else { f.Path = filepath.Join("config", "rbac", "%[kind]_viewer_role.yaml") diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go index f583eeb0eb0..1c3b53d756e 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go @@ -36,7 +36,11 @@ type CRDSample struct { // SetTemplateDefaults implements file.Template func (f *CRDSample) SetTemplateDefaults() error { if f.Path == "" { - f.Path = filepath.Join("config", "samples", "%[group]_%[version]_%[kind].yaml") + if f.Resource.Group != "" { + f.Path = filepath.Join("config", "samples", "%[group]_%[version]_%[kind].yaml") + } else { + f.Path = filepath.Join("config", "samples", "%[version]_%[kind].yaml") + } } f.Path = f.Resource.Replacer().Replace(f.Path) diff --git a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go index e2be2044d5a..9b0f528d5ab 100644 --- a/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go @@ -59,7 +59,11 @@ const samplesCodeFragment = `- %s // makeCRFileName returns a Custom Resource example file name in the same format // as kubebuilder's CreateAPI plugin for a gvk. func (f Kustomization) makeCRFileName() string { - return f.Resource.Replacer().Replace("%[group]_%[version]_%[kind].yaml") + if f.Resource.Group != "" { + return f.Resource.Replacer().Replace("%[group]_%[version]_%[kind].yaml") + } + return f.Resource.Replacer().Replace("%[version]_%[kind].yaml") + } // GetCodeFragments implements file.Inserter diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/config/samples/crd_sample.go b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/config/samples/crd_sample.go index a698f481f19..397a2fed18f 100644 --- a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/config/samples/crd_sample.go +++ b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/config/samples/crd_sample.go @@ -35,7 +35,11 @@ type CRDSample struct { // SetTemplateDefaults implements file.Template func (f *CRDSample) SetTemplateDefaults() error { if f.Path == "" { - f.Path = filepath.Join("config", "samples", "%[group]_%[version]_%[kind].yaml") + if f.Resource.Group != "" { + f.Path = filepath.Join("config", "samples", "%[group]_%[version]_%[kind].yaml") + } else { + f.Path = filepath.Join("config", "samples", "%[version]_%[kind].yaml") + } } f.Path = f.Resource.Replacer().Replace(f.Path) log.Println(f.Path) diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml index 240fd658848..cb76203b8fb 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-deploy-image/config/crd/kustomization.yaml @@ -26,7 +26,7 @@ patches: #- path: patches/webhook_in_foo.policy_healthcheckpolicies.yaml #- path: patches/webhook_in_foo_bars.yaml #- path: patches/webhook_in_fiz_bars.yaml -#- path: patches/webhook_in__lakers.yaml +#- path: patches/webhook_in_lakers.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. @@ -40,7 +40,7 @@ patches: #- path: patches/cainjection_in_foo.policy_healthcheckpolicies.yaml #- path: patches/cainjection_in_foo_bars.yaml #- path: patches/cainjection_in_fiz_bars.yaml -#- path: patches/cainjection_in__lakers.yaml +#- path: patches/cainjection_in_lakers.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in__lakers.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in__lakers.yaml rename to testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/cainjection_in_lakers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in__lakers.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in__lakers.yaml rename to testdata/project-v4-multigroup-with-deploy-image/config/crd/patches/webhook_in_lakers.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/_lakers_editor_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_editor_role.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/_lakers_editor_role.yaml rename to testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_editor_role.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/rbac/_lakers_viewer_role.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_viewer_role.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/rbac/_lakers_viewer_role.yaml rename to testdata/project-v4-multigroup-with-deploy-image/config/rbac/lakers_viewer_role.yaml diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml index a74ed904341..eeaf0793876 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml +++ b/testdata/project-v4-multigroup-with-deploy-image/config/samples/kustomization.yaml @@ -9,5 +9,5 @@ resources: - foo.policy_v1_healthcheckpolicy.yaml - foo_v1_bar.yaml - fiz_v1_bar.yaml -- _v1_lakers.yaml +- v1_lakers.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/testdata/project-v4-multigroup-with-deploy-image/config/samples/_v1_lakers.yaml b/testdata/project-v4-multigroup-with-deploy-image/config/samples/v1_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup-with-deploy-image/config/samples/_v1_lakers.yaml rename to testdata/project-v4-multigroup-with-deploy-image/config/samples/v1_lakers.yaml diff --git a/testdata/project-v4-multigroup/config/crd/kustomization.yaml b/testdata/project-v4-multigroup/config/crd/kustomization.yaml index 240fd658848..cb76203b8fb 100644 --- a/testdata/project-v4-multigroup/config/crd/kustomization.yaml +++ b/testdata/project-v4-multigroup/config/crd/kustomization.yaml @@ -26,7 +26,7 @@ patches: #- path: patches/webhook_in_foo.policy_healthcheckpolicies.yaml #- path: patches/webhook_in_foo_bars.yaml #- path: patches/webhook_in_fiz_bars.yaml -#- path: patches/webhook_in__lakers.yaml +#- path: patches/webhook_in_lakers.yaml #+kubebuilder:scaffold:crdkustomizewebhookpatch # [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix. @@ -40,7 +40,7 @@ patches: #- path: patches/cainjection_in_foo.policy_healthcheckpolicies.yaml #- path: patches/cainjection_in_foo_bars.yaml #- path: patches/cainjection_in_fiz_bars.yaml -#- path: patches/cainjection_in__lakers.yaml +#- path: patches/cainjection_in_lakers.yaml #+kubebuilder:scaffold:crdkustomizecainjectionpatch # [WEBHOOK] To enable webhook, uncomment the following section diff --git a/testdata/project-v4-multigroup/config/crd/patches/cainjection_in__lakers.yaml b/testdata/project-v4-multigroup/config/crd/patches/cainjection_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/crd/patches/cainjection_in__lakers.yaml rename to testdata/project-v4-multigroup/config/crd/patches/cainjection_in_lakers.yaml diff --git a/testdata/project-v4-multigroup/config/crd/patches/webhook_in__lakers.yaml b/testdata/project-v4-multigroup/config/crd/patches/webhook_in_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/crd/patches/webhook_in__lakers.yaml rename to testdata/project-v4-multigroup/config/crd/patches/webhook_in_lakers.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/_lakers_editor_role.yaml b/testdata/project-v4-multigroup/config/rbac/lakers_editor_role.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/rbac/_lakers_editor_role.yaml rename to testdata/project-v4-multigroup/config/rbac/lakers_editor_role.yaml diff --git a/testdata/project-v4-multigroup/config/rbac/_lakers_viewer_role.yaml b/testdata/project-v4-multigroup/config/rbac/lakers_viewer_role.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/rbac/_lakers_viewer_role.yaml rename to testdata/project-v4-multigroup/config/rbac/lakers_viewer_role.yaml diff --git a/testdata/project-v4-multigroup/config/samples/kustomization.yaml b/testdata/project-v4-multigroup/config/samples/kustomization.yaml index a74ed904341..eeaf0793876 100644 --- a/testdata/project-v4-multigroup/config/samples/kustomization.yaml +++ b/testdata/project-v4-multigroup/config/samples/kustomization.yaml @@ -9,5 +9,5 @@ resources: - foo.policy_v1_healthcheckpolicy.yaml - foo_v1_bar.yaml - fiz_v1_bar.yaml -- _v1_lakers.yaml +- v1_lakers.yaml #+kubebuilder:scaffold:manifestskustomizesamples diff --git a/testdata/project-v4-multigroup/config/samples/_v1_lakers.yaml b/testdata/project-v4-multigroup/config/samples/v1_lakers.yaml similarity index 100% rename from testdata/project-v4-multigroup/config/samples/_v1_lakers.yaml rename to testdata/project-v4-multigroup/config/samples/v1_lakers.yaml