From 238914952ef4b33a765f7a206bd1f9dc00d46eb2 Mon Sep 17 00:00:00 2001 From: Eric Stroczynski Date: Wed, 29 Jul 2020 14:22:55 -0700 Subject: [PATCH] internal/generate/{collector/clusterserviceversion}: consider (cluster) role bindings so CSV generator can assign the correct service account names to roles --- changelog/fragments/fix-csv-role-names.yaml | 5 + .../clusterserviceversion_test.go | 67 ++--- .../clusterserviceversion_updaters.go | 87 ++++-- internal/generate/collector/collect.go | 36 +++ internal/generate/collector/collect_test.go | 54 ---- ...cached-operator.clusterserviceversion.yaml | 140 +++++----- .../{non-standard-layout => go}/PROJECT | 1 + .../{pkg/apis/cache => api}/v1alpha1/doc.go | 0 .../go/api/v1alpha1/memcached_types.go | 6 +- .../generate/testdata/go/api/v1alpha2/doc.go | 2 +- .../generate/testdata/go/cmd/manager/main.go | 3 - .../cache.example.com_memcachedrs_crd.yaml | 57 ---- .../cache.example.com_memcacheds_crd.yaml | 56 ---- ...che.example.com_v1alpha1_memcached_cr.yaml | 7 - ...e.example.com_v1alpha1_memcachedrs_cr.yaml | 6 - .../cache.example.com_memcachedrs_crd.yaml | 58 ---- .../cache.example.com_memcacheds_crd.yaml | 57 ---- ...che.example.com_v1alpha1_memcached_cr.yaml | 7 - ...e.example.com_v1alpha1_memcachedrs_cr.yaml | 6 - ...operator.v0.0.2.clusterserviceversion.yaml | 212 -------------- ...operator.v0.0.3.clusterserviceversion.yaml | 213 --------------- ...cached-operator.clusterserviceversion.yaml | 212 -------------- .../memcached-operator.package.yaml | 7 - ...operator.v0.0.3.clusterserviceversion.yaml | 216 --------------- .../generate/testdata/go/deploy/operator.yaml | 32 --- .../generate/testdata/go/deploy/role.yaml | 61 ----- .../testdata/go/deploy/role_binding.yaml | 11 - .../testdata/go/deploy/service_account.yaml | 4 - ...xample-com-v1alpha1-memcached.webhook.yaml | 50 ---- internal/generate/testdata/go/emptydir/.keep | 0 .../go/pkg/apis/cache/v1alpha1/dummy_types.go | 183 ------------- .../apis/cache/v1alpha1/memcached_types.go | 57 ---- .../apis/cache/v1alpha1/memcachedrs_types.go | 55 ---- .../testdata/go/static/basic.operatory.yaml | 258 ++++++++++++++++++ .../api/cache/v1alpha1/doc.go | 18 -- .../api/cache/v1alpha1/memcached_types.go | 57 ---- .../foo.example.com_deployment_crd.yaml | 57 ---- ...oo.example.com_v1alpha1_deployment_cr.yaml | 7 - .../cache.example.com_memcacheds_crd.yaml | 57 ---- ...che.example.com_v1alpha1_memcached_cr.yaml | 7 - .../non-standard-layout/config/operator.yaml | 32 --- .../non-standard-layout/config/role.yaml | 61 ----- .../config/role_binding.yaml | 11 - .../config/service_account.yaml | 4 - ...operator.v0.0.1.clusterserviceversion.yaml | 158 ----------- ...operator.v0.0.3.clusterserviceversion.yaml | 159 ----------- ...operator.v0.0.4.clusterserviceversion.yaml | 160 ----------- .../memcached-operator.package.yaml | 5 - .../testdata/non-standard-layout/main.go | 3 - 49 files changed, 465 insertions(+), 2557 deletions(-) create mode 100644 changelog/fragments/fix-csv-role-names.yaml delete mode 100644 internal/generate/collector/collect_test.go rename internal/generate/testdata/clusterserviceversions/{newlayout/manifests => output}/memcached-operator.clusterserviceversion.yaml (58%) rename internal/generate/testdata/{non-standard-layout => go}/PROJECT (87%) rename internal/generate/testdata/go/{pkg/apis/cache => api}/v1alpha1/doc.go (100%) delete mode 100644 internal/generate/testdata/go/cmd/manager/main.go delete mode 100644 internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcachedrs_crd.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcacheds_crd.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcached_cr.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcachedrs_cr.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcachedrs_crd.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcacheds_crd.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcached_cr.yaml delete mode 100644 internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcachedrs_cr.yaml delete mode 100644 internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.2/memcached-operator.v0.0.2.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/manifests/memcached-operator.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/memcached-operator.package.yaml delete mode 100644 internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/noupdate/memcached-operator.v0.0.3.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/go/deploy/operator.yaml delete mode 100644 internal/generate/testdata/go/deploy/role.yaml delete mode 100644 internal/generate/testdata/go/deploy/role_binding.yaml delete mode 100644 internal/generate/testdata/go/deploy/service_account.yaml delete mode 100644 internal/generate/testdata/go/deploy/webhooks/cache-example-com-v1alpha1-memcached.webhook.yaml delete mode 100644 internal/generate/testdata/go/emptydir/.keep delete mode 100644 internal/generate/testdata/go/pkg/apis/cache/v1alpha1/dummy_types.go delete mode 100644 internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcached_types.go delete mode 100644 internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcachedrs_types.go create mode 100644 internal/generate/testdata/go/static/basic.operatory.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/doc.go delete mode 100644 internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/memcached_types.go delete mode 100644 internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_deployment_crd.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_v1alpha1_deployment_cr.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_memcacheds_crd.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_v1alpha1_memcached_cr.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/operator.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/role.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/role_binding.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/config/service_account.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.1/memcached-operator.v0.0.1.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.4/memcached-operator.v0.0.4.clusterserviceversion.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/memcached-operator.package.yaml delete mode 100644 internal/generate/testdata/non-standard-layout/main.go diff --git a/changelog/fragments/fix-csv-role-names.yaml b/changelog/fragments/fix-csv-role-names.yaml new file mode 100644 index 00000000000..ba6c3e0d983 --- /dev/null +++ b/changelog/fragments/fix-csv-role-names.yaml @@ -0,0 +1,5 @@ +entries: + - description: > + Fixed incorrect (cluster) role name assignments in generated CSVs + [#3600](https://github.com/operator-framework/operator-sdk/issues/3600). + kind: bugfix diff --git a/internal/generate/clusterserviceversion/clusterserviceversion_test.go b/internal/generate/clusterserviceversion/clusterserviceversion_test.go index f6ab7ddefe8..299a78d246f 100644 --- a/internal/generate/clusterserviceversion/clusterserviceversion_test.go +++ b/internal/generate/clusterserviceversion/clusterserviceversion_test.go @@ -16,7 +16,6 @@ package clusterserviceversion import ( "bytes" - "encoding/json" "fmt" "io/ioutil" "os" @@ -32,7 +31,6 @@ import ( "github.com/operator-framework/api/pkg/operators/v1alpha1" "github.com/operator-framework/operator-registry/pkg/lib/bundle" appsv1 "k8s.io/api/apps/v1" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/kubebuilder/pkg/model/config" "sigs.k8s.io/yaml" @@ -46,16 +44,12 @@ var ( testDataDir = filepath.Join("..", "testdata") csvDir = filepath.Join(testDataDir, "clusterserviceversions") csvBasesDir = filepath.Join(csvDir, "bases") - csvNewLayoutBundleDir = filepath.Join(csvDir, "newlayout", "manifests") - - // TODO: create a new testdata dir (top level?) that has both a "config" - // dir and a "deploy" dir that contains `kustomize build config/default` - // output to simulate actual manifest collection behavior. Using "config" - // directly is not standard behavior. - goTestDataDir = filepath.Join(testDataDir, "non-standard-layout") - goAPIsDir = filepath.Join(goTestDataDir, "api") - goConfigDir = filepath.Join(goTestDataDir, "config") - goCRDsDir = filepath.Join(goConfigDir, "crds") + csvNewLayoutBundleDir = filepath.Join(csvDir, "output") + + goTestDataDir = filepath.Join(testDataDir, "go") + goAPIsDir = filepath.Join(goTestDataDir, "api") + goStaticDir = filepath.Join(goTestDataDir, "static") + goBasicOperatorPath = filepath.Join(goStaticDir, "basic.operatory.yaml") ) var ( @@ -75,7 +69,7 @@ var ( var _ = BeforeSuite(func() { col = &collector.Manifests{} - Expect(col.UpdateFromDirs(goConfigDir, goCRDsDir)).ToNot(HaveOccurred()) + collectManifestsFromFileHelper(col, goBasicOperatorPath) cfg = readConfigHelper(goTestDataDir) @@ -98,7 +92,7 @@ var _ = Describe("Generating a ClusterServiceVersion", func() { buf = &bytes.Buffer{} }) - Describe("for the new Go project layout", func() { + Describe("for a Go project", func() { Context("with correct Options", func() { @@ -282,7 +276,7 @@ var _ = Describe("Generating a ClusterServiceVersion", func() { getBase: makeBaseGetter(newCSV), } // Update the input's and expected CSV's Deployment image. - Expect(g.Collector.UpdateFromDirs(goConfigDir, goCRDsDir)).ToNot(HaveOccurred()) + collectManifestsFromFileHelper(g.Collector, goBasicOperatorPath) Expect(len(g.Collector.Deployments)).To(BeNumerically(">=", 1)) imageTag := "controller:v" + g.Version modifyDepImageHelper(&g.Collector.Deployments[0].Spec, imageTag) @@ -312,42 +306,6 @@ var _ = Describe("Generating a ClusterServiceVersion", func() { Expect(csv).To(Equal(upgradeCSV(newCSV, g.OperatorName, g.Version))) }) }) - - Context("generate ClusterServiceVersion", func() { - It("should handle CRDs with core type name", func() { - g = Generator{ - OperatorName: operatorName, - OperatorType: operatorType, - Version: version, - Collector: &collector.Manifests{}, - config: cfg, - getBase: makeBaseGetter(newCSV), - } - err := filepath.Walk(goConfigDir, func(path string, info os.FileInfo, err error) error { - if err != nil || info.IsDir() { - return err - } - file, err := os.OpenFile(path, os.O_RDONLY, 0) - if err != nil { - return err - } - defer file.Close() - return g.Collector.UpdateFromReader(file) - }) - Expect(err).ShouldNot(HaveOccurred(), "failed to read manifests") - Expect(len(g.Collector.V1beta1CustomResourceDefinitions)).Should(BeEquivalentTo(2)) - Expect(len(g.Collector.CustomResources)).Should(BeEquivalentTo(2)) - - csv, err := g.generate() - Expect(err).ToNot(HaveOccurred()) - Expect(csv.Annotations["alm-examples"]).ShouldNot(BeEquivalentTo("[]")) - - crs := []unstructured.Unstructured{} - err = json.Unmarshal([]byte(csv.Annotations["alm-examples"]), &crs) - Expect(err).ShouldNot(HaveOccurred(), "failed to parse 'alm-examples' annotations") - Expect(crs).Should(ConsistOf(g.Collector.CustomResources), "custom resources shall match with CSV annotations") - }) - }) }) }) @@ -389,6 +347,13 @@ var _ = Describe("Generation requires interaction", func() { }) }) +func collectManifestsFromFileHelper(col *collector.Manifests, path string) { + f, err := os.Open(path) + ExpectWithOffset(1, err).ToNot(HaveOccurred()) + ExpectWithOffset(1, col.UpdateFromReader(f)).ToNot(HaveOccurred()) + ExpectWithOffset(1, f.Close()).Should(Succeed()) +} + func readConfigHelper(dir string) *config.Config { wd, err := os.Getwd() ExpectWithOffset(1, err).ToNot(HaveOccurred()) diff --git a/internal/generate/clusterserviceversion/clusterserviceversion_updaters.go b/internal/generate/clusterserviceversion/clusterserviceversion_updaters.go index 73bd0a65beb..f8fa413bea9 100644 --- a/internal/generate/clusterserviceversion/clusterserviceversion_updaters.go +++ b/internal/generate/clusterserviceversion/clusterserviceversion_updaters.go @@ -28,6 +28,7 @@ import ( admissionregv1 "k8s.io/api/admissionregistration/v1" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/version" "github.com/operator-framework/operator-sdk/internal/generate/collector" @@ -39,7 +40,7 @@ import ( func ApplyTo(c *collector.Manifests, csv *operatorsv1alpha1.ClusterServiceVersion) error { // Apply manifests to the CSV object. if err := apply(c, csv); err != nil { - return fmt.Errorf("error updating ClusterServiceVersion: %v", err) + return err } // Set fields required by namespaced operators. This is a no-op for cluster- @@ -65,7 +66,7 @@ func apply(c *collector.Manifests, csv *operatorsv1alpha1.ClusterServiceVersion) applyCustomResourceDefinitions(c, csv) if err := applyCustomResources(c, csv); err != nil { - return fmt.Errorf("error applying Custom Resource: %v", err) + return fmt.Errorf("error applying Custom Resource examples to CSV %s: %v", csv.GetName(), err) } applyWebhooks(c, csv) return nil @@ -80,29 +81,77 @@ func getCSVInstallStrategy(csv *operatorsv1alpha1.ClusterServiceVersion) operato return csv.Spec.InstallStrategy } -// applyRoles updates strategy's permissions with the Roles in the collector. -func applyRoles(c *collector.Manifests, strategy *operatorsv1alpha1.StrategyDetailsDeployment) { +// applyRoles applies Roles to strategy's permissions field while respecting ServiceAccount names in RoleBindings. +func applyRoles(c *collector.Manifests, strategy *operatorsv1alpha1.StrategyDetailsDeployment) { //nolint:dupl + // Collect all role names by their corresponding service accounts via bindings. This lets us + // look up all service accounts a role is bound to and create one set of permissions per service account. + saNamesToRoleNames := make(map[string]map[string]struct{}) + for _, binding := range c.RoleBindings { + roleRef := binding.RoleRef + if roleRef.Kind == "Role" && (roleRef.APIGroup == "" || roleRef.APIGroup == rbacv1.SchemeGroupVersion.Group) { + for _, name := range getSubjectServiceAccountNames(binding.Subjects) { + if saNamesToRoleNames[name] == nil { + saNamesToRoleNames[name] = make(map[string]struct{}) + } + saNamesToRoleNames[name][roleRef.Name] = struct{}{} + } + } + } + + // Apply relevant roles to each service account. perms := []operatorsv1alpha1.StrategyDeploymentPermissions{} - for _, role := range c.Roles { - perms = append(perms, operatorsv1alpha1.StrategyDeploymentPermissions{ - ServiceAccountName: role.GetName(), - Rules: role.Rules, - }) + for saName, roleNames := range saNamesToRoleNames { + p := operatorsv1alpha1.StrategyDeploymentPermissions{ServiceAccountName: saName} + for _, role := range c.Roles { + if _, ok := roleNames[role.GetName()]; ok { + p.Rules = append(p.Rules, role.Rules...) + } + } + perms = append(perms, p) } strategy.Permissions = perms } -// applyClusterRoles updates strategy's cluserPermissions with the ClusterRoles -// in the collector. -func applyClusterRoles(c *collector.Manifests, strategy *operatorsv1alpha1.StrategyDetailsDeployment) { - perms := []operatorsv1alpha1.StrategyDeploymentPermissions{} - for _, role := range c.ClusterRoles { - perms = append(perms, operatorsv1alpha1.StrategyDeploymentPermissions{ - ServiceAccountName: role.GetName(), - Rules: role.Rules, - }) +// applyClusterRoles applies ClusterRoles to strategy's clusterPermissions field while respecting +// ServiceAccount names in ClusterRoleBindings. +func applyClusterRoles(c *collector.Manifests, strategy *operatorsv1alpha1.StrategyDetailsDeployment) { //nolint:dupl + // Collect all cluster role names by their corresponding service accounts via bindings. This lets us look up + // all service accounts a cluster role is bound to and create one set of clusterPermissions per service account. + saNamesToClusterRoleNames := make(map[string]map[string]struct{}) + for _, binding := range c.ClusterRoleBindings { + roleRef := binding.RoleRef + if roleRef.Kind == "ClusterRole" && (roleRef.APIGroup == "" || roleRef.APIGroup == rbacv1.SchemeGroupVersion.Group) { + for _, name := range getSubjectServiceAccountNames(binding.Subjects) { + if saNamesToClusterRoleNames[name] == nil { + saNamesToClusterRoleNames[name] = make(map[string]struct{}) + } + saNamesToClusterRoleNames[name][roleRef.Name] = struct{}{} + } + } + } + + // Apply relevant cluster roles to each service account. + clusterPerms := []operatorsv1alpha1.StrategyDeploymentPermissions{} + for saName, clusterRoleNames := range saNamesToClusterRoleNames { + p := operatorsv1alpha1.StrategyDeploymentPermissions{ServiceAccountName: saName} + for _, clusterRole := range c.ClusterRoles { + if _, ok := clusterRoleNames[clusterRole.GetName()]; ok { + p.Rules = append(p.Rules, clusterRole.Rules...) + } + } + clusterPerms = append(clusterPerms, p) + } + strategy.ClusterPermissions = clusterPerms +} + +// getSubjectServiceAccountNames returns a list of all ServiceAccount subject names. +func getSubjectServiceAccountNames(subjects []rbacv1.Subject) (saNames []string) { + for _, subject := range subjects { + if subject.Kind == "ServiceAccount" { + saNames = append(saNames, subject.Name) + } } - strategy.ClusterPermissions = perms + return saNames } // applyDeployments updates strategy's deployments with the Deployments diff --git a/internal/generate/collector/collect.go b/internal/generate/collector/collect.go index 642dd3205af..4e16eb0cd2c 100644 --- a/internal/generate/collector/collect.go +++ b/internal/generate/collector/collect.go @@ -40,6 +40,8 @@ import ( type Manifests struct { Roles []rbacv1.Role ClusterRoles []rbacv1.ClusterRole + RoleBindings []rbacv1.RoleBinding + ClusterRoleBindings []rbacv1.ClusterRoleBinding Deployments []appsv1.Deployment V1CustomResourceDefinitions []apiextv1.CustomResourceDefinition V1beta1CustomResourceDefinitions []apiextv1beta1.CustomResourceDefinition @@ -54,6 +56,8 @@ type Manifests struct { var ( roleGK = rbacv1.SchemeGroupVersion.WithKind("Role").GroupKind() clusterRoleGK = rbacv1.SchemeGroupVersion.WithKind("ClusterRole").GroupKind() + roleBindingGK = rbacv1.SchemeGroupVersion.WithKind("RoleBinding").GroupKind() + clusterRoleBindingGK = rbacv1.SchemeGroupVersion.WithKind("ClusterRoleBinding").GroupKind() deploymentGK = appsv1.SchemeGroupVersion.WithKind("Deployment").GroupKind() v1crdGK = apiextv1.SchemeGroupVersion.WithKind("CustomResourceDefinition").GroupKind() v1beta1crdGK = apiextv1beta1.SchemeGroupVersion.WithKind("CustomResourceDefinition").GroupKind() @@ -92,6 +96,10 @@ func (c *Manifests) UpdateFromDirs(deployDir, crdsDir string) error { err = c.addRoles(manifest) case clusterRoleGK: err = c.addClusterRoles(manifest) + case roleBindingGK: + err = c.addRoleBindings(manifest) + case clusterRoleBindingGK: + err = c.addClusterRoleBindings(manifest) case deploymentGK: err = c.addDeployments(manifest) case v1crdGK, v1beta1crdGK: @@ -154,6 +162,10 @@ func (c *Manifests) UpdateFromReader(r io.Reader) error { err = c.addRoles(manifest) case clusterRoleGK: err = c.addClusterRoles(manifest) + case roleBindingGK: + err = c.addRoleBindings(manifest) + case clusterRoleBindingGK: + err = c.addClusterRoleBindings(manifest) case deploymentGK: err = c.addDeployments(manifest) case v1crdGK, v1beta1crdGK: @@ -212,6 +224,30 @@ func (c *Manifests) addClusterRoles(rawManifests ...[]byte) error { return nil } +// addRoleBindings assumes all manifest data in rawManifests are RoleBindings and adds them to the collector. +func (c *Manifests) addRoleBindings(rawManifests ...[]byte) error { + for _, rawManifest := range rawManifests { + binding := rbacv1.RoleBinding{} + if err := yaml.Unmarshal(rawManifest, &binding); err != nil { + return err + } + c.RoleBindings = append(c.RoleBindings, binding) + } + return nil +} + +// addClusterRoleBindings assumes all manifest data in rawManifests are ClusterRoleBindings and adds them to the collector. +func (c *Manifests) addClusterRoleBindings(rawManifests ...[]byte) error { + for _, rawManifest := range rawManifests { + binding := rbacv1.ClusterRoleBinding{} + if err := yaml.Unmarshal(rawManifest, &binding); err != nil { + return err + } + c.ClusterRoleBindings = append(c.ClusterRoleBindings, binding) + } + return nil +} + // addDeployments assumes all manifest data in rawManifests are Deployments // and adds them to the collector. func (c *Manifests) addDeployments(rawManifests ...[]byte) error { diff --git a/internal/generate/collector/collect_test.go b/internal/generate/collector/collect_test.go deleted file mode 100644 index 0010cba259b..00000000000 --- a/internal/generate/collector/collect_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2018 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 collector - -import ( - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/assert" -) - -var ( - testDataDir = filepath.Join("..", "testdata") - goTestDataDir = filepath.Join(testDataDir, "non-standard-layout") - goConfigDir = filepath.Join(goTestDataDir, "config") -) - -func TestUpdateFromReader(t *testing.T) { - c := &Manifests{} - - err := filepath.Walk(goConfigDir, func(path string, info os.FileInfo, err error) error { - if err != nil || info.IsDir() { - return err - } - file, err := os.OpenFile(path, os.O_RDONLY, 0) - if err != nil { - return err - } - defer file.Close() - return c.UpdateFromReader(file) - }) - - assert.Nil(t, err, "failed to read manifests") - assert.Equal(t, len(c.Roles), 1, "failed to read Role(s)") - assert.Equal(t, len(c.Deployments), 1, "failed to read Deployment(s)") - // 2 CR/CRDs: - // - memcached.cache.examples.com - // - deployment.foo.example.com - assert.Equal(t, len(c.V1beta1CustomResourceDefinitions), 2, "failed to read v1beta1 CRDs") - assert.Equal(t, len(c.CustomResources), 2, "failed to read CRs") -} diff --git a/internal/generate/testdata/clusterserviceversions/newlayout/manifests/memcached-operator.clusterserviceversion.yaml b/internal/generate/testdata/clusterserviceversions/output/memcached-operator.clusterserviceversion.yaml similarity index 58% rename from internal/generate/testdata/clusterserviceversions/newlayout/manifests/memcached-operator.clusterserviceversion.yaml rename to internal/generate/testdata/clusterserviceversions/output/memcached-operator.clusterserviceversion.yaml index 6c5a0b6a972..af7b345e646 100644 --- a/internal/generate/testdata/clusterserviceversions/newlayout/manifests/memcached-operator.clusterserviceversion.yaml +++ b/internal/generate/testdata/clusterserviceversions/output/memcached-operator.clusterserviceversion.yaml @@ -8,10 +8,10 @@ metadata: "apiVersion": "cache.example.com/v1alpha1", "kind": "Memcached", "metadata": { - "name": "example-memcached" + "name": "memcached-sample" }, "spec": { - "size": 3 + "foo": "bar" } } ] @@ -42,97 +42,111 @@ spec: mediatype: "" install: spec: + clusterPermissions: + - rules: + - apiGroups: + - cache.example.com + resources: + - memcacheds + verbs: + - create + - delete + - get + - list + - patch + - update + - watch + - apiGroups: + - cache.example.com + resources: + - memcacheds/status + verbs: + - get + - patch + - update + - apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create + - apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create + serviceAccountName: default deployments: - - name: memcached-operator + - name: memcached-operator-controller-manager spec: replicas: 1 selector: matchLabels: - name: memcached-operator + control-plane: controller-manager strategy: {} template: metadata: labels: - name: memcached-operator + control-plane: controller-manager spec: containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=10 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https resources: {} - serviceAccountName: memcached-operator + - args: + - --metrics-addr=127.0.0.1:8080 + - --enable-leader-election + command: + - /manager + image: controller:latest + name: manager + resources: + limits: + cpu: 100m + memory: 30Mi + requests: + cpu: 100m + memory: 20Mi + terminationGracePeriodSeconds: 10 permissions: - rules: - apiGroups: - "" resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors verbs: - get + - list + - watch - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - update + - patch + - delete - apiGroups: - "" resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments + - configmaps/status verbs: - get + - update + - patch - apiGroups: - - cache.example.com + - "" resources: - - '*' + - events verbs: - - '*' - serviceAccountName: memcached-operator + - create + - patch + serviceAccountName: default strategy: deployment installModes: - supported: true diff --git a/internal/generate/testdata/non-standard-layout/PROJECT b/internal/generate/testdata/go/PROJECT similarity index 87% rename from internal/generate/testdata/non-standard-layout/PROJECT rename to internal/generate/testdata/go/PROJECT index ccdb9332a17..29a8478d6fd 100644 --- a/internal/generate/testdata/non-standard-layout/PROJECT +++ b/internal/generate/testdata/go/PROJECT @@ -1,5 +1,6 @@ domain: example.com layout: go.kubebuilder.io/v2 +projectName: memcached-operator repo: github.com/example/memcached-operator resources: - group: cache diff --git a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/doc.go b/internal/generate/testdata/go/api/v1alpha1/doc.go similarity index 100% rename from internal/generate/testdata/go/pkg/apis/cache/v1alpha1/doc.go rename to internal/generate/testdata/go/api/v1alpha1/doc.go diff --git a/internal/generate/testdata/go/api/v1alpha1/memcached_types.go b/internal/generate/testdata/go/api/v1alpha1/memcached_types.go index 985292f393e..99b77521bf4 100644 --- a/internal/generate/testdata/go/api/v1alpha1/memcached_types.go +++ b/internal/generate/testdata/go/api/v1alpha1/memcached_types.go @@ -21,14 +21,14 @@ import ( // MemcachedSpec defines the desired state of Memcached type MemcachedSpec struct { // Size is the size of the memcached deployment - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:csv:customresourcedefinitions:type=spec Size int32 `json:"size"` } // MemcachedStatus defines the observed state of Memcached type MemcachedStatus struct { // Nodes are the names of the memcached pods - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true + // +operator-sdk:csv:customresourcedefinitions:type=status Nodes []string `json:"nodes"` } @@ -38,7 +38,7 @@ type MemcachedStatus struct { // +kubebuilder:subresource:status // +kubebuilder:resource:path=memcacheds,scope=Namespaced // +kubebuilder:storageversion -// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Memcached App" +// +operator-sdk:csv:customresourcedefinitions:displayName="Memcached App Display Name" type Memcached struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` diff --git a/internal/generate/testdata/go/api/v1alpha2/doc.go b/internal/generate/testdata/go/api/v1alpha2/doc.go index 09ac980c8c3..5686f852db6 100644 --- a/internal/generate/testdata/go/api/v1alpha2/doc.go +++ b/internal/generate/testdata/go/api/v1alpha2/doc.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Package v1alpha1 contains API Schema definitions for the cache v1alpha1 API group +// Package v1alpha2 contains API Schema definitions for the cache v1alpha2 API group // +k8s:deepcopy-gen=package,register // +groupName=cache.example.com package v1alpha2 diff --git a/internal/generate/testdata/go/cmd/manager/main.go b/internal/generate/testdata/go/cmd/manager/main.go deleted file mode 100644 index 38dd16da61a..00000000000 --- a/internal/generate/testdata/go/cmd/manager/main.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -func main() {} diff --git a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcachedrs_crd.yaml b/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcachedrs_crd.yaml deleted file mode 100644 index be7b00dfc12..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcachedrs_crd.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: memcachedrs.cache.example.com -spec: - group: cache.example.com - names: - kind: MemcachedRS - listKind: MemcachedRSList - plural: memcachedrs - singular: memcachedrs - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: MemcachedRS is the Schema for the memcachedrs 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: MemcachedRSSpec defines the desired state of MemcachedRS - properties: - numNodes: - format: int32 - type: integer - required: - - numNodes - type: object - status: - description: MemcachedRSStatus defines the observed state of MemcachedRS - properties: - nodeList: - items: - type: string - type: array - test: - type: boolean - required: - - nodeList - - test - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcacheds_crd.yaml b/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcacheds_crd.yaml deleted file mode 100644 index 800a156069e..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_memcacheds_crd.yaml +++ /dev/null @@ -1,56 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: memcacheds.cache.example.com -spec: - group: cache.example.com - names: - kind: Memcached - listKind: MemcachedList - plural: memcacheds - singular: memcached - scope: Namespaced - versions: - - name: v1alpha1 - schema: - openAPIV3Schema: - description: Memcached is the Schema for the memcacheds 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: MemcachedSpec defines the desired state of Memcached - properties: - size: - description: Size is the size of the memcached deployment - format: int32 - type: integer - required: - - size - type: object - status: - description: MemcachedStatus defines the observed state of Memcached - properties: - nodes: - description: Nodes are the names of the memcached pods - items: - type: string - type: array - required: - - nodes - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcached_cr.yaml b/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcached_cr.yaml deleted file mode 100644 index 2b8f17c3998..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcached_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: cache.example.com/v1alpha1 -kind: Memcached -metadata: - name: example-memcached -spec: - # Add fields here - size: 3 diff --git a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcachedrs_cr.yaml b/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcachedrs_cr.yaml deleted file mode 100644 index 92861ed5fe5..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1/cache.example.com_v1alpha1_memcachedrs_cr.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: cache.example.com/v1alpha1 -kind: MemcachedRS -metadata: - name: example-memcachedrs -spec: - numNodes: 4 diff --git a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcachedrs_crd.yaml b/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcachedrs_crd.yaml deleted file mode 100644 index 9ffb3fab46d..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcachedrs_crd.yaml +++ /dev/null @@ -1,58 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: memcachedrs.cache.example.com -spec: - group: cache.example.com - names: - kind: MemcachedRS - listKind: MemcachedRSList - plural: memcachedrs - singular: memcachedrs - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: MemcachedRS is the Schema for the memcachedrs 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: MemcachedRSSpec defines the desired state of MemcachedRS - properties: - numNodes: - format: int32 - type: integer - required: - - numNodes - type: object - status: - description: MemcachedRSStatus defines the observed state of MemcachedRS - properties: - nodeList: - items: - type: string - type: array - test: - type: boolean - required: - - nodeList - - test - type: object - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true diff --git a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcacheds_crd.yaml b/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcacheds_crd.yaml deleted file mode 100644 index 0109edbab9a..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_memcacheds_crd.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: memcacheds.cache.example.com -spec: - group: cache.example.com - names: - kind: Memcached - listKind: MemcachedList - plural: memcacheds - singular: memcached - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: Memcached is the Schema for the memcacheds 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: MemcachedSpec defines the desired state of Memcached - properties: - size: - description: Size is the size of the memcached deployment - format: int32 - type: integer - required: - - size - type: object - status: - description: MemcachedStatus defines the observed state of Memcached - properties: - nodes: - description: Nodes are the names of the memcached pods - items: - type: string - type: array - required: - - nodes - type: object - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true diff --git a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcached_cr.yaml b/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcached_cr.yaml deleted file mode 100644 index 2b8f17c3998..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcached_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: cache.example.com/v1alpha1 -kind: Memcached -metadata: - name: example-memcached -spec: - # Add fields here - size: 3 diff --git a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcachedrs_cr.yaml b/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcachedrs_cr.yaml deleted file mode 100644 index 92861ed5fe5..00000000000 --- a/internal/generate/testdata/go/deploy/crds_v1beta1/cache.example.com_v1alpha1_memcachedrs_cr.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: cache.example.com/v1alpha1 -kind: MemcachedRS -metadata: - name: example-memcachedrs -spec: - numNodes: 4 diff --git a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.2/memcached-operator.v0.0.2.clusterserviceversion.yaml b/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.2/memcached-operator.v0.0.2.clusterserviceversion.yaml deleted file mode 100644 index bdbdf724572..00000000000 --- a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.2/memcached-operator.v0.0.2.clusterserviceversion.yaml +++ /dev/null @@ -1,212 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - }, - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "MemcachedRS", - "metadata": { - "name": "example-memcachedrs" - }, - "spec": { - "numNodes": 4 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.2 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: MemcachedRS is the Schema for the memcachedrs API - displayName: MemcachedRS App - kind: MemcachedRS - name: memcachedrs.cache.example.com - specDescriptors: - - displayName: Num Nodes - path: numNodes - statusDescriptors: - - displayName: Node List - path: nodeList - version: v1alpha1 - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Main enterprise application providing business critical features with - high availability and no manual intervention. - displayName: Memcached Application - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.2 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - memcached - - app - maintainers: - - email: corp@example.com - name: Some Corp - maturity: alpha - provider: - name: Example - url: www.example.com - version: 0.0.2 - webhookdefinitions: - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: vmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: ValidatingAdmissionWebhook - webhookPath: /validate-cache-example-com-v1alpha1-memcached - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: mmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: MutatingAdmissionWebhook - webhookPath: /mutate-cache-example-com-v1alpha1-memcached diff --git a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml b/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml deleted file mode 100644 index 4204b668f2e..00000000000 --- a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml +++ /dev/null @@ -1,213 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - }, - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "MemcachedRS", - "metadata": { - "name": "example-memcachedrs" - }, - "spec": { - "numNodes": 4 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.3 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: MemcachedRS is the Schema for the memcachedrs API - displayName: MemcachedRS App - kind: MemcachedRS - name: memcachedrs.cache.example.com - specDescriptors: - - displayName: Num Nodes - path: numNodes - statusDescriptors: - - displayName: Node List - path: nodeList - version: v1alpha1 - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Main enterprise application providing business critical features with - high availability and no manual intervention. - displayName: Memcached Application - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - memcached - - app - maintainers: - - email: corp@example.com - name: Some Corp - maturity: alpha - provider: - name: Example - url: www.example.com - replaces: memcached-operator.v0.0.2 - version: 0.0.3 - webhookdefinitions: - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: vmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: ValidatingAdmissionWebhook - webhookPath: /validate-cache-example-com-v1alpha1-memcached - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: mmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: MutatingAdmissionWebhook - webhookPath: /mutate-cache-example-com-v1alpha1-memcached diff --git a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/manifests/memcached-operator.clusterserviceversion.yaml b/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/manifests/memcached-operator.clusterserviceversion.yaml deleted file mode 100644 index ce132cdbf53..00000000000 --- a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/manifests/memcached-operator.clusterserviceversion.yaml +++ /dev/null @@ -1,212 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - }, - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "MemcachedRS", - "metadata": { - "name": "example-memcachedrs" - }, - "spec": { - "numNodes": 4 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.2 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: MemcachedRS is the Schema for the memcachedrs API - displayName: MemcachedRS App - kind: MemcachedRS - name: memcachedrs.cache.example.com - specDescriptors: - - displayName: Num Nodes - path: numNodes - statusDescriptors: - - displayName: Node List - path: nodeList - version: v1alpha1 - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Main enterprise application providing business critical features with - high availability and no manual intervention. - displayName: Memcached Application - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - memcached - - app - maintainers: - - email: corp@example.com - name: Some Corp - maturity: alpha - provider: - name: Example - url: www.example.com - version: 0.0.2 - webhookdefinitions: - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: vmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: ValidatingAdmissionWebhook - webhookPath: /validate-cache-example-com-v1alpha1-memcached - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: mmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: MutatingAdmissionWebhook - webhookPath: /mutate-cache-example-com-v1alpha1-memcached diff --git a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/memcached-operator.package.yaml b/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/memcached-operator.package.yaml deleted file mode 100644 index 63b19654795..00000000000 --- a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/memcached-operator.package.yaml +++ /dev/null @@ -1,7 +0,0 @@ -channels: -- currentCSV: memcached-operator.v0.0.2 - name: alpha -- currentCSV: memcached-operator.v0.0.3 - name: stable -defaultChannel: stable -packageName: memcached-operator diff --git a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/noupdate/memcached-operator.v0.0.3.clusterserviceversion.yaml b/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/noupdate/memcached-operator.v0.0.3.clusterserviceversion.yaml deleted file mode 100644 index 31afb9a1d1c..00000000000 --- a/internal/generate/testdata/go/deploy/olm-catalog/memcached-operator/noupdate/memcached-operator.v0.0.3.clusterserviceversion.yaml +++ /dev/null @@ -1,216 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - }, - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "MemcachedRS", - "metadata": { - "name": "example-memcachedrs" - }, - "spec": { - "numNodes": 4 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.3 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: MemcachedRS is the Schema for the memcachedrs API - displayName: MemcachedRS App - kind: MemcachedRS - name: memcachedrs.cache.example.com - specDescriptors: - - displayName: Num Nodes - path: numNodes - statusDescriptors: - - displayName: Node List - path: nodeList - version: v1alpha1 - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - x-descriptors: - - urn:alm:descriptor:com.tectonic.ui:podCount - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Memcached Operator description. TODO. - displayName: Memcached Operator - icon: - - base64data: "" - mediatype: "" - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - memcached-operator - links: - - name: Memcached Operator - url: https://memcached-operator.domain - maintainers: - - email: your@email.com - name: Maintainer Name - maturity: alpha - provider: - name: Provider Name - url: https://your.domain - version: 0.0.3 - webhookdefinitions: - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: vmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: ValidatingAdmissionWebhook - webhookPath: /validate-cache-example-com-v1alpha1-memcached - - admissionReviewVersions: null - deploymentName: memcached-operator-webhook - failurePolicy: Fail - generateName: mmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds - sideEffects: null - type: MutatingAdmissionWebhook - webhookPath: /mutate-cache-example-com-v1alpha1-memcached diff --git a/internal/generate/testdata/go/deploy/operator.yaml b/internal/generate/testdata/go/deploy/operator.yaml deleted file mode 100644 index 8a00f16ad68..00000000000 --- a/internal/generate/testdata/go/deploy/operator.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: memcached-operator -spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - template: - metadata: - labels: - name: memcached-operator - spec: - serviceAccountName: memcached-operator - containers: - - name: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - command: - - memcached-operator - imagePullPolicy: Never - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator diff --git a/internal/generate/testdata/go/deploy/role.yaml b/internal/generate/testdata/go/deploy/role.yaml deleted file mode 100644 index d1a2a04d0d0..00000000000 --- a/internal/generate/testdata/go/deploy/role.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: memcached-operator -rules: -- apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' -- apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' -- apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create -- apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update -- apiGroups: - - "" - resources: - - pods - verbs: - - get -- apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get -- apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' diff --git a/internal/generate/testdata/go/deploy/role_binding.yaml b/internal/generate/testdata/go/deploy/role_binding.yaml deleted file mode 100644 index 322ecc9e6ac..00000000000 --- a/internal/generate/testdata/go/deploy/role_binding.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: memcached-operator -subjects: -- kind: ServiceAccount - name: memcached-operator -roleRef: - kind: Role - name: memcached-operator - apiGroup: rbac.authorization.k8s.io diff --git a/internal/generate/testdata/go/deploy/service_account.yaml b/internal/generate/testdata/go/deploy/service_account.yaml deleted file mode 100644 index 8d58bc78322..00000000000 --- a/internal/generate/testdata/go/deploy/service_account.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: memcached-operator diff --git a/internal/generate/testdata/go/deploy/webhooks/cache-example-com-v1alpha1-memcached.webhook.yaml b/internal/generate/testdata/go/deploy/webhooks/cache-example-com-v1alpha1-memcached.webhook.yaml deleted file mode 100644 index 063f60f2f91..00000000000 --- a/internal/generate/testdata/go/deploy/webhooks/cache-example-com-v1alpha1-memcached.webhook.yaml +++ /dev/null @@ -1,50 +0,0 @@ ---- -apiVersion: admissionregistration.k8s.io/v1beta1 -kind: MutatingWebhookConfiguration -metadata: - creationTimestamp: null - name: memcached-operator-mutating-webhook-configuration -webhooks: -- clientConfig: - caBundle: Cg== - service: - name: memcached-operator-webhook-service - namespace: memcached-operator-system - path: /mutate-cache-example-com-v1alpha1-memcached - failurePolicy: Fail - name: mmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds ---- -apiVersion: admissionregistration.k8s.io/v1beta1 -kind: ValidatingWebhookConfiguration -metadata: - creationTimestamp: null - name: memcached-operator-validating-webhook-configuration -webhooks: -- clientConfig: - caBundle: Cg== - service: - name: memcached-operator-webhook-service - namespace: memcached-operator-system - path: /validate-cache-example-com-v1alpha1-memcached - failurePolicy: Fail - name: vmemcached.kb.io - rules: - - apiGroups: - - cache.example.com - apiVersions: - - v1alpha1 - operations: - - CREATE - - UPDATE - resources: - - memcacheds diff --git a/internal/generate/testdata/go/emptydir/.keep b/internal/generate/testdata/go/emptydir/.keep deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/dummy_types.go b/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/dummy_types.go deleted file mode 100644 index e6ee1101a7c..00000000000 --- a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/dummy_types.go +++ /dev/null @@ -1,183 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type NoKindSpec struct { - // Not included in anything, no kind type - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Size int32 `json:"size"` - // Not included in anything, no kind type - Boss Hog `json:"hog"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type NoKindStatus struct { - // Not included in anything, no kind type - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Nodes []string `json:"nodes"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type DummySpec struct { - // Should be in spec - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="dummy-pods" - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:podCount" - Size int32 `json:"size"` - // Should be in spec, but should not have array index in path - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Wheels" - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" - Wheels []Wheel `json:"wheels"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type DummyStatus struct { - // Should be in status but not spec, since DummyStatus isn't in DummySpec - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Nodes []string `json:"nodes"` - // Not included in status but children should be - Boss Hog `json:"hog"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type Hog struct { - // Should be in status but not spec, since Hog isn't in DummySpec - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors.displayName="boss-hog-engine" - Engine Engine `json:"engine"` - // Not in spec or status, no boolean annotation - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors.displayName="doesnt-matter" - Brand string `json:"brand"` - // Not in spec or status - Helmet string `json:"helmet"` - // Fields should be inlined - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Inlined InlinedComponent `json:",inline"` - // Fields should be inlined - InlinedComponent `json:",inline"` - // Should be ignored - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Ignored IgnoredComponent `json:"-"` - // Should be ignored, but exported children should not be - notExported `json:",inline"` -} - -type notExported struct { - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Public string `json:"foo"` - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - private string `json:"-"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type Engine struct { - // Should not be included, no annotations. - Pistons []string `json:"pistons"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type Wheel struct { - // Type should be in spec with path equal to wheels[0].type - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Wheel Type" - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:arrayFieldGroup:wheels,urn:alm:descriptor:com.tectonic.ui:text" - Type string `json:"type"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type InlinedComponent struct { - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - SeatMaterial string `json:"seatMaterial"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type IgnoredComponent struct { - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - TrunkSpace string `json:"trunkSpace"` -} - -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type OtherDummyStatus struct { - // Should be in status but not spec, since this isn't a spec type - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Nothing string `json:"nothing"` -} - -// Dummy is the Schema for the dummy API -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -// +kubebuilder:subresource:status -// +kubebuilder:resource:path=dummys,scope=Namespaced -// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Dummy App" -// +operator-sdk:gen-csv:customresourcedefinitions.resources="Deployment,v1,\"dummy-deployment\"" -// +operator-sdk:gen-csv:customresourcedefinitions.resources="ReplicaSet,v1beta2,\"dummy-replicaset\"" -// +operator-sdk:gen-csv:customresourcedefinitions.resources="Pod,v1,\"dummy-pod\"" -type Dummy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec DummySpec `json:"spec,omitempty"` - Status DummyStatus `json:"status,omitempty"` -} - -// OtherDummy is the Schema for the other dummy API -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Other Dummy App" -// +operator-sdk:gen-csv:customresourcedefinitions.resources="Service,v1,\"other-dummy-service\"" -// +operator-sdk:gen-csv:customresourcedefinitions.resources="Pod,v1,\"other-dummy-pod\"" -type OtherDummy struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec Hog `json:"spec,omitempty"` - Status OtherDummyStatus `json:"status,omitempty"` -} - -// DummyList contains a list of Dummy -// +k8s:deepcopy-gen=false -// +k8s:openapi-gen=false -type DummyList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Dummy `json:"items"` -} diff --git a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcached_types.go b/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcached_types.go deleted file mode 100644 index 985292f393e..00000000000 --- a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcached_types.go +++ /dev/null @@ -1,57 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// MemcachedSpec defines the desired state of Memcached -type MemcachedSpec struct { - // Size is the size of the memcached deployment - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - Size int32 `json:"size"` -} - -// MemcachedStatus defines the observed state of Memcached -type MemcachedStatus struct { - // Nodes are the names of the memcached pods - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - Nodes []string `json:"nodes"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Memcached is the Schema for the memcacheds API -// +kubebuilder:subresource:status -// +kubebuilder:resource:path=memcacheds,scope=Namespaced -// +kubebuilder:storageversion -// +operator-sdk:gen-csv:customresourcedefinitions.displayName="Memcached App" -type Memcached struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec MemcachedSpec `json:"spec,omitempty"` - Status MemcachedStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// MemcachedList contains a list of Memcached -type MemcachedList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Memcached `json:"items"` -} diff --git a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcachedrs_types.go b/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcachedrs_types.go deleted file mode 100644 index ec8dde33bfc..00000000000 --- a/internal/generate/testdata/go/pkg/apis/cache/v1alpha1/memcachedrs_types.go +++ /dev/null @@ -1,55 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// MemcachedRSSpec defines the desired state of MemcachedRS -type MemcachedRSSpec struct { - // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true - NumNodes int32 `json:"numNodes"` -} - -// MemcachedRSStatus defines the observed state of MemcachedRS -type MemcachedRSStatus struct { - // +operator-sdk:gen-csv:customresourcedefinitions.statusDescriptors=true - NodeList []string `json:"nodeList"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// MemcachedRS is the Schema for the memcachedrs API -// +kubebuilder:subresource:status -// +kubebuilder:resource:path=memcachedrs,scope=Namespaced -// +kubebuilder:storageversion -// +operator-sdk:gen-csv:customresourcedefinitions.displayName="MemcachedRS App" -type MemcachedRS struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec MemcachedRSSpec `json:"spec,omitempty"` - Status MemcachedRSStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// MemcachedRSList contains a list of MemcachedRS -type MemcachedRSList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []MemcachedRS `json:"items"` -} diff --git a/internal/generate/testdata/go/static/basic.operatory.yaml b/internal/generate/testdata/go/static/basic.operatory.yaml new file mode 100644 index 00000000000..2d97140d3c0 --- /dev/null +++ b/internal/generate/testdata/go/static/basic.operatory.yaml @@ -0,0 +1,258 @@ +apiVersion: v1 +kind: Namespace +metadata: + labels: + control-plane: controller-manager + name: memcached-operator-system +--- +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.3.0 + creationTimestamp: null + name: memcacheds.cache.example.com +spec: + group: cache.example.com + names: + kind: Memcached + listKind: MemcachedList + plural: memcacheds + singular: memcached + scope: Namespaced + subresources: + status: {} + validation: + openAPIV3Schema: + description: Memcached is the Schema for the memcacheds 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: MemcachedSpec defines the desired state of Memcached + properties: + foo: + description: Foo is an example field of Memcached. Edit Memcached_types.go + to remove/update + type: string + type: object + status: + description: MemcachedStatus defines the observed state of Memcached + type: object + type: object + version: v1alpha1 + versions: + - name: v1alpha1 + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: memcached-operator-leader-election-role + namespace: memcached-operator-system +rules: +- apiGroups: + - "" + resources: + - configmaps + verbs: + - get + - list + - watch + - create + - update + - patch + - delete +- apiGroups: + - "" + resources: + - configmaps/status + verbs: + - get + - update + - patch +- apiGroups: + - "" + resources: + - events + verbs: + - create + - patch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + creationTimestamp: null + name: memcached-operator-manager-role +rules: +- apiGroups: + - cache.example.com + resources: + - memcacheds + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - cache.example.com + resources: + - memcacheds/status + verbs: + - get + - patch + - update +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: memcached-operator-proxy-role +rules: +- apiGroups: + - authentication.k8s.io + resources: + - tokenreviews + verbs: + - create +- apiGroups: + - authorization.k8s.io + resources: + - subjectaccessreviews + verbs: + - create +--- +apiVersion: rbac.authorization.k8s.io/v1beta1 +kind: ClusterRole +metadata: + name: memcached-operator-metrics-reader +rules: +- nonResourceURLs: + - /metrics + verbs: + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: memcached-operator-leader-election-rolebinding + namespace: memcached-operator-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: memcached-operator-leader-election-role +subjects: +- kind: ServiceAccount + name: default + namespace: memcached-operator-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: memcached-operator-manager-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: memcached-operator-manager-role +subjects: +- kind: ServiceAccount + name: default + namespace: memcached-operator-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: memcached-operator-proxy-rolebinding +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: memcached-operator-proxy-role +subjects: +- kind: ServiceAccount + name: default + namespace: memcached-operator-system +--- +apiVersion: v1 +kind: Service +metadata: + labels: + control-plane: controller-manager + name: memcached-operator-controller-manager-metrics-service + namespace: memcached-operator-system +spec: + ports: + - name: https + port: 8443 + targetPort: https + selector: + control-plane: controller-manager +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + control-plane: controller-manager + name: memcached-operator-controller-manager + namespace: memcached-operator-system +spec: + replicas: 1 + selector: + matchLabels: + control-plane: controller-manager + template: + metadata: + labels: + control-plane: controller-manager + spec: + containers: + - args: + - --secure-listen-address=0.0.0.0:8443 + - --upstream=http://127.0.0.1:8080/ + - --logtostderr=true + - --v=10 + image: gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 + name: kube-rbac-proxy + ports: + - containerPort: 8443 + name: https + - args: + - --metrics-addr=127.0.0.1:8080 + - --enable-leader-election + command: + - /manager + image: controller:latest + name: manager + resources: + limits: + cpu: 100m + memory: 30Mi + requests: + cpu: 100m + memory: 20Mi + terminationGracePeriodSeconds: 10 +--- +apiVersion: cache.example.com/v1alpha1 +kind: Memcached +metadata: + name: memcached-sample +spec: + foo: bar diff --git a/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/doc.go b/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/doc.go deleted file mode 100644 index d5094b45a66..00000000000 --- a/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/doc.go +++ /dev/null @@ -1,18 +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 v1alpha1 contains API Schema definitions for the cache v1alpha1 API group -// +k8s:deepcopy-gen=package,register -// +groupName=cache.example.com -package v1alpha1 diff --git a/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/memcached_types.go b/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/memcached_types.go deleted file mode 100644 index 99b77521bf4..00000000000 --- a/internal/generate/testdata/non-standard-layout/api/cache/v1alpha1/memcached_types.go +++ /dev/null @@ -1,57 +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 v1alpha1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// MemcachedSpec defines the desired state of Memcached -type MemcachedSpec struct { - // Size is the size of the memcached deployment - // +operator-sdk:csv:customresourcedefinitions:type=spec - Size int32 `json:"size"` -} - -// MemcachedStatus defines the observed state of Memcached -type MemcachedStatus struct { - // Nodes are the names of the memcached pods - // +operator-sdk:csv:customresourcedefinitions:type=status - Nodes []string `json:"nodes"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// Memcached is the Schema for the memcacheds API -// +kubebuilder:subresource:status -// +kubebuilder:resource:path=memcacheds,scope=Namespaced -// +kubebuilder:storageversion -// +operator-sdk:csv:customresourcedefinitions:displayName="Memcached App Display Name" -type Memcached struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - Spec MemcachedSpec `json:"spec,omitempty"` - Status MemcachedStatus `json:"status,omitempty"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// MemcachedList contains a list of Memcached -type MemcachedList struct { - metav1.TypeMeta `json:",inline"` - metav1.ListMeta `json:"metadata,omitempty"` - Items []Memcached `json:"items"` -} diff --git a/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_deployment_crd.yaml b/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_deployment_crd.yaml deleted file mode 100644 index 44f4065c8c5..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_deployment_crd.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: deployment.foo.example.com -spec: - group: foo.example.com - names: - kind: Deployment - listKind: DeploymentList - plural: deployments - singular: deployment - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: Schema for the deployments 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: DeploymentSpec defines the desired state of the Foo Deployment - properties: - size: - description: Size is the size of the Foo deployment nodes - format: int32 - type: integer - required: - - size - type: object - status: - description: DeploymentStatus defines the observed state of the Foo Deployment - properties: - nodes: - description: Nodes are the names of the Foo pods - items: - type: string - type: array - required: - - nodes - type: object - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true diff --git a/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_v1alpha1_deployment_cr.yaml b/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_v1alpha1_deployment_cr.yaml deleted file mode 100644 index 1e7da7daf47..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/crds-with-core-types/foo.example.com_v1alpha1_deployment_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: foo.example.com/v1alpha1 -kind: Deployment -metadata: - name: example-foo-deployment -spec: - # Add fields here - size: 3 diff --git a/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_memcacheds_crd.yaml b/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_memcacheds_crd.yaml deleted file mode 100644 index 0109edbab9a..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_memcacheds_crd.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - name: memcacheds.cache.example.com -spec: - group: cache.example.com - names: - kind: Memcached - listKind: MemcachedList - plural: memcacheds - singular: memcached - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: Memcached is the Schema for the memcacheds 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: MemcachedSpec defines the desired state of Memcached - properties: - size: - description: Size is the size of the memcached deployment - format: int32 - type: integer - required: - - size - type: object - status: - description: MemcachedStatus defines the observed state of Memcached - properties: - nodes: - description: Nodes are the names of the memcached pods - items: - type: string - type: array - required: - - nodes - type: object - type: object - version: v1alpha1 - versions: - - name: v1alpha1 - served: true - storage: true diff --git a/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_v1alpha1_memcached_cr.yaml b/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_v1alpha1_memcached_cr.yaml deleted file mode 100644 index 2b8f17c3998..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/crds/cache.example.com_v1alpha1_memcached_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: cache.example.com/v1alpha1 -kind: Memcached -metadata: - name: example-memcached -spec: - # Add fields here - size: 3 diff --git a/internal/generate/testdata/non-standard-layout/config/operator.yaml b/internal/generate/testdata/non-standard-layout/config/operator.yaml deleted file mode 100644 index 8a00f16ad68..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/operator.yaml +++ /dev/null @@ -1,32 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: memcached-operator -spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - template: - metadata: - labels: - name: memcached-operator - spec: - serviceAccountName: memcached-operator - containers: - - name: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - command: - - memcached-operator - imagePullPolicy: Never - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.namespace - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator diff --git a/internal/generate/testdata/non-standard-layout/config/role.yaml b/internal/generate/testdata/non-standard-layout/config/role.yaml deleted file mode 100644 index d1a2a04d0d0..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/role.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: memcached-operator -rules: -- apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' -- apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' -- apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create -- apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update -- apiGroups: - - "" - resources: - - pods - verbs: - - get -- apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get -- apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' diff --git a/internal/generate/testdata/non-standard-layout/config/role_binding.yaml b/internal/generate/testdata/non-standard-layout/config/role_binding.yaml deleted file mode 100644 index 322ecc9e6ac..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/role_binding.yaml +++ /dev/null @@ -1,11 +0,0 @@ -kind: RoleBinding -apiVersion: rbac.authorization.k8s.io/v1 -metadata: - name: memcached-operator -subjects: -- kind: ServiceAccount - name: memcached-operator -roleRef: - kind: Role - name: memcached-operator - apiGroup: rbac.authorization.k8s.io diff --git a/internal/generate/testdata/non-standard-layout/config/service_account.yaml b/internal/generate/testdata/non-standard-layout/config/service_account.yaml deleted file mode 100644 index 8d58bc78322..00000000000 --- a/internal/generate/testdata/non-standard-layout/config/service_account.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: ServiceAccount -metadata: - name: memcached-operator diff --git a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.1/memcached-operator.v0.0.1.clusterserviceversion.yaml b/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.1/memcached-operator.v0.0.1.clusterserviceversion.yaml deleted file mode 100644 index 6c5a0b6a972..00000000000 --- a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.1/memcached-operator.v0.0.1.clusterserviceversion.yaml +++ /dev/null @@ -1,158 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.1 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App Display Name - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Memcached Operator description. TODO. - displayName: Memcached Operator - icon: - - base64data: "" - mediatype: "" - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - memcached-operator - links: - - name: Memcached Operator - url: https://memcached-operator.domain - maintainers: - - email: your@email.com - name: Maintainer Name - maturity: alpha - provider: - name: Provider Name - url: https://your.domain - version: 0.0.1 diff --git a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml b/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml deleted file mode 100644 index 8d9dcde805d..00000000000 --- a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.3/memcached-operator.v0.0.3.clusterserviceversion.yaml +++ /dev/null @@ -1,159 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.3 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App Display Name - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Memcached Operator description. TODO. - displayName: Memcached Operator - icon: - - base64data: "" - mediatype: "" - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - FooBar - - These keywords must be preserved in the CSV update tests from 0.0.3 to 0.0.4 - links: - - name: Memcached Operator - url: https://memcached-operator.domain - maintainers: - - email: your@email.com - name: Maintainer Name - maturity: alpha - provider: - name: Provider Name - url: https://your.domain - version: 0.0.3 diff --git a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.4/memcached-operator.v0.0.4.clusterserviceversion.yaml b/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.4/memcached-operator.v0.0.4.clusterserviceversion.yaml deleted file mode 100644 index 63f288cdb16..00000000000 --- a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/0.0.4/memcached-operator.v0.0.4.clusterserviceversion.yaml +++ /dev/null @@ -1,160 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: ClusterServiceVersion -metadata: - annotations: - alm-examples: |- - [ - { - "apiVersion": "cache.example.com/v1alpha1", - "kind": "Memcached", - "metadata": { - "name": "example-memcached" - }, - "spec": { - "size": 3 - } - } - ] - capabilities: Basic Install - name: memcached-operator.v0.0.4 - namespace: placeholder -spec: - apiservicedefinitions: {} - customresourcedefinitions: - owned: - - description: Memcached is the Schema for the memcacheds API - displayName: Memcached App Display Name - kind: Memcached - name: memcacheds.cache.example.com - specDescriptors: - - description: Size is the size of the memcached deployment - displayName: Size - path: size - statusDescriptors: - - description: Nodes are the names of the memcached pods - displayName: Nodes - path: nodes - version: v1alpha1 - description: Memcached Operator description. TODO. - displayName: Memcached Operator - icon: - - base64data: "" - mediatype: "" - install: - spec: - deployments: - - name: memcached-operator - spec: - replicas: 1 - selector: - matchLabels: - name: memcached-operator - strategy: {} - template: - metadata: - labels: - name: memcached-operator - spec: - containers: - - command: - - memcached-operator - env: - - name: WATCH_NAMESPACE - valueFrom: - fieldRef: - fieldPath: metadata.annotations['olm.targetNamespaces'] - - name: POD_NAME - valueFrom: - fieldRef: - fieldPath: metadata.name - - name: OPERATOR_NAME - value: memcached-operator - image: quay.io/example/memcached-operator:v0.0.3 - imagePullPolicy: Never - name: memcached-operator - resources: {} - serviceAccountName: memcached-operator - permissions: - - rules: - - apiGroups: - - "" - resources: - - pods - - services - - services/finalizers - - endpoints - - persistentvolumeclaims - - events - - configmaps - - secrets - verbs: - - '*' - - apiGroups: - - apps - resources: - - deployments - - daemonsets - - replicasets - - statefulsets - verbs: - - '*' - - apiGroups: - - monitoring.coreos.com - resources: - - servicemonitors - verbs: - - get - - create - - apiGroups: - - apps - resourceNames: - - memcached-operator - resources: - - deployments/finalizers - verbs: - - update - - apiGroups: - - "" - resources: - - pods - verbs: - - get - - apiGroups: - - apps - resources: - - replicasets - - deployments - verbs: - - get - - apiGroups: - - cache.example.com - resources: - - '*' - verbs: - - '*' - serviceAccountName: memcached-operator - strategy: deployment - installModes: - - supported: true - type: OwnNamespace - - supported: true - type: SingleNamespace - - supported: false - type: MultiNamespace - - supported: true - type: AllNamespaces - keywords: - - FooBar - - These keywords must be preserved in the CSV update tests from 0.0.3 to 0.0.4 - links: - - name: Memcached Operator - url: https://memcached-operator.domain - maintainers: - - email: your@email.com - name: Maintainer Name - maturity: alpha - provider: - name: Provider Name - url: https://your.domain - replaces: memcached-operator.v0.0.3 - version: 0.0.4 diff --git a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/memcached-operator.package.yaml b/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/memcached-operator.package.yaml deleted file mode 100644 index 64d34201345..00000000000 --- a/internal/generate/testdata/non-standard-layout/expected-catalog/olm-catalog/memcached-operator/memcached-operator.package.yaml +++ /dev/null @@ -1,5 +0,0 @@ -channels: -- currentCSV: memcached-operator.v0.0.3 - name: stable -defaultChannel: stable -packageName: memcached-operator diff --git a/internal/generate/testdata/non-standard-layout/main.go b/internal/generate/testdata/non-standard-layout/main.go deleted file mode 100644 index 38dd16da61a..00000000000 --- a/internal/generate/testdata/non-standard-layout/main.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -func main() {}