Skip to content

Commit

Permalink
Updated to generate plain manifests from an SDK project with kustomiz…
Browse files Browse the repository at this point in the history
…e;Restructed code to have a single It block in a describe block

Signed-off-by: jubittajohn <jujohn@redhat.com>
  • Loading branch information
jubittajohn committed Aug 9, 2023
1 parent b6e8d9b commit f3fce19
Show file tree
Hide file tree
Showing 11 changed files with 417 additions and 333 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ##

.PHONY: operator-developer-e2e
operator-developer-e2e: KIND_CLUSTER_NAME=operator-controller-op-dev-e2e ## Run operator-developer e2e on local kind cluster
operator-developer-e2e: run setup-op-dev-e2e deploy-local-registry test-op-dev-e2e stop-local-registry remove-local-registry kind-cluster-cleanup
operator-developer-e2e: run $(OPM) $(OPERATOR_SDK) $(KUSTOMIZE) deploy-local-registry test-op-dev-e2e stop-local-registry remove-local-registry kind-cluster-cleanup

.PHONY: e2e-coverage
e2e-coverage:
Expand Down Expand Up @@ -151,7 +151,7 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into

.PHONY: deploy-local-registry
deploy-local-registry: ## Deploy local docker registry
$(CONTAINER_RUNTIME) run -d -p 5000:5000 --restart=always --name local-registry registry:2
$(CONTAINER_RUNTIME) run -d -p 5001:5000 --restart=always --name local-registry registry:2

.PHONY: stop-local-registry
stop-local-registry: ## Stop local registry
Expand All @@ -161,15 +161,15 @@ stop-local-registry: ## Stop local registry
remove-local-registry: ## Remove local registry
$(CONTAINER_RUNTIME) container rm -v local-registry

.PHONY: setup-op-dev-e2e
setup-op-dev-e2e: $(OPM) $(OPERATOR_SDK)

opm: $(OPM)
$(OPM) $(OPM_ARGS)

operator-sdk: $(OPERATOR_SDK)
(cd $(OPERATOR_SDK_PROJECT_PATH) && $(OPERATOR_SDK) $(OPERATOR_SDK_ARGS))

kustomize: $(KUSTOMIZE)
(cd $(OPERATOR_SDK_PROJECT_PATH) && $(KUSTOMIZE) $(KUSTOMIZE_ARGS))

##@ Build

export VERSION ?= $(shell git describe --tags --always --dirty)
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ go 1.20
require (
github.com/blang/semver/v4 v4.0.0
github.com/go-logr/logr v1.2.4
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.10
github.com/onsi/ginkgo/v2 v2.9.7
github.com/onsi/gomega v1.27.7
github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42
github.com/operator-framework/catalogd v0.4.1
github.com/operator-framework/deppy v0.0.0-20230629133131-bb7b6ae7b266
github.com/operator-framework/operator-registry v1.27.1
github.com/operator-framework/rukpak v0.13.0
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.25.0
github.com/stretchr/testify v1.8.1
go.uber.org/zap v1.24.0
k8s.io/apiextensions-apiserver v0.26.1
k8s.io/apimachinery v0.26.1
k8s.io/client-go v0.26.1
k8s.io/component-base v0.26.1
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
sigs.k8s.io/controller-runtime v0.14.4
sigs.k8s.io/yaml v1.3.0
)

require (
Expand Down Expand Up @@ -96,7 +97,6 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42 // indirect
github.com/otiai10/copy v1.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down Expand Up @@ -139,12 +139,12 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.26.1 // indirect
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.1 // indirect
k8s.io/klog/v2 v2.80.1 // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
13 changes: 13 additions & 0 deletions test/operator-framework-e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ This is a cross-component demo with all OLM v1 repositories. The ginkgo test doe
- Uses operator-sdk to build `registry+v1` bundles and create catalogs to include the bundles.
- Installs, upgrades and deletes a `registry+v1` operator.

1. start with an empty directory
2. call operator-sdk to initialize and generate an operator
3. generate a bundle directory
4. build/push/kind load bundle images from the bundle directories
5. repeat steps 2-4 as necessary to get bundles for multiple operator versions
6. generate a catalog directory
7. build/push/kind load the catalog
8. create a Catalog CR (with kubectl operator)
9. create an Operator CR (with kubectl operator)
10. trigger Operator upgrades (with kubectl operator)
11. delete the Operator CR (with kubectl operator)
12. delete the Catalog CR (with kubectl operator)
13. repeat steps 2-12 for each bundle format (e.g. registry+v1 and plain+v0)
## Objective
- Development on OLM v1 is split across multiple repositories, and the list of relevant repositories may grow over time. While we have demos showing improvements in functionality of components over time, it can be difficult to have a picture of the state of OLM v1 at any given time for someone not following its development closely. Having a single source to look for OLM v1 behavior can provide more clarity about the state of the project.
- 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.
Expand Down
4 changes: 2 additions & 2 deletions test/operator-framework-e2e/create_fbc_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) er
return err
}

// Generates the semver using the bundle images passed
func generateOLMSemverFile(semverFileName string, bundleImages []string) error {
// Forms the semver using the bundle images passed
func formOLMSemverFile(semverFileName string, bundleImages []string) error {
images := make([]string, 0, len(bundleImages))
for _, bundleImage := range bundleImages {
images = append(images, fmt.Sprintf(" - image: %s", bundleImage))
Expand Down
20 changes: 15 additions & 5 deletions test/operator-framework-e2e/generate_dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ package operatore2e

import (
"os"
"path/filepath"
"text/template"
)

// generates Dockerfile and its contents for a given set of yaml files
func generateDockerFile(dockerFilePath, yamlFolderName, dockerFileName string) error {
// GenerateDockerFile generates Dockerfile and its contents for a given set of yaml files
func generateDockerFile(dockerFilePath, yamlFolderName, dockerfileTmpl string) error {
t, err := template.New("dockerfile").Parse(dockerfileTmpl)
if err != nil {
panic(err)
}

dockerFilePath = filepath.Join(dockerFilePath, dockerFileName)
file, err := os.Create(dockerFilePath)
if err != nil {
return err
Expand All @@ -28,4 +26,16 @@ func generateDockerFile(dockerFilePath, yamlFolderName, dockerFileName string) e
return err
}

const dockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"
// GenerateCatalogDockerFile generates Dockerfile for the catalog
func generateCatalogDockerFile(dockerFilePath, yamlFolderName string) error {
return generateDockerFile(dockerFilePath, yamlFolderName, catalogDockerfileTmpl)
}

// GenerateBundleDockerFile generates Dockerfile for the bundle
func generateBundleDockerFile(dockerFilePath, yamlFolderName string) error {
return generateDockerFile(dockerFilePath, yamlFolderName, bundleDockerfileTmpl)
}

// Dockerfile templates
const catalogDockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"
const bundleDockerfileTmpl = "ADD manifests /manifests\n"
Loading

0 comments on commit f3fce19

Please sign in to comment.