Skip to content

Commit bba9a01

Browse files
committed
Updated to generate plain manifests from an SDK project with kustomize;Restructed code to have a single It block in a describe block
Signed-off-by: jubittajohn <[email protected]>
1 parent 87fa9b5 commit bba9a01

File tree

11 files changed

+413
-329
lines changed

11 files changed

+413
-329
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ##
117117

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

122122
.PHONY: e2e-coverage
123123
e2e-coverage:
@@ -147,7 +147,7 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into
147147

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

152152
.PHONY: stop-local-registry
153153
stop-local-registry: ## Stop local registry
@@ -157,15 +157,15 @@ stop-local-registry: ## Stop local registry
157157
remove-local-registry: ## Remove local registry
158158
$(CONTAINER_RUNTIME) container rm -v local-registry
159159

160-
.PHONY: setup-op-dev-e2e
161-
setup-op-dev-e2e: $(OPM) $(OPERATOR_SDK)
162-
163160
opm: $(OPM)
164161
$(OPM) $(OPM_ARGS)
165162

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

166+
kustomize: $(KUSTOMIZE)
167+
(cd $(OPERATOR_SDK_PROJECT_PATH) && $(KUSTOMIZE) $(KUSTOMIZE_ARGS))
168+
169169
##@ Build
170170

171171
export VERSION ?= $(shell git describe --tags --always --dirty)

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ require (
77
github.com/go-logr/logr v1.2.4
88
github.com/onsi/ginkgo/v2 v2.9.7
99
github.com/onsi/gomega v1.27.7
10+
github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42
1011
github.com/operator-framework/catalogd v0.4.1
1112
github.com/operator-framework/deppy v0.0.0-20230629133131-bb7b6ae7b266
1213
github.com/operator-framework/operator-registry v1.27.1
1314
github.com/operator-framework/rukpak v0.13.0
1415
github.com/spf13/pflag v1.0.5
1516
github.com/stretchr/testify v1.8.1
1617
go.uber.org/zap v1.24.0
18+
k8s.io/apiextensions-apiserver v0.26.1
1719
k8s.io/apimachinery v0.26.1
1820
k8s.io/client-go v0.26.1
1921
k8s.io/component-base v0.26.1
2022
k8s.io/utils v0.0.0-20221128185143-99ec85e7a448
2123
sigs.k8s.io/controller-runtime v0.14.4
22-
sigs.k8s.io/yaml v1.3.0
2324
)
2425

2526
require (
@@ -96,7 +97,6 @@ require (
9697
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
9798
github.com/opencontainers/go-digest v1.0.0 // indirect
9899
github.com/opencontainers/image-spec v1.1.0-rc2 // indirect
99-
github.com/operator-framework/api v0.17.4-0.20230223191600-0131a6301e42 // indirect
100100
github.com/otiai10/copy v1.2.0 // indirect
101101
github.com/pkg/errors v0.9.1 // indirect
102102
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -140,12 +140,12 @@ require (
140140
gopkg.in/yaml.v2 v2.4.0 // indirect
141141
gopkg.in/yaml.v3 v3.0.1 // indirect
142142
k8s.io/api v0.26.1 // indirect
143-
k8s.io/apiextensions-apiserver v0.26.1 // indirect
144143
k8s.io/apiserver v0.26.1 // indirect
145144
k8s.io/klog/v2 v2.80.1 // indirect
146145
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
147146
rsc.io/letsencrypt v0.0.3 // indirect
148147
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.35 // indirect
149148
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
150149
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
150+
sigs.k8s.io/yaml v1.3.0 // indirect
151151
)

test/operator-framework-e2e/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ This is a cross-component demo with all OLM v1 repositories. The ginkgo test doe
66
- Uses operator-sdk to build `registry+v1` bundles and create catalogs to include the bundles.
77
- Installs, upgrades and deletes a `registry+v1` operator.
88

9+
1. start with an empty directory
10+
2. call operator-sdk to initialize and generate an operator
11+
3. generate a bundle directory
12+
4. build/push/kind load bundle images from the bundle directories
13+
5. repeat steps 2-4 as necessary to get bundles for multiple operator versions
14+
6. generate a catalog directory
15+
7. build/push/kind load the catalog
16+
8. create a Catalog CR (with kubectl operator)
17+
9. create an Operator CR (with kubectl operator)
18+
10. trigger Operator upgrades (with kubectl operator)
19+
11. delete the Operator CR (with kubectl operator)
20+
12. delete the Catalog CR (with kubectl operator)
21+
13. repeat steps 2-12 for each bundle format (e.g. registry+v1 and plain+v0)
922
## Objective
1023
- 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.
1124
- 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.

test/operator-framework-e2e/create_fbc_helper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) er
125125
return err
126126
}
127127

128-
// Generates the semver using the bundle images passed
129-
func generateOLMSemverFile(semverFileName string, bundleImages []string) error {
128+
// Forms the semver using the bundle images passed
129+
func formOLMSemverFile(semverFileName string, bundleImages []string) error {
130130
images := make([]string, 0, len(bundleImages))
131131
for _, bundleImage := range bundleImages {
132132
images = append(images, fmt.Sprintf(" - image: %s", bundleImage))

test/operator-framework-e2e/generate_dockerfile.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ package operatore2e
22

33
import (
44
"os"
5-
"path/filepath"
65
"text/template"
76
)
87

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

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

31-
const dockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"
29+
// GenerateCatalogDockerFile generates Dockerfile for the catalog
30+
func generateCatalogDockerFile(dockerFilePath, yamlFolderName string) error {
31+
return generateDockerFile(dockerFilePath, yamlFolderName, catalogDockerfileTmpl)
32+
}
33+
34+
// GenerateBundleDockerFile generates Dockerfile for the bundle
35+
func generateBundleDockerFile(dockerFilePath, yamlFolderName string) error {
36+
return generateDockerFile(dockerFilePath, yamlFolderName, bundleDockerfileTmpl)
37+
}
38+
39+
// Dockerfile templates
40+
const catalogDockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"
41+
const bundleDockerfileTmpl = "ADD manifests /manifests\n"

0 commit comments

Comments
 (0)