diff --git a/internal/plugins/ansible/v1/scaffolds/api.go b/internal/plugins/ansible/v1/scaffolds/api.go index 6dd7cd27f6..5396b6650f 100644 --- a/internal/plugins/ansible/v1/scaffolds/api.go +++ b/internal/plugins/ansible/v1/scaffolds/api.go @@ -31,12 +31,13 @@ import ( "github.com/operator-framework/operator-sdk/internal/kubebuilder/machinery" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/constants" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac" + ansiblerbac "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/samples" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/playbooks" ansibleroles "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/roles" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/crd" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/rbac" ) var _ scaffold.Scaffolder = &apiScaffolder{} @@ -99,10 +100,13 @@ func (s *apiScaffolder) scaffold() error { createAPITemplates = append(createAPITemplates, &rbac.CRDViewerRole{}, &rbac.CRDEditorRole{}, - &rbac.ManagerRoleUpdater{}, + // The role is customized for Ansible + &ansiblerbac.ManagerRoleUpdater{}, &crd.CRD{CRDVersion: s.opts.CRDVersion}, &crd.Kustomization{}, + + // The Sample is customized for Ansible &samples.CR{}, &templates.WatchesUpdater{GeneratePlaybook: s.opts.GeneratePlaybook, GenerateRole: s.opts.GenerateRole, PlaybooksDir: constants.PlaybooksDir}, &mdefault.ResourceTest{}, diff --git a/internal/plugins/ansible/v1/scaffolds/init.go b/internal/plugins/ansible/v1/scaffolds/init.go index b6631118a3..8898051caf 100644 --- a/internal/plugins/ansible/v1/scaffolds/init.go +++ b/internal/plugins/ansible/v1/scaffolds/init.go @@ -23,16 +23,18 @@ import ( "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/manager" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus" - "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac" + ansiblemanager "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/manager" + ansiblerbac "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/testing" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/config/testing/pullpolicy" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mdefault" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/molecule/mkind" "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/playbooks" ansibleroles "github.com/operator-framework/operator-sdk/internal/plugins/ansible/v1/scaffolds/internal/templates/roles" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/kdefault" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/manager" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/prometheus" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/rbac" "github.com/operator-framework/operator-sdk/internal/kubebuilder/machinery" ) @@ -90,16 +92,22 @@ func (s *initScaffolder) scaffold() error { &rbac.AuthProxyService{}, &rbac.LeaderElectionRole{}, &rbac.LeaderElectionRoleBinding{}, - &rbac.ManagerRole{}, - &rbac.RoleBinding{}, + &rbac.ManagerRoleBinding{}, + // The role is customized for Ansible + &ansiblerbac.ManagerRole{}, &prometheus.Kustomization{}, &prometheus.ServiceMonitor{}, - &manager.Manager{Image: imageName}, + // Ansible do not use the default Manager because of the + // the resources limit configuration them do not work with it. + // Todo: https://github.com/operator-framework/operator-sdk/issues/3573 + // When we do the above task we can centralize the manager and pass the limits + // as arg here. + &ansiblemanager.Manager{Image: imageName}, &manager.Kustomization{}, - &kdefault.Kustomize{}, + &kdefault.Kustomization{}, &kdefault.AuthProxyPatch{}, &templates.Makefile{}, diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault/kustomization.go b/internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault/kustomization.go deleted file mode 100644 index 71e4dbd76d..0000000000 --- a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault/kustomization.go +++ /dev/null @@ -1,73 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. -Modifications copyright 2020 The Operator-SDK Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package kdefault - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &Kustomize{} - -// Kustomize scaffolds the Kustomization file for the default overlay -type Kustomize struct { - file.TemplateMixin - file.ProjectNameMixin -} - -// SetTemplateDefaults implements input.Template -func (f *Kustomize) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "default", "kustomization.yaml") - } - - f.TemplateBody = kustomizeTemplate - - f.IfExistsAction = file.Error - - return nil -} - -const kustomizeTemplate = `# Adds namespace to all resources. -namespace: {{ .ProjectName }}-system - -# Value of this field is prepended to the -# names of all resources, e.g. a deployment named -# "wordpress" becomes "alices-wordpress". -# Note that it should also match with the prefix (text before '-') of the namespace -# field above. -namePrefix: {{ .ProjectName }}- - -# Labels to add to all resources and selectors. -#commonLabels: -# someName: someValue - -bases: -- ../crd -- ../rbac -- ../manager -# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. -#- ../prometheus - -patchesStrategicMerge: - # Protect the /metrics endpoint by putting it behind auth. - # If you want your controller-manager to expose the /metrics - # endpoint w/o any authn/z, please comment the following line. -- manager_auth_proxy_patch.yaml -` diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus/monitor.go b/internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus/monitor.go deleted file mode 100644 index 03fe1f3a4f..0000000000 --- a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus/monitor.go +++ /dev/null @@ -1,59 +0,0 @@ -/* -Copyright 2020 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package prometheus - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &ServiceMonitor{} - -// ServiceMonitor scaffolds an issuer CR and a certificate CR -type ServiceMonitor struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *ServiceMonitor) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "prometheus", "monitor.yaml") - } - - f.TemplateBody = serviceMonitorTemplate - - return nil -} - -const serviceMonitorTemplate = `--- -# Prometheus Monitor Service (Metrics) -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - labels: - control-plane: controller-manager - name: controller-manager-metrics-monitor - namespace: system -spec: - endpoints: - - path: /metrics - port: https - selector: - matchLabels: - control-plane: controller-manager -` diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_client_clusterrole.go b/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_client_clusterrole.go deleted file mode 100644 index c4a32ab496..0000000000 --- a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_client_clusterrole.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &ClientClusterRole{} - -// ClientClusterRole scaffolds the config/rbac/client_clusterrole.yaml file -type ClientClusterRole struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *ClientClusterRole) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "auth_proxy_client_clusterrole.yaml") - } - - f.TemplateBody = clientClusterRoleTemplate - - return nil -} - -const clientClusterRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: ClusterRole -metadata: - name: metrics-reader -rules: -- nonResourceURLs: ["/metrics"] - verbs: ["get"] -` diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/role_binding.go b/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/role_binding.go deleted file mode 100644 index 7afd1a317d..0000000000 --- a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/role_binding.go +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. -Modifications copyright 2020 The Operator-SDK Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &RoleBinding{} - -// RoleBinding scaffolds the config/rbac/role_binding.yaml file -type RoleBinding struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *RoleBinding) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "role_binding.yaml") - } - - f.TemplateBody = roleBindingTemplate - - return nil -} - -const roleBindingTemplate = `--- -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: manager-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: manager-role -subjects: -- kind: ServiceAccount - name: default - namespace: system -` diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd/crd.go b/internal/plugins/configbase/config/crd/crd.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd/crd.go rename to internal/plugins/configbase/config/crd/crd.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd/kustomization.go b/internal/plugins/configbase/config/crd/kustomization.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/crd/kustomization.go rename to internal/plugins/configbase/config/crd/kustomization.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault/auth_proxy_patch.go b/internal/plugins/configbase/config/kdefault/auth_proxy_patch.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/kdefault/auth_proxy_patch.go rename to internal/plugins/configbase/config/kdefault/auth_proxy_patch.go diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault/kustomization.go b/internal/plugins/configbase/config/kdefault/kustomization.go similarity index 100% rename from internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault/kustomization.go rename to internal/plugins/configbase/config/kdefault/kustomization.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/manager/kustomization.go b/internal/plugins/configbase/config/manager/kustomization.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/manager/kustomization.go rename to internal/plugins/configbase/config/manager/kustomization.go diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/manager/manager.go b/internal/plugins/configbase/config/manager/manager.go similarity index 100% rename from internal/plugins/helm/v1/scaffolds/internal/templates/config/manager/manager.go rename to internal/plugins/configbase/config/manager/manager.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus/kustomization.go b/internal/plugins/configbase/config/prometheus/kustomization.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/prometheus/kustomization.go rename to internal/plugins/configbase/config/prometheus/kustomization.go diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus/monitor.go b/internal/plugins/configbase/config/prometheus/monitor.go similarity index 100% rename from internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus/monitor.go rename to internal/plugins/configbase/config/prometheus/monitor.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role.go b/internal/plugins/configbase/config/rbac/auth_proxy_role.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role.go rename to internal/plugins/configbase/config/rbac/auth_proxy_role.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go b/internal/plugins/configbase/config/rbac/auth_proxy_role_binding.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go rename to internal/plugins/configbase/config/rbac/auth_proxy_role_binding.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_service.go b/internal/plugins/configbase/config/rbac/auth_proxy_service.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/auth_proxy_service.go rename to internal/plugins/configbase/config/rbac/auth_proxy_service.go diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/client_cluster_role.go b/internal/plugins/configbase/config/rbac/client_cluster_role.go similarity index 100% rename from internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/client_cluster_role.go rename to internal/plugins/configbase/config/rbac/client_cluster_role.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/crd_editor_rbac.go b/internal/plugins/configbase/config/rbac/crd_editor_rbac.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/crd_editor_rbac.go rename to internal/plugins/configbase/config/rbac/crd_editor_rbac.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/crd_viewer_rbac.go b/internal/plugins/configbase/config/rbac/crd_viewer_rbac.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/crd_viewer_rbac.go rename to internal/plugins/configbase/config/rbac/crd_viewer_rbac.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/kustomization.go b/internal/plugins/configbase/config/rbac/kustomization.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/kustomization.go rename to internal/plugins/configbase/config/rbac/kustomization.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/leader_election_role.go b/internal/plugins/configbase/config/rbac/leader_election_role.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/leader_election_role.go rename to internal/plugins/configbase/config/rbac/leader_election_role.go diff --git a/internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go b/internal/plugins/configbase/config/rbac/leader_election_role_binding.go similarity index 100% rename from internal/plugins/ansible/v1/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go rename to internal/plugins/configbase/config/rbac/leader_election_role_binding.go diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/manager_role_binding.go b/internal/plugins/configbase/config/rbac/manager_role_binding.go similarity index 100% rename from internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/manager_role_binding.go rename to internal/plugins/configbase/config/rbac/manager_role_binding.go diff --git a/internal/plugins/helm/v1/scaffolds/api.go b/internal/plugins/helm/v1/scaffolds/api.go index f07ed3c1c6..d645b1a6b0 100644 --- a/internal/plugins/helm/v1/scaffolds/api.go +++ b/internal/plugins/helm/v1/scaffolds/api.go @@ -29,10 +29,11 @@ import ( "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold" "github.com/operator-framework/operator-sdk/internal/kubebuilder/machinery" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/crd" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/rbac" "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/chartutil" "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac" + helmrbac "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac" "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/samples" ) @@ -96,7 +97,9 @@ func (s *apiScaffolder) scaffold() error { &crd.Kustomization{}, &rbac.CRDEditorRole{}, &rbac.CRDViewerRole{}, - &rbac.ManagerRoleUpdater{Chart: chrt}, + + // The role and sample are customized for Helm + &helmrbac.ManagerRoleUpdater{Chart: chrt}, &samples.CRDSample{ChartPath: chartPath, Chart: chrt}, ); err != nil { return fmt.Errorf("error scaffolding APIs: %v", err) diff --git a/internal/plugins/helm/v1/scaffolds/init.go b/internal/plugins/helm/v1/scaffolds/init.go index 0dc4ea68ed..3b70020995 100644 --- a/internal/plugins/helm/v1/scaffolds/init.go +++ b/internal/plugins/helm/v1/scaffolds/init.go @@ -26,12 +26,13 @@ import ( "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold" "github.com/operator-framework/operator-sdk/internal/kubebuilder/machinery" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/kdefault" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/manager" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/prometheus" + "github.com/operator-framework/operator-sdk/internal/plugins/configbase/config/rbac" "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/chartutil" "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/manager" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus" - "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac" + helmrbac "github.com/operator-framework/operator-sdk/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac" "github.com/operator-framework/operator-sdk/internal/version" ) @@ -100,7 +101,8 @@ func (s *initScaffolder) scaffold() error { &rbac.Kustomization{}, &rbac.LeaderElectionRole{}, &rbac.LeaderElectionRoleBinding{}, - &rbac.ManagerRole{}, + // The role is customized for Helm + &helmrbac.ManagerRole{}, &rbac.ManagerRoleBinding{}, &manager.Kustomization{}, &manager.Manager{Image: imageName}, diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/crd.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/crd.go deleted file mode 100644 index b03ac74d48..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/crd.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2020 The Operator-SDK Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package crd - -import ( - "errors" - "fmt" - "path/filepath" - - "github.com/kr/text" - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &CRD{} - -// CRD scaffolds a manifest for CRD sample. -type CRD struct { - file.TemplateMixin - file.ResourceMixin - - CRDVersion string -} - -// SetTemplateDefaults implements input.Template -func (f *CRD) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "crd", "bases", fmt.Sprintf("%s_%%[plural].yaml", f.Resource.Domain)) - } - f.Path = f.Resource.Replacer().Replace(f.Path) - - f.IfExistsAction = file.Error - - if f.CRDVersion == "" { - f.CRDVersion = "v1" - } else if f.CRDVersion != "v1" && f.CRDVersion != "v1beta1" { - return errors.New("the CRD version value must be either 'v1' or 'v1beta1'") - } - f.TemplateBody = fmt.Sprintf(crdTemplate, - text.Indent(openAPIV3SchemaTemplate, " "), - text.Indent(openAPIV3SchemaTemplate, " "), - ) - return nil -} - -const crdTemplate = `--- -apiVersion: apiextensions.k8s.io/{{ .CRDVersion }} -kind: CustomResourceDefinition -metadata: - name: {{ .Resource.Plural }}.{{ .Resource.Domain }} -spec: - group: {{ .Resource.Domain }} - names: - kind: {{ .Resource.Kind }} - listKind: {{ .Resource.Kind }}List - plural: {{ .Resource.Plural }} - singular: {{ .Resource.Kind | lower }} - scope: Namespaced -{{- if eq .CRDVersion "v1beta1" }} - subresources: - status: {} - validation: -%s -{{- end }} - versions: - - name: {{ .Resource.Version }} -{{- if eq .CRDVersion "v1" }} - schema: -%s -{{- end }} - served: true - storage: true -{{- if eq .CRDVersion "v1" }} - subresources: - status: {} -{{- end }} -` - -const openAPIV3SchemaTemplate = `openAPIV3Schema: - description: {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: Spec defines the desired state of {{ .Resource.Kind }} - type: object - x-kubernetes-preserve-unknown-fields: true - status: - description: Status defines the observed state of {{ .Resource.Kind }} - type: object - x-kubernetes-preserve-unknown-fields: true - type: object -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/kustomization.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/kustomization.go deleted file mode 100644 index 917cadddb0..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/crd/kustomization.go +++ /dev/null @@ -1,87 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. -Modifications copyright 2020 The Operator-SDK Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package crd - -import ( - "fmt" - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &Kustomization{} -var _ file.Inserter = &Kustomization{} - -// Kustomization scaffolds the kustomization file in manager folder. -type Kustomization struct { - file.TemplateMixin - file.ResourceMixin -} - -// SetTemplateDefaults implements file.Template -func (f *Kustomization) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "crd", "kustomization.yaml") - } - f.Path = f.Resource.Replacer().Replace(f.Path) - - f.TemplateBody = fmt.Sprintf(kustomizationTemplate, - file.NewMarkerFor(f.Path, resourceMarker), - ) - - return nil -} - -const ( - resourceMarker = "crdkustomizeresource" -) - -// GetMarkers implements file.Inserter -func (f *Kustomization) GetMarkers() []file.Marker { - return []file.Marker{ - file.NewMarkerFor(f.Path, resourceMarker), - } -} - -const ( - resourceCodeFragment = `- bases/%s_%s.yaml -` -) - -// GetCodeFragments implements file.Inserter -func (f *Kustomization) GetCodeFragments() file.CodeFragmentsMap { - fragments := make(file.CodeFragmentsMap, 3) - - // Generate resource code fragments - res := make([]string, 0) - res = append(res, fmt.Sprintf(resourceCodeFragment, f.Resource.Domain, f.Resource.Plural)) - - // Only store code fragments in the map if the slices are non-empty - if len(res) != 0 { - fragments[file.NewMarkerFor(f.Path, resourceMarker)] = res - } - - return fragments -} - -var kustomizationTemplate = `# This kustomization.yaml is not intended to be run by itself, -# since it depends on service name and namespace that are out of this kustomize package. -# It should be run by config/default -resources: -%s -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault/auth_proxy_patch.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault/auth_proxy_patch.go deleted file mode 100644 index 2abb40cc6e..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/kdefault/auth_proxy_patch.go +++ /dev/null @@ -1,74 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. -Modifications copyright 2020 The Operator-SDK Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package kdefault - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &AuthProxyPatch{} - -// AuthProxyPatch scaffolds the patch file for enabling -// prometheus metrics for manager Pod. -type AuthProxyPatch struct { - file.TemplateMixin - file.ProjectNameMixin -} - -// SetTemplateDefaults implements input.Template -func (f *AuthProxyPatch) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "default", "manager_auth_proxy_patch.yaml") - } - - f.TemplateBody = kustomizeAuthProxyPatchTemplate - - f.IfExistsAction = file.Error - - return nil -} - -const kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the -# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews. -apiVersion: apps/v1 -kind: Deployment -metadata: - name: controller-manager - namespace: system -spec: - template: - spec: - containers: - - name: kube-rbac-proxy - image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 - args: - - "--secure-listen-address=0.0.0.0:8443" - - "--upstream=http://127.0.0.1:8080/" - - "--logtostderr=true" - - "--v=10" - ports: - - containerPort: 8443 - name: https - - name: manager - args: - - "--metrics-addr=127.0.0.1:8080" - - "--enable-leader-election" - - "--leader-election-id={{ .ProjectName }}" -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/manager/kustomization.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/manager/kustomization.go deleted file mode 100644 index 84af806d0e..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/manager/kustomization.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package manager - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &Kustomization{} - -// Kustomization scaffolds the Kustomization file in manager folder. -type Kustomization struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *Kustomization) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "manager", "kustomization.yaml") - } - - f.TemplateBody = kustomizeManagerTemplate - - f.IfExistsAction = file.Error - - return nil -} - -const kustomizeManagerTemplate = `resources: -- manager.yaml -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus/kustomization.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus/kustomization.go deleted file mode 100644 index a630cddcf2..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/prometheus/kustomization.go +++ /dev/null @@ -1,45 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package prometheus - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &Kustomization{} - -// Kustomization scaffolds the kustomizaiton in the prometheus folder -type Kustomization struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *Kustomization) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "prometheus", "kustomization.yaml") - } - - f.TemplateBody = kustomizationTemplate - - return nil -} - -const kustomizationTemplate = `resources: -- monitor.yaml -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role.go deleted file mode 100644 index f05e776702..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role.go +++ /dev/null @@ -1,56 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &AuthProxyRole{} - -// AuthProxyRole scaffolds the config/rbac/auth_proxy_role.yaml file -type AuthProxyRole struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *AuthProxyRole) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "auth_proxy_role.yaml") - } - - f.TemplateBody = proxyRoleTemplate - - return nil -} - -const proxyRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: proxy-role -rules: -- apiGroups: ["authentication.k8s.io"] - resources: - - tokenreviews - verbs: ["create"] -- apiGroups: ["authorization.k8s.io"] - resources: - - subjectaccessreviews - verbs: ["create"] -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go deleted file mode 100644 index d0d43cf071..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &AuthProxyRoleBinding{} - -// AuthProxyRoleBinding scaffolds the config/rbac/auth_proxy_role_binding_rbac.yaml file -type AuthProxyRoleBinding struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *AuthProxyRoleBinding) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "auth_proxy_role_binding.yaml") - } - - f.TemplateBody = proxyRoleBindinggTemplate - - return nil -} - -const proxyRoleBindinggTemplate = `apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding -metadata: - name: proxy-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: ClusterRole - name: proxy-role -subjects: -- kind: ServiceAccount - name: default - namespace: system -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_service.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_service.go deleted file mode 100644 index 31a66347de..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/auth_proxy_service.go +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &AuthProxyService{} - -// AuthProxyService scaffolds the config/rbac/auth_proxy_service.yaml file -type AuthProxyService struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *AuthProxyService) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "auth_proxy_service.yaml") - } - - f.TemplateBody = authProxyServiceTemplate - - return nil -} - -const authProxyServiceTemplate = `apiVersion: v1 -kind: Service -metadata: - labels: - control-plane: controller-manager - name: controller-manager-metrics-service - namespace: system -spec: - ports: - - name: https - port: 8443 - targetPort: https - selector: - control-plane: controller-manager -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_editor_rbac.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_editor_rbac.go deleted file mode 100644 index 44c28e8886..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_editor_rbac.go +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &CRDEditorRole{} - -// CRDEditorRole scaffolds the config/rbac/_editor_role.yaml -type CRDEditorRole struct { - file.TemplateMixin - file.ResourceMixin -} - -// SetTemplateDefaults implements input.Template -func (f *CRDEditorRole) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "%[kind]_editor_role.yaml") - } - f.Path = f.Resource.Replacer().Replace(f.Path) - - f.TemplateBody = crdRoleEditorTemplate - - return nil -} - -const crdRoleEditorTemplate = `# permissions for end users to edit {{ .Resource.Plural }}. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ lower .Resource.Kind }}-editor-role -rules: -- apiGroups: - - {{ .Resource.Domain }} - resources: - - {{ .Resource.Plural }} - verbs: - - create - - delete - - get - - list - - patch - - update - - watch -- apiGroups: - - {{ .Resource.Domain }} - resources: - - {{ .Resource.Plural }}/status - verbs: - - get -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_viewer_rbac.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_viewer_rbac.go deleted file mode 100644 index 2591e50916..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/crd_viewer_rbac.go +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &CRDViewerRole{} - -// CRDViewerRole scaffolds the config/rbac/_viewer_role.yaml -type CRDViewerRole struct { - file.TemplateMixin - file.ResourceMixin -} - -// SetTemplateDefaults implements input.Template -func (f *CRDViewerRole) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "%[kind]_viewer_role.yaml") - } - f.Path = f.Resource.Replacer().Replace(f.Path) - - f.TemplateBody = crdRoleViewerTemplate - - return nil -} - -const crdRoleViewerTemplate = `# permissions for end users to view {{ .Resource.Plural }}. -apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRole -metadata: - name: {{ lower .Resource.Kind }}-viewer-role -rules: -- apiGroups: - - {{ .Resource.Domain }} - resources: - - {{ .Resource.Plural }} - verbs: - - get - - list - - watch -- apiGroups: - - {{ .Resource.Domain }} - resources: - - {{ .Resource.Plural }}/status - verbs: - - get -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/kustomization.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/kustomization.go deleted file mode 100644 index f3de8307aa..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/kustomization.go +++ /dev/null @@ -1,57 +0,0 @@ -/* -Copyright 2019 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &Kustomization{} - -// Kustomization scaffolds the Kustomization file in rbac folder. -type Kustomization struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *Kustomization) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "kustomization.yaml") - } - - f.TemplateBody = kustomizeRBACTemplate - - f.IfExistsAction = file.Error - - return nil -} - -const kustomizeRBACTemplate = `resources: -- role.yaml -- role_binding.yaml -- leader_election_role.yaml -- leader_election_role_binding.yaml -# Comment the following 4 lines if you want to disable -# the auth proxy (https://github.com/brancz/kube-rbac-proxy) -# which protects your /metrics endpoint. -- auth_proxy_service.yaml -- auth_proxy_role.yaml -- auth_proxy_role_binding.yaml -- auth_proxy_client_clusterrole.yaml -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role.go deleted file mode 100644 index d8b0aaa61d..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role.go +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &LeaderElectionRole{} - -// LeaderElectionRole scaffolds the config/rbac/leader_election_role.yaml file -type LeaderElectionRole struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *LeaderElectionRole) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "leader_election_role.yaml") - } - - f.TemplateBody = leaderElectionRoleTemplate - - return nil -} - -const leaderElectionRoleTemplate = `# permissions to do leader election. -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: leader-election-role -rules: -- apiGroups: - - "" - resources: - - configmaps - verbs: - - get - - list - - watch - - create - - update - - patch - - delete -- apiGroups: - - "" - resources: - - events - verbs: - - create - - patch -` diff --git a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go b/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go deleted file mode 100644 index 875fff93fb..0000000000 --- a/internal/plugins/helm/v1/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package rbac - -import ( - "path/filepath" - - "sigs.k8s.io/kubebuilder/pkg/model/file" -) - -var _ file.Template = &LeaderElectionRoleBinding{} - -// LeaderElectionRoleBinding scaffolds the config/rbac/leader_election_role_binding.yaml file -type LeaderElectionRoleBinding struct { - file.TemplateMixin -} - -// SetTemplateDefaults implements input.Template -func (f *LeaderElectionRoleBinding) SetTemplateDefaults() error { - if f.Path == "" { - f.Path = filepath.Join("config", "rbac", "leader_election_role_binding.yaml") - } - - f.TemplateBody = leaderElectionRoleBindingTemplate - - return nil -} - -const leaderElectionRoleBindingTemplate = `apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: leader-election-rolebinding -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: leader-election-role -subjects: -- kind: ServiceAccount - name: default - namespace: system -`