From 321525f2a49ced7465a211fe32b71a6e52908280 Mon Sep 17 00:00:00 2001 From: jubittajohn Date: Fri, 11 Aug 2023 02:59:47 -0400 Subject: [PATCH] Updated comments and README Signed-off-by: jubittajohn --- test/operator-framework-e2e/README.md | 137 +++++++++++++----- .../create_fbc_helper.go | 20 ++- .../generate_dockerfile.go | 14 +- .../operator_framework_test.go | 70 ++++----- 4 files changed, 155 insertions(+), 86 deletions(-) diff --git a/test/operator-framework-e2e/README.md b/test/operator-framework-e2e/README.md index 5f2ba13a5..c7b4dbb7c 100644 --- a/test/operator-framework-e2e/README.md +++ b/test/operator-framework-e2e/README.md @@ -26,15 +26,18 @@ The steps in the ginkgo test can be summarized as follows: - With the scale of the OLM v1 project, it is useful to have a means to test components in the operator development + lifecycle pipeline together to create a more cohesive experience for all users. ## Getting Started - +- This test currently only works with the container runtime `docker`. - Building operator-controller, deploying it into the cluster and rest of the configuration is done in the `MakeFile` of this repo under the target `operator-developer-e2e`. This includes: - Setting up a kind cluster named `operator-controller-op-dev-e2e`. - Installing the operator controller onto the cluster. - Setting up `opm`, `operator-sdk` and `kustomize` using bingo. - Setting up a local registry server for building and loading images. +### Input Values used + +Below are the input values used in the test which is specified in the `operator_framework_test.go`. -- The following structs defined are required as input for both plain+v0 and registry+v1 bundles: +- The following structs defined are required, to accept input for both `plain+v0` and `registry+v1` bundles: - For getting bundle related inputs: ``` type BundleInfo struct { @@ -48,11 +51,11 @@ The steps in the ginkgo test can be summarized as follows: imageRef string } ``` - - `baseFolderPath` - Base/root path of the folder for the specific bundle type input data.[path to plain-v0 or registry-v1 bundles testdata] + - `baseFolderPath` - Base/root path of the folder where the specific bundle type input data is stored.[root path to plain-v0 or registry-v1 bundles testdata] - `bundles` - Stores the data relevant to different versions of the bundle. - - `bInputDir` - The input directory containing the specific version of the bundle data. + - `bInputDir` - The directory that stores the specific version of the bundle data. The name of the directory is formed and is of the format `.v`. - `bundleVersion` - The specific version of the bundle data. - - `imageRef` - This is formed. Stores the bundle image reference which will be of the format `localhost:5001/-bundle:v.` + - `imageRef` - This is formed. Stores the bundle image reference which will be of the format `/< operatorName>-bundle:v.` - For getting catalog related inputs: ``` type CatalogDInfo struct { @@ -64,11 +67,11 @@ The steps in the ginkgo test can be summarized as follows: fbcFileName string } ``` - - `baseFolderPath` - Base/root path of the folder for the catalogs. + - `baseFolderPath` - Base/root path of the folder that stores the catalogs. - `operatorName` - Name of the operator to be installed from the bundles. - `desiredChannelName` - Desired channel name for the operator. - - `catalogDir` - This is formed. The directory to store the FBC. The formed value will be of the format: `-catalog` - - `imageRef` - This is formed. Stores the FBC image reference which will be of the format: `localhost:5001//:test` + - `catalogDir` - This is formed. The directory to store the catalog/FBC. The directory name will be of the format: `-catalog` + - `imageRef` - This is formed. Stores the FBC image reference which will be of the format: `/:test` - `fbcFileName` - Name of the FBC file. This is hard-coded as `catalog.yaml`. - For getting information related to the install/upgrade action for operators: ``` @@ -80,9 +83,8 @@ The steps in the ginkgo test can be summarized as follows: - `installVersion` - Version of the operator to be installed on the cluster. - `upgradeVersion` - Version of the operator to be upgraded on the cluster. -### Plain bundles -- The plain+v0 bundles are formed using `operator-sdk` and `kustomize`. - - The below input is used to form the bundle using operator-sdk. + - The below inputs are used to form the bundle using operator-sdk. + ``` type SdkProjectInfo struct { projectName string @@ -92,42 +94,109 @@ The steps in the ginkgo test can be summarized as follows: kind string } ``` +## How to run +- Makefile target `operator-developer-e2e` : Runs the entire E2E setup. +- Makefile target `test-op-dev-e2e`: Runs the ginkgo test. +- Makefile target `deploy-local-registry`: Deploys local registry +- Makefile target `cleanup-local-registry` : Stops and removes local registry +- Makefile target `kind-cluster-cleanup`: Deletes the kind cluster + +## Bundle Types +### Plain bundles +- The `plain+v0` bundles are formed using `operator-sdk` and `kustomize`. + - The `kustomize` organizes the different resources present in the `operator-sdk` project into a single yaml file. + - The Dockerfile for the bundle is named `plainbundle.Dockerfile` and is generated using a custom routine. + - The generated bundle is stored in the format: + ``` + plain-v0 + └── .v + └── manifests + │ └── mainfest.yaml + └── plainbundle.Dockerfile + ``` -- After the bundle image is created and loaded, the FBC is formed by a custom routine by using the operatorName, desiredChannelName, bundle imageRefs and bundleVersions. - - - The generated FBC will be present in the file path: `testdata/catalogs/-catalog/catalog.yaml` and the Dockerfile will be formed in the file path: `testdata/catalogs/-catalog.Dockerfile` - - `Default channel` is not used in forming the FBC as it is not an OLMv1 concept. - - The package schema name will be the operatorName and the bundle name will be `.v`. -- The catalog resource is then formed with the name `-catalog`. +- The FBC template is formed by a custom routine by using the operatorName, desiredChannelName, bundle imageRefs and bundleVersions. + - `Default channel` is not used in forming the FBC as it is not an OLMv1 concept. + - Only one `olm.channel` is generated which is the given . + - Upgrade graph is formed with only replaces edge. + - The generated FBC is not validated using `opm` as the tool has no support for plain bundles. + - The Dockerfile for the catalog is named `-catalog.Dockerfile` and is generated using a custom routine. + - The generated catalog is stored in the format: + ``` + catalogs + └── -catalog + │ └── catalog.yaml + └── -catalog.Dockerfile + ``` +- The catalog CR is then formed with the name `-catalog`. - The operator is then installed and has the name ``. ### Registry Bundles - The registry+v1 bundles are formed using operator-sdk. - - The below input is used to form the bundle using operator-sdk. + - The generated CSV uses the default values. + - The bundle content is formed within the operator-sdk project directory in the folder `bundle`. This is moved to the bundle directory folder. + - The generated Dockerfile has the name `bundle.Dockerfile`. The Dockerfile and bundle structure is genearted by the `operator-sdk` tool. + - The generated bundle is stored in the format: ``` - type SdkProjectInfo struct { - projectName string - domainName string - group string - version string - kind string - } + registry-v1 + └── .v + └── manifests + └── metadata + └── bundle.Dockerfile + ``` + +- The FBC is formed using `opm alpha render-template semver` tool. + - The semver template named `registry-semver.yaml` is formed using a custom routine by passing the bundle imageRefs. + - `generatemajorchannels` and `generateminorchannels` is set to false in the semver template. + - The generated catalog is stored in the format: + ``` + catalogs + └── -catalog + │ └── catalog.yaml + └── -catalog.Dockerfile ``` - - The generated CSV uses the default values. - - The bundle content is formed in the operator-sdk project directory in the folder `bundle`. This is moved to the folder path: `testdata/bundles/registry-v1/.v`. - - The generated Dockerfile has the name `bundle.Dockerfile`. - - The same project directory needs to be updated for forming a different version of the `bundle`. -- After the bundle image is created and loaded, the FBC is formed using `semver` and `opm` tool. - - The semver named `registry-semver.yaml` is formed by passing the bundle imageRefs. - - The generated FBC will be present in the file path: `testdata/catalogs/-catalog/catalog.yaml` and the Dockerfile will be formed in the file path: `testdata/catalogs/-catalog.Dockerfile` - - The package schema name will be the operator-sdk projectName. - The catalog resource is then formed with the name `-catalog`. - The operator is then installed and has the name ``. -- After the e2e workflow, all the files formed are cleared and the catalog is deleted. +- After the e2e workflow, all the files formed are cleared. + + +## To-do +1. The resources are read from input manifests using universal decoder from `k8s.io/apimachinery/pkg/runtime/serializer`. + - However, in cases where a single file contains multiple YAML documents separated by `---,` the `UniversalDecoder` recognizes only the first resource. This situation is relevant as for `plain+v0` bundles generated through `kustomize,` the manifest has multiple YAML documents are combined into one file using --- separators. This is now handled by splitting the content of the YAML file and decoding each of them using the `UniversalDecoder`. + - This workaround can be improved using `YAMLToJSONDecoder` from `k8s.io/apimachinery/pkg/util/yaml`. And the kind, api version and name can be get by decoding into `Unstructured` from `k8s.io/apimachinery/pkg/apis/meta/v1/unstructured`. +2. All the tests pass and the operator is installed successfully. The bundledeployment succeeds and the resources are created. But the pod for the new operator failes due to `ImagePullBackOff`. + - This is because the `Deployment` controller-manager uses the image `controller:latest` which is not present on the cluster. + - The solution would be to replace `controller:latest` with the `busybox:latest` and then pulling and loading `busybox:latest` onto cluster. + - The replacement could possibly be achieved by adding the following to `config/default/kustomization.yaml` under `operator-sdk` project: + ``` + images: + - name: controller + newName: controller + newTag: latest + ``` +## Issues +1. This test currently only works with the container runtime `docker`. + - The default value of CONTAINER_RUNTIME defined in the Makefile is `docker`. Therefore the correct runtime has to be assigned to the variable `CONTAINER_RUNTIME` before calling the make target if docker is what is not being used. The test routine also assumes the runtime as `docker` if it is unable to retrieve the value of the environment variable. + - But this is only a partial fix to the problem. With this change the test for `plain+v0` bundles will pass but for `registry+v1` will fail for other container runtimes. This is because `registry+v1` uses `operator-sdk` support. Thus to mimic the user experience, the targets `bundle-build` and `bundle-push` from the generated Makefile by operator-sdk tool, which has docker being hard coded as the container runtime, is used to build and push the bundle images. This could be marked as an issue and addressed when hard coding docker as container runtime in the generated Makefile is addressed by operator-sdk. + +2. The `opm`,`operator-sdk` and `kustomize` binaries are added in operator-controller using `bingo`. + - But based on discussions, if required test should be changed so that it has `opm` and `operator-sdk` in `PATH` and simply runs it like `exec.Command("opm", ...)`. + - This will enable in running [a matrix](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs) for the tests and to use different versions of `opm` and `operator-sdk`. + - This might help in emulating the user experience better. + +## Tooling gaps + +Following are the tooling gaps identified while testing `operator-framework` end-to-end: +- `opm` doesn't have plain bundle support. +- No tool for forming FBC for plain bundles. +- No tool for generating Dockerfile for plain bundles. +- No tool for generating Dockerfile for plain catalogs. +- Since `opm` doesn't have plain bundle support, there is no means to validate the FBC generated for plain bundles. + diff --git a/test/operator-framework-e2e/create_fbc_helper.go b/test/operator-framework-e2e/create_fbc_helper.go index 68d9ae0ca..731fd39ad 100644 --- a/test/operator-framework-e2e/create_fbc_helper.go +++ b/test/operator-framework-e2e/create_fbc_helper.go @@ -13,21 +13,18 @@ import ( ) const ( - SchemaPackage = "olm.package" - SchemaChannel = "olm.channel" - SchemaBundle = "olm.bundle" SchemaBundleMediatype = "olm.bundle.mediatype" BundleMediatype = "plain+v0" ) // Forms the FBC declartive config and creates the FBC by calling functions for forming the package, channel and bundles. -func CreateFBC(operatorName, defaultChannel string, bundleRefsVersions map[string]string) *declcfg.DeclarativeConfig { +func CreateFBC(operatorName, channelName string, bundleRefsVersions map[string]string) *declcfg.DeclarativeConfig { dPackage := formPackage(operatorName) bundleVersions := make([]string, 0) for _, bundleVersion := range bundleRefsVersions { bundleVersions = append(bundleVersions, bundleVersion) } - dChannel := formChannel(operatorName, defaultChannel, bundleVersions) + dChannel := formChannel(operatorName, channelName, bundleVersions) dBundle := formBundle(operatorName, bundleRefsVersions) @@ -42,7 +39,7 @@ func CreateFBC(operatorName, defaultChannel string, bundleRefsVersions map[strin // Forms package schema for the FBC func formPackage(pkgName string) declcfg.Package { packageFormed := declcfg.Package{ - Schema: SchemaPackage, + Schema: declcfg.SchemaPackage, Name: pkgName, } return packageFormed @@ -52,7 +49,7 @@ func formPackage(pkgName string) declcfg.Package { func formChannel(pkgName, channelName string, bundleVersions []string) declcfg.Channel { channelEntries := formChannelEntries(pkgName, bundleVersions) channelFormed := declcfg.Channel{ - Schema: SchemaChannel, + Schema: declcfg.SchemaChannel, Name: channelName, Package: pkgName, Entries: channelEntries, @@ -60,7 +57,8 @@ func formChannel(pkgName, channelName string, bundleVersions []string) declcfg.C return channelFormed } -// Forms the uprade graph for the FBC +// Forms the uprade graph for the FBC. Only forms replaces edge. For forming replaces edge, +// bundleVersions are assumed to be in increasing version number order. func formChannelEntries(pkgName string, bundleVersions []string) []declcfg.ChannelEntry { channelEntries := make([]declcfg.ChannelEntry, 0, len(bundleVersions)) for i, version := range bundleVersions { @@ -83,7 +81,7 @@ func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bun for imgRef, version := range imgRefsVersions { var properties []property.Property properties = append(properties, property.Property{ - Type: SchemaPackage, + Type: declcfg.SchemaPackage, Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, version)), }) properties = append(properties, property.Property{ @@ -92,7 +90,7 @@ func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bun }) bundleFormed = append(bundleFormed, declcfg.Bundle{ - Schema: SchemaBundle, + Schema: declcfg.SchemaBundle, Name: pkgName + ".v" + version, Package: pkgName, Image: imgRef, @@ -102,7 +100,7 @@ func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bun return bundleFormed } -// Writes the formed FBC into catalog.yaml file +// Writes the formed FBC into catalog.yaml file in the path fbcFilePath func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) error { var buf bytes.Buffer if err := declcfg.WriteYAML(fbc, &buf); err != nil { diff --git a/test/operator-framework-e2e/generate_dockerfile.go b/test/operator-framework-e2e/generate_dockerfile.go index b58a35e1d..c5d888fb8 100644 --- a/test/operator-framework-e2e/generate_dockerfile.go +++ b/test/operator-framework-e2e/generate_dockerfile.go @@ -5,7 +5,7 @@ import ( "text/template" ) -// GenerateDockerFile generates Dockerfile and its contents for a given set of yaml files +// GenerateDockerFile generates Dockerfile and its contents for the data in yamlFolderName func generateDockerFile(dockerFilePath, yamlFolderName, dockerfileTmpl string) error { t, err := template.New("dockerfile").Parse(dockerfileTmpl) if err != nil { @@ -26,14 +26,14 @@ func generateDockerFile(dockerFilePath, yamlFolderName, dockerfileTmpl string) e return err } -// GenerateCatalogDockerFile generates Dockerfile for the catalog -func generateCatalogDockerFile(dockerFilePath, yamlFolderName string) error { - return generateDockerFile(dockerFilePath, yamlFolderName, catalogDockerfileTmpl) +// GenerateCatalogDockerFile generates Dockerfile for the catalog content in catalogFolderName +func generateCatalogDockerFile(dockerFilePath, catalogFolderName string) error { + return generateDockerFile(dockerFilePath, catalogFolderName, catalogDockerfileTmpl) } -// GenerateBundleDockerFile generates Dockerfile for the bundle -func generateBundleDockerFile(dockerFilePath, yamlFolderName string) error { - return generateDockerFile(dockerFilePath, yamlFolderName, bundleDockerfileTmpl) +// GenerateBundleDockerFile generates Dockerfile for the bundle content in bundleFolderName +func generateBundleDockerFile(dockerFilePath, bundleFolderName string) error { + return generateDockerFile(dockerFilePath, bundleFolderName, bundleDockerfileTmpl) } // Dockerfile templates diff --git a/test/operator-framework-e2e/operator_framework_test.go b/test/operator-framework-e2e/operator_framework_test.go index f2f73fc88..db2e6a836 100644 --- a/test/operator-framework-e2e/operator_framework_test.go +++ b/test/operator-framework-e2e/operator_framework_test.go @@ -40,23 +40,23 @@ var ( ) type BundleInfo struct { - baseFolderPath string // Base path of the folder for the specific the bundle type input data - bundles []BundleContent // Stores the data relevant to different versions of the bundle + baseFolderPath string // root path of the folder where the specific bundle type input data is stored + bundles []BundleContent // stores the data relevant to different versions of the bundle } type BundleContent struct { - bInputDir string // The input directory containing the specific version of bundle data + bInputDir string // The directory that stores the specific version of bundle data bundleVersion string // The specific version of the bundle data imageRef string // Stores the bundle image reference } type CatalogDInfo struct { - baseFolderPath string // Base path of the folder for the catalogs - catalogDir string // The folder storing the FBC + baseFolderPath string // root path to the folder storing the catalogs + catalogDir string // The folder storing the FBC template operatorName string // Name of the operator to be installed from the bundles desiredChannelName string // Desired channel name for the operator - imageRef string // Stores the FBC image reference - fbcFileName string // Name of the FBC file + imageRef string // Stores the catalog image reference + fbcFileName string // Name of the FBC template file } type OperatorActionInfo struct { @@ -65,7 +65,7 @@ type OperatorActionInfo struct { } type SdkProjectInfo struct { - projectName string + projectName string // The operator-sdk project name domainName string group string version string @@ -105,7 +105,7 @@ var _ = BeforeSuite(func() { ctx = context.Background() - containerRuntime = os.Getenv("CONTAINER_RUNTIME") + containerRuntime = os.Getenv("CONTAINER_RUNTIME") // This environment variable is set in the Makefile if containerRuntime == "" { containerRuntime = "docker" } @@ -172,8 +172,8 @@ var _ = Describe("Operator Framework E2E for plain+v0 bundles", func() { Expect(err).ToNot(HaveOccurred()) By("generating bundle directory using kustomize") - // Creates bundle structure for the specified bundle versions - // Bundle content is same for the bundles now + // Creates bundle structure for the given bundle versions + // Bundle content is same for the different versions of bundle now for _, b := range bundleInfo.bundles { err = kustomizeGenPlainBundleDirectory(sdkInfo, bundleInfo.baseFolderPath, b) Expect(err).ToNot(HaveOccurred()) @@ -192,7 +192,7 @@ var _ = Describe("Operator Framework E2E for plain+v0 bundles", func() { for _, b := range bundleInfo.bundles { imageRefsBundleVersions[b.imageRef] = b.bundleVersion } - err = genPlainCatalogDirectory(catalogDInfo, imageRefsBundleVersions) + err = genPlainCatalogDirectory(catalogDInfo, imageRefsBundleVersions) // the bundle image references and their respective versions are passed Expect(err).ToNot(HaveOccurred()) By("building/pushing/kind loading the catalog images") @@ -210,16 +210,15 @@ var _ = Describe("Operator Framework E2E for plain+v0 bundles", func() { Expect(err).ToNot(HaveOccurred()) By("creating an operator CR and verifying the operator operations") - nameSpace := sdkInfo.projectName + "-system" + namespace := fmt.Sprintf("%s-system", sdkInfo.projectName) operator, err = createOperator(ctx, catalogDInfo.operatorName, operatorAction.installVersion) Expect(err).ToNot(HaveOccurred()) - checkOperatorOperationsSuccess(operator, catalogDInfo.operatorName, operatorAction.installVersion, bundleInfo.baseFolderPath, nameSpace) + checkOperatorOperationsSuccess(operator, catalogDInfo.operatorName, operatorAction.installVersion, bundleInfo.baseFolderPath, namespace) By("upgrading an operator and verifying the operator operations") - nameSpace = sdkInfo.projectName + "-system" operator, err = upgradeOperator(ctx, catalogDInfo.operatorName, operatorAction.upgradeVersion) Expect(err).ToNot(HaveOccurred()) - checkOperatorOperationsSuccess(operator, catalogDInfo.operatorName, operatorAction.upgradeVersion, bundleInfo.baseFolderPath, nameSpace) + checkOperatorOperationsSuccess(operator, catalogDInfo.operatorName, operatorAction.upgradeVersion, bundleInfo.baseFolderPath, namespace) By("deleting the operator CR and verifying the operator doesn't exist after deletion") err = deleteOperator(ctx, catalogDInfo.operatorName) @@ -241,7 +240,7 @@ var _ = Describe("Operator Framework E2E for plain+v0 bundles", func() { // Clearing up data generated for the test var toDelete []string for _, b := range bundleInfo.bundles { - toDelete = append(toDelete, bundleInfo.baseFolderPath+"/"+b.bInputDir) // delete the registry+v1 bundles formed + toDelete = append(toDelete, filepath.Join(bundleInfo.baseFolderPath, b.bInputDir)) // delete the registry+v1 bundles formed } toDelete = append(toDelete, sdkInfo.projectName) //delete the sdk project directory toDelete = append(toDelete, filepath.Join(catalogDInfo.baseFolderPath, catalogDInfo.catalogDir)) // delete the FBC formed @@ -304,7 +303,7 @@ var _ = Describe("Operator Framework E2E for registry+v1 bundles", func() { err = sdkInitialize(sdkInfo) Expect(err).ToNot(HaveOccurred()) - By("creating a new api and controller") + By("creating new api and controller") err = sdkNewAPIAndController(sdkInfo) Expect(err).ToNot(HaveOccurred()) @@ -375,10 +374,10 @@ var _ = Describe("Operator Framework E2E for registry+v1 bundles", func() { AfterEach(func() { var toDelete []string for _, b := range bundleInfo.bundles { - toDelete = append(toDelete, bundleInfo.baseFolderPath+"/"+b.bInputDir) // delete the registry+v1 bundles formed + toDelete = append(toDelete, filepath.Join(bundleInfo.baseFolderPath, b.bInputDir)) // delete the registry+v1 bundles formed } toDelete = append(toDelete, sdkInfo.projectName) //delete the sdk project directory - toDelete = append(toDelete, semverTemplateFileName) // delete the semver yaml formed + toDelete = append(toDelete, semverTemplateFileName) // delete the semver template formed toDelete = append(toDelete, filepath.Join(catalogDInfo.baseFolderPath, catalogDInfo.catalogDir)) // delete the FBC formed toDelete = append(toDelete, filepath.Join(catalogDInfo.baseFolderPath, fmt.Sprintf("%s.Dockerfile", catalogDInfo.catalogDir))) // delete the catalog Dockerfile generated err = deleteFolderFile(toDelete) @@ -386,7 +385,8 @@ var _ = Describe("Operator Framework E2E for registry+v1 bundles", func() { }) }) -// Creates new operator-sdk project with the name sdkInfo.projectName +// Creates a new operator-sdk project with the name sdkInfo.projectName. +// A project folder is created with the name sdkInfo.projectName and operator-sdk is initialized. func sdkInitialize(sdkInfo *SdkProjectInfo) error { if err := os.Mkdir(sdkInfo.projectName, 0755); err != nil { return fmt.Errorf("Error creating the sdk project %v:%v", sdkInfo.projectName, err) @@ -418,11 +418,11 @@ func sdkNewAPIAndController(sdkInfo *SdkProjectInfo) error { } // Checking if the API was created in the expected path - apiFilePath := filepath.Join(sdkInfo.projectName, "api", sdkInfo.version, strings.ToLower(sdkInfo.kind)+"_types.go") + apiFilePath := filepath.Join(sdkInfo.projectName, "api", sdkInfo.version, fmt.Sprintf("%s_types.go", strings.ToLower(sdkInfo.kind))) Expect(apiFilePath).To(BeAnExistingFile()) // Checking if the controller was created in the expected path") - controllerFilePath := filepath.Join(sdkInfo.projectName, "controllers", strings.ToLower(sdkInfo.kind)+"_controller.go") + controllerFilePath := filepath.Join(sdkInfo.projectName, "controllers", fmt.Sprintf("%s_controller.go", strings.ToLower(sdkInfo.kind))) Expect(controllerFilePath).To(BeAnExistingFile()) return nil @@ -445,8 +445,8 @@ func sdkGenerateManifests(sdkInfo *SdkProjectInfo) error { return fmt.Errorf("Error generating and updating crd manifests for the operator-sdk project %v:%v", sdkInfo.projectName, err) } - // Checking if CRD manifests are generated - crdFilePath := filepath.Join(sdkInfo.projectName, "config", "crd", "bases", sdkInfo.group+"."+sdkInfo.domainName+"_"+strings.ToLower(sdkInfo.kind)+"s.yaml") + // Checking if CRD manifests are generated in the expected path + crdFilePath := filepath.Join(sdkInfo.projectName, "config", "crd", "bases", fmt.Sprintf("%s.%s_%ss.yaml", sdkInfo.group, sdkInfo.domainName, strings.ToLower(sdkInfo.kind))) Expect(crdFilePath).To(BeAnExistingFile()) return nil @@ -491,7 +491,7 @@ func kustomizeGenPlainBundleDirectory(sdkInfo *SdkProjectInfo, rootBundlePath st return fmt.Errorf("Error generating plain bundle directory %v: %v", string(output), err) } - // Create bundle dockerfile + // Creates bundle dockerfile dockerFilePath := filepath.Join(rootBundlePath, bundleData.bInputDir, "plainbundle.Dockerfile") if err = generateBundleDockerFile(dockerFilePath, bundleData.bInputDir); err != nil { return fmt.Errorf("Error generating bundle dockerfile for the bundle %v: %v", bundleData.bInputDir, err) @@ -599,7 +599,7 @@ func loadImages(w io.Writer, kindServerName string, images ...string) error { return nil } -// Generates catalog directory contents for the plain bundle format. The FBC(yaml file) and the Dockerfile +// Generates catalog directory contents for the plain bundle format. The FBC template and the Dockerfile // is formed using custom routines func genPlainCatalogDirectory(catalogDInfo *CatalogDInfo, imageRefsBundleVersions map[string]string) error { // forming the FBC using custom routine @@ -687,7 +687,7 @@ func validateFBC(fbcDirPath string) error { return nil } -// Creates catalog instance +// Creates catalog CR func createTestCatalog(ctx context.Context, name, imageRef string) (*catalogd.Catalog, error) { catalog := &catalogd.Catalog{ ObjectMeta: metav1.ObjectMeta{ @@ -707,7 +707,7 @@ func createTestCatalog(ctx context.Context, name, imageRef string) (*catalogd.Ca return catalog, err } -// Creates the operator opName for the version +// Creates the operator for opName for the version func createOperator(ctx context.Context, opName, version string) (*operatorv1alpha1.Operator, error) { operator := &operatorv1alpha1.Operator{ ObjectMeta: metav1.ObjectMeta{ @@ -742,7 +742,7 @@ func upgradeOperator(ctx context.Context, opName, version string) (*operatorv1al return operator, err } -// Deletes the operator opName +// Deletes the operator CR with the name opName func deleteOperator(ctx context.Context, opName string) error { operator := &operatorv1alpha1.Operator{} if err := c.Get(ctx, types.NamespacedName{Name: opName}, operator); err != nil { @@ -753,13 +753,14 @@ func deleteOperator(ctx context.Context, opName string) error { return err } -// Checks if the operator was successfully deleted and returns error if not. +// Checks if the operator was successfully deleted by trying to reteive the operator with the name opName. +// Error in retrieving indicates a successful deletion. func validateOperatorDeletion(opName string) error { err := c.Get(ctx, types.NamespacedName{Name: opName}, &operatorv1alpha1.Operator{}) return err } -// Deletes the catalog instance. +// Deletes the catalog CR. func deleteCatalog(catalog *catalogd.Catalog) error { if err := c.Delete(ctx, catalog); err != nil { return fmt.Errorf("Error deleting the catalog instance: %v", err) @@ -767,7 +768,8 @@ func deleteCatalog(catalog *catalogd.Catalog) error { return nil } -// Checks if the catalog was successfully deleted and returns error if not. +// Checks if the catalog was successfully deleted by trying to reteive the catalog. +// Error in retrieving indicates a successful deletion. func validateCatalogDeletion(catalog *catalogd.Catalog) error { err := c.Get(ctx, types.NamespacedName{Name: catalog.Name}, &catalogd.Catalog{}) return err @@ -809,7 +811,7 @@ func validateCatalogUnpacking(operatorCatalog *catalogd.Catalog) error { return nil } -// Creates catalog instance and check if catalog unpackging is successul and if the packages and bundle metadatas are formed +// Creates catalog CR and checks if catalog unpackging is successful and if the packages and bundle metadatas are formed func createCatalogCheckResources(operatorCatalog *catalogd.Catalog, catalogDInfo *CatalogDInfo, bundleVersions []string) (*catalogd.Catalog, error) { operatorCatalog, err := createTestCatalog(ctx, catalogDInfo.catalogDir, catalogDInfo.imageRef) if err != nil {