Skip to content

Commit 85f1a24

Browse files
committed
Modified adding opm and operator-sdk binary using bingo; Updated files to be consistent in styling
Signed-off-by: jubittajohn <[email protected]>
1 parent 6b7e5b9 commit 85f1a24

File tree

14 files changed

+2840
-250
lines changed

14 files changed

+2840
-250
lines changed

.bingo/Variables.mk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ $(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
5959
@echo "(re)installing $(GOBIN)/kustomize-v4.5.7"
6060
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v4.5.7 "sigs.k8s.io/kustomize/kustomize/v4"
6161

62+
OPERATOR_SDK := $(GOBIN)/operator-sdk-v1.31.0
63+
$(OPERATOR_SDK): $(BINGO_DIR)/operator-sdk.mod
64+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
65+
@echo "(re)installing $(GOBIN)/operator-sdk-v1.31.0"
66+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -ldflags=-X=github.com/operator-framework/operator-sdk/internal/version.Version=v1.31.0 -mod=mod -modfile=operator-sdk.mod -o=$(GOBIN)/operator-sdk-v1.31.0 "github.com/operator-framework/operator-sdk/cmd/operator-sdk"
67+
68+
OPM := $(GOBIN)/opm-v1.28.0
69+
$(OPM): $(BINGO_DIR)/opm.mod
70+
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
71+
@echo "(re)installing $(GOBIN)/opm-v1.28.0"
72+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=opm.mod -o=$(GOBIN)/opm-v1.28.0 "github.com/operator-framework/operator-registry/cmd/opm"
73+
6274
SETUP_ENVTEST := $(GOBIN)/setup-envtest-v0.0.0-20230606045100-e54088c8c7da
6375
$(SETUP_ENVTEST): $(BINGO_DIR)/setup-envtest.mod
6476
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.

.bingo/operator-sdk.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.20
4+
5+
replace github.com/containerd/containerd => github.com/containerd/containerd v1.4.11
6+
7+
replace github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
8+
9+
replace github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.10.0
10+
11+
require github.com/operator-framework/operator-sdk v1.31.0 // cmd/operator-sdk -ldflags=-X=github.com/operator-framework/operator-sdk/internal/version.Version=v1.31.0

.bingo/operator-sdk.sum

Lines changed: 1590 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/opm.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
2+
3+
go 1.20
4+
5+
replace github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d
6+
7+
require github.com/operator-framework/operator-registry v1.28.0 // cmd/opm

.bingo/opm.sum

Lines changed: 947 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,9 @@ KIND="${GOBIN}/kind-v0.15.0"
2222

2323
KUSTOMIZE="${GOBIN}/kustomize-v4.5.7"
2424

25+
OPERATOR_SDK="${GOBIN}/operator-sdk-v1.31.0"
26+
27+
OPM="${GOBIN}/opm-v1.28.0"
28+
2529
SETUP_ENVTEST="${GOBIN}/setup-envtest-v0.0.0-20230606045100-e54088c8c7da"
2630

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: operator-developer-e2e
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
operator-developer-e2e:
12+
runs-on: ubuntu-latest
13+
steps:
14+
15+
- uses: actions/checkout@v3
16+
17+
- uses: actions/setup-go@v4
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Run the operator framework e2e test
22+
run: |
23+
make operator-developer-e2e

Makefile

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,25 @@ E2E_FLAGS ?= ""
9999
test-e2e: $(GINKGO) ## Run the e2e tests
100100
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e
101101

102-
.PHONY: test-operator-developer-e2e
103-
test-operator-developer-e2e: $(GINKGO) ## Run operator create, upgrade and delete tests
104-
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress test/operator-framework-e2e
102+
.PHONY: test-op-dev-e2e
103+
test-op-dev-e2e: $(GINKGO) ## Run operator create, upgrade and delete tests
104+
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/operator-framework-e2e
105105

106106
.PHONY: test-unit
107107
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\)\.[[:digit:]]\{1,\}$$/1.\1.x/')
108108
UNIT_TEST_DIRS=$(shell go list ./... | grep -v /test/)
109109
test-unit: $(SETUP_ENVTEST) ## Run the unit tests
110110
eval $$($(SETUP_ENVTEST) use -p env $(ENVTEST_VERSION)) && go test -tags $(GO_BUILD_TAGS) -count=1 -short $(UNIT_TEST_DIRS) -coverprofile cover.out
111111

112-
.PHONY: test-operator-framework-e2e
113-
test-operator-framework-e2e: $(GINKGO) ## Run operator create, upgrade and delete tests
114-
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress test/operator-e2e
115-
116112
.PHONY: e2e
117113
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
118114
e2e: KUSTOMIZE_BUILD_DIR=config/e2e
119115
e2e: GO_BUILD_FLAGS=-cover
120116
e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ## Run e2e test suite on local kind cluster
121117

122-
operator-developer-e2e: KIND_CLUSTER_NAME=operator-controller-e2e ## Run operator-developer e2e on local kind cluster
123-
operator-developer-e2e: run opm install-operator-sdk deploy-local-registry test-operator-developer-e2e stop-local-registry kind-cluster-cleanup
118+
.PHONY: operator-developer-e2e
119+
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
124121

125122
.PHONY: e2e-coverage
126123
e2e-coverage:
@@ -152,42 +149,26 @@ kind-load-test-artifacts: $(KIND) ## Load the e2e testdata container images into
152149
$(KIND) load docker-image localhost/testdata/bundles/plain-v0/plain:v0.1.0 --name $(KIND_CLUSTER_NAME)
153150
$(KIND) load docker-image localhost/testdata/catalogs/test-catalog:e2e --name $(KIND_CLUSTER_NAME)
154151

155-
.PHONY: opm
156-
OPM = ./bin/opm
157-
OPM_VERSION = v1.28.0
158-
opm: ## Download opm locally if necessary.
159-
ifeq (,$(wildcard $(OPM)))
160-
ifeq (,$(shell which opm 2>/dev/null))
161-
@{ \
162-
set -e ;\
163-
mkdir -p $(dir $(OPM)) ;\
164-
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
165-
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\
166-
chmod +x $(OPM) ;\
167-
}
168-
else
169-
OPM = $(shell which opm)
170-
endif
171-
endif
172-
173-
.PHONY: install-operator-sdk
174-
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.30.0
175-
export OS=$(shell go env GOOS)
176-
export ARCH=$(shell go env GOARCH)
177-
install-operator-sdk: ## Install operator-sdk
178-
if [ ! -f ~/bin/operator-sdk ]; then \
179-
curl -LO $(OPERATOR_SDK_DL_URL)/operator-sdk_${OS}_${ARCH} ; \
180-
chmod +x operator-sdk_${OS}_${ARCH} ; \
181-
mv operator-sdk_$(OS)_$(ARCH) /usr/local/bin/operator-sdk ; \
182-
fi
183-
184152
.PHONY: deploy-local-registry
185153
deploy-local-registry: ## Deploy local docker registry
186-
docker run -d -p 5000:5000 --restart=always --name local-registry registry:2
154+
$(CONTAINER_RUNTIME) run -d -p 5000:5000 --restart=always --name local-registry registry:2
187155

188156
.PHONY: stop-local-registry
189-
stop-local-registry: ## Stop and remove local registry
190-
docker container stop local-registry && docker container rm -v local-registry
157+
stop-local-registry: ## Stop local registry
158+
$(CONTAINER_RUNTIME) container stop local-registry
159+
160+
.PHONY: remove-local-registry
161+
remove-local-registry: ## Remove local registry
162+
$(CONTAINER_RUNTIME) container rm -v local-registry
163+
164+
.PHONY: setup-op-dev-e2e
165+
setup-op-dev-e2e: $(OPM) $(OPERATOR_SDK)
166+
167+
opm: $(OPM)
168+
$(OPM) $(OPM_ARGS)
169+
170+
operator-sdk: $(OPERATOR_SDK)
171+
(cd $(OPERATOR_SDK_PROJECT_PATH) && $(OPERATOR_SDK) $(OPERATOR_SDK_ARGS))
191172

192173
##@ Build
193174

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ require (
8282
github.com/josharian/intern v1.0.0 // indirect
8383
github.com/json-iterator/go v1.1.12 // indirect
8484
github.com/klauspost/compress v1.12.3 // indirect
85+
github.com/kr/pretty v0.3.1 // indirect
8586
github.com/mailru/easyjson v0.7.6 // indirect
8687
github.com/mattn/go-sqlite3 v1.14.10 // indirect
8788
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
@@ -103,6 +104,7 @@ require (
103104
github.com/prometheus/client_model v0.3.0 // indirect
104105
github.com/prometheus/common v0.37.0 // indirect
105106
github.com/prometheus/procfs v0.8.0 // indirect
107+
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 // indirect
106108
github.com/sirupsen/logrus v1.9.0 // indirect
107109
github.com/stoewer/go-strcase v1.2.0 // indirect
108110
go.etcd.io/bbolt v1.3.6 // indirect
@@ -118,12 +120,13 @@ require (
118120
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
119121
go.uber.org/multierr v1.10.0 // indirect
120122
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
121-
golang.org/x/net v0.12.0 // indirect
123+
golang.org/x/mod v0.12.0 // indirect
124+
golang.org/x/net v0.10.0 // indirect
122125
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
123-
golang.org/x/sync v0.2.0 // indirect
126+
golang.org/x/sync v0.3.0 // indirect
124127
golang.org/x/sys v0.10.0 // indirect
125128
golang.org/x/term v0.10.0 // indirect
126-
golang.org/x/text v0.11.0 // indirect
129+
golang.org/x/text v0.9.0 // indirect
127130
golang.org/x/time v0.3.0 // indirect
128131
golang.org/x/tools v0.9.3 // indirect
129132
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect

go.sum

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv
632632
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
633633
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
634634
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
635-
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
636635
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
636+
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
637+
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
637638
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
638639
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
639640
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -777,6 +778,7 @@ github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrap
777778
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
778779
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
779780
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
781+
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
780782
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
781783
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
782784
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -835,6 +837,9 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
835837
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
836838
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
837839
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
840+
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
841+
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY=
842+
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
838843
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
839844
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
840845
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
@@ -1033,7 +1038,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10331038
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10341039
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
10351040
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
1036-
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
1041+
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
1042+
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
10371043
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
10381044
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
10391045
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1112,8 +1118,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
11121118
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
11131119
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
11141120
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1115-
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
1116-
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1121+
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
1122+
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
11171123
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
11181124
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
11191125
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -1204,8 +1210,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
12041210
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12051211
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12061212
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1207-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
1208-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1213+
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
1214+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12091215
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
12101216
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
12111217
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=

test/operator-framework-e2e/create_fbc_helper.go

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"fmt"
77
"os"
8+
"path/filepath"
89
"strings"
910

1011
"github.com/operator-framework/operator-registry/alpha/declcfg"
@@ -20,10 +21,15 @@ const (
2021
)
2122

2223
// Forms the FBC declartive config and creates the FBC by calling functions for forming the package, channel and bundles.
23-
func CreateFBC(operatorName, defaultChannel string, bundleRef, bundleVersions []string) *declcfg.DeclarativeConfig {
24+
func CreateFBC(operatorName, defaultChannel string, bundleRefsVersions map[string]string) *declcfg.DeclarativeConfig {
2425
dPackage := formPackage(operatorName)
26+
bundleVersions := make([]string, 0)
27+
for _, bundleVersion := range bundleRefsVersions {
28+
bundleVersions = append(bundleVersions, bundleVersion)
29+
}
2530
dChannel := formChannel(operatorName, defaultChannel, bundleVersions)
26-
dBundle := formBundle(operatorName, bundleVersions, bundleRef)
31+
32+
dBundle := formBundle(operatorName, bundleRefsVersions)
2733

2834
fbc := declcfg.DeclarativeConfig{
2935
Packages: []declcfg.Package{dPackage},
@@ -72,13 +78,13 @@ func formChannelEntries(pkgName string, bundleVersions []string) []declcfg.Chann
7278
}
7379

7480
// Forms bundle schema for the FBC
75-
func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
76-
bundleFormed := make([]declcfg.Bundle, 0, len(imageRefs))
77-
for i := 0; i < len(imageRefs); i++ {
81+
func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bundle {
82+
bundleFormed := make([]declcfg.Bundle, 0, len(imgRefsVersions))
83+
for imgRef, version := range imgRefsVersions {
7884
var properties []property.Property
7985
properties = append(properties, property.Property{
8086
Type: SchemaPackage,
81-
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, versions[i])),
87+
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, version)),
8288
})
8389
properties = append(properties, property.Property{
8490
Type: SchemaBundleMediatype,
@@ -87,9 +93,9 @@ func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
8793

8894
bundleFormed = append(bundleFormed, declcfg.Bundle{
8995
Schema: SchemaBundle,
90-
Name: pkgName + ".v" + versions[i],
96+
Name: pkgName + ".v" + version,
9197
Package: pkgName,
92-
Image: imageRefs[i],
98+
Image: imgRef,
9399
Properties: properties,
94100
})
95101
}
@@ -99,30 +105,24 @@ func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
99105
// Writes the formed FBC into catalog.yaml file
100106
func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) error {
101107
var buf bytes.Buffer
102-
err := declcfg.WriteYAML(fbc, &buf)
103-
if err != nil {
108+
if err := declcfg.WriteYAML(fbc, &buf); err != nil {
104109
return err
105110
}
106111

107-
_, err = os.Stat(fbcFilePath)
108-
if os.IsNotExist(err) {
109-
err := os.MkdirAll(fbcFilePath, 0755)
110-
if err != nil {
112+
if _, err := os.Stat(fbcFilePath); os.IsNotExist(err) {
113+
if err := os.MkdirAll(fbcFilePath, 0755); err != nil {
111114
return err
112115
}
113116
}
114-
file, err := os.Create(fbcFilePath + "/" + fbcFileName)
115-
if err != nil {
116-
return err
117-
}
118-
defer file.Close()
119117

120-
err = os.WriteFile(fbcFilePath+"/"+fbcFileName, buf.Bytes(), 0600)
118+
file, err := os.Create(filepath.Join(fbcFilePath, fbcFileName))
121119
if err != nil {
122120
return err
123121
}
122+
defer file.Close()
124123

125-
return nil
124+
err = os.WriteFile(filepath.Join(fbcFilePath, fbcFileName), buf.Bytes(), 0600)
125+
return err
126126
}
127127

128128
// Generates the semver using the bundle images passed
@@ -146,8 +146,7 @@ stable:
146146
}
147147
defer file.Close()
148148

149-
_, err = file.WriteString(fileContent)
150-
if err != nil {
149+
if _, err = file.WriteString(fileContent); err != nil {
151150
return fmt.Errorf("error forming the semver yaml file %v : %v", semverFileName, err)
152151
}
153152

test/operator-framework-e2e/generate_dockerfile.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ func generateDockerFile(dockerFilePath, yamlFolderName, dockerFileName string) e
2020
}
2121
defer file.Close()
2222

23-
_, err = file.WriteString("FROM scratch\n")
24-
if err != nil {
25-
return err
26-
}
27-
err = t.Execute(file, struct{ YamlDir string }{yamlFolderName})
28-
if err != nil {
23+
if _, err = file.WriteString("FROM scratch\n"); err != nil {
2924
return err
3025
}
3126

32-
return nil
27+
err = t.Execute(file, struct{ YamlDir string }{yamlFolderName})
28+
return err
3329
}
3430

35-
const dockerfileTmpl = `ADD {{.YamlDir}} /configs/{{.YamlDir}}
36-
`
31+
const dockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"

0 commit comments

Comments
 (0)