Skip to content

Commit

Permalink
Modified adding opm and operator-sdk binary using bingo; Updated file…
Browse files Browse the repository at this point in the history
…s to be consistent in styling

Signed-off-by: jubittajohn <jujohn@redhat.com>
  • Loading branch information
jubittajohn committed Aug 9, 2023
1 parent a3a1b8c commit b6e8d9b
Show file tree
Hide file tree
Showing 14 changed files with 2,840 additions and 250 deletions.
12 changes: 12 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,18 @@ $(KUSTOMIZE): $(BINGO_DIR)/kustomize.mod
@echo "(re)installing $(GOBIN)/kustomize-v4.5.7"
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=kustomize.mod -o=$(GOBIN)/kustomize-v4.5.7 "sigs.k8s.io/kustomize/kustomize/v4"

OPERATOR_SDK := $(GOBIN)/operator-sdk-v1.31.0
$(OPERATOR_SDK): $(BINGO_DIR)/operator-sdk.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/operator-sdk-v1.31.0"
@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"

OPM := $(GOBIN)/opm-v1.28.0
$(OPM): $(BINGO_DIR)/opm.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/opm-v1.28.0"
@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"

SETUP_ENVTEST := $(GOBIN)/setup-envtest-v0.0.0-20230606045100-e54088c8c7da
$(SETUP_ENVTEST): $(BINGO_DIR)/setup-envtest.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
Expand Down
11 changes: 11 additions & 0 deletions .bingo/operator-sdk.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.20

replace github.com/containerd/containerd => github.com/containerd/containerd v1.4.11

replace github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d

replace github.com/mattn/go-sqlite3 => github.com/mattn/go-sqlite3 v1.10.0

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
1,590 changes: 1,590 additions & 0 deletions .bingo/operator-sdk.sum

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .bingo/opm.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.20

replace github.com/docker/distribution => github.com/docker/distribution v0.0.0-20191216044856-a8371794149d

require github.com/operator-framework/operator-registry v1.28.0 // cmd/opm
947 changes: 947 additions & 0 deletions .bingo/opm.sum

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@ KIND="${GOBIN}/kind-v0.15.0"

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

OPERATOR_SDK="${GOBIN}/operator-sdk-v1.31.0"

OPM="${GOBIN}/opm-v1.28.0"

SETUP_ENVTEST="${GOBIN}/setup-envtest-v0.0.0-20230606045100-e54088c8c7da"

23 changes: 23 additions & 0 deletions .github/workflows/operator-developer-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: operator-developer-e2e

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
operator-developer-e2e:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: Run the operator framework e2e test
run: |
make operator-developer-e2e
63 changes: 22 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,25 @@ E2E_FLAGS ?= ""
test-e2e: $(GINKGO) ## Run the e2e tests
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e

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

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

.PHONY: test-operator-framework-e2e
test-operator-framework-e2e: $(GINKGO) ## Run operator create, upgrade and delete tests
$(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress test/operator-e2e

.PHONY: e2e
e2e: KIND_CLUSTER_NAME=operator-controller-e2e
e2e: KUSTOMIZE_BUILD_DIR=config/e2e
e2e: GO_BUILD_FLAGS=-cover
e2e: run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup ## Run e2e test suite on local kind cluster

operator-developer-e2e: KIND_CLUSTER_NAME=operator-controller-e2e ## Run operator-developer e2e on local kind cluster
operator-developer-e2e: run opm install-operator-sdk deploy-local-registry test-operator-developer-e2e stop-local-registry 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

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

.PHONY: opm
OPM = ./bin/opm
OPM_VERSION = v1.28.0
opm: ## Download opm locally if necessary.
ifeq (,$(wildcard $(OPM)))
ifeq (,$(shell which opm 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(OPM)) ;\
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/$(OPM_VERSION)/$${OS}-$${ARCH}-opm ;\
chmod +x $(OPM) ;\
}
else
OPM = $(shell which opm)
endif
endif

.PHONY: install-operator-sdk
OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.30.0
export OS=$(shell go env GOOS)
export ARCH=$(shell go env GOARCH)
install-operator-sdk: ## Install operator-sdk
if [ ! -f ~/bin/operator-sdk ]; then \
curl -LO $(OPERATOR_SDK_DL_URL)/operator-sdk_${OS}_${ARCH} ; \
chmod +x operator-sdk_${OS}_${ARCH} ; \
mv operator-sdk_$(OS)_$(ARCH) /usr/local/bin/operator-sdk ; \
fi

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

.PHONY: stop-local-registry
stop-local-registry: ## Stop and remove local registry
docker container stop local-registry && docker container rm -v local-registry
stop-local-registry: ## Stop local registry
$(CONTAINER_RUNTIME) container stop local-registry

.PHONY: remove-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))

##@ Build

Expand Down
9 changes: 6 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ require (
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.12.3 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-sqlite3 v1.14.10 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
Expand All @@ -103,6 +104,7 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
Expand All @@ -118,12 +120,13 @@ require (
go.opentelemetry.io/proto/otlp v0.19.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
Expand Down
18 changes: 12 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
Expand Down Expand Up @@ -777,6 +778,7 @@ github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrap
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -835,6 +837,9 @@ github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqn
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97 h1:3RPlVWzZ/PDqmVuf/FKHARG5EMid/tl7cv54Sw/QRVY=
github.com/rogpeppe/go-internal v1.10.1-0.20230524175051-ec119421bb97/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4=
Expand Down Expand Up @@ -1033,7 +1038,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -1112,8 +1118,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1204,8 +1210,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
Expand Down
45 changes: 22 additions & 23 deletions test/operator-framework-e2e/create_fbc_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"

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

// Forms the FBC declartive config and creates the FBC by calling functions for forming the package, channel and bundles.
func CreateFBC(operatorName, defaultChannel string, bundleRef, bundleVersions []string) *declcfg.DeclarativeConfig {
func CreateFBC(operatorName, defaultChannel 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)
dBundle := formBundle(operatorName, bundleVersions, bundleRef)

dBundle := formBundle(operatorName, bundleRefsVersions)

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

// Forms bundle schema for the FBC
func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(imageRefs))
for i := 0; i < len(imageRefs); i++ {
func formBundle(pkgName string, imgRefsVersions map[string]string) []declcfg.Bundle {
bundleFormed := make([]declcfg.Bundle, 0, len(imgRefsVersions))
for imgRef, version := range imgRefsVersions {
var properties []property.Property
properties = append(properties, property.Property{
Type: SchemaPackage,
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, versions[i])),
Value: json.RawMessage(fmt.Sprintf(`{"packageName": "%s", "version": "%s"}`, pkgName, version)),
})
properties = append(properties, property.Property{
Type: SchemaBundleMediatype,
Expand All @@ -87,9 +93,9 @@ func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {

bundleFormed = append(bundleFormed, declcfg.Bundle{
Schema: SchemaBundle,
Name: pkgName + ".v" + versions[i],
Name: pkgName + ".v" + version,
Package: pkgName,
Image: imageRefs[i],
Image: imgRef,
Properties: properties,
})
}
Expand All @@ -99,30 +105,24 @@ func formBundle(pkgName string, versions, imageRefs []string) []declcfg.Bundle {
// Writes the formed FBC into catalog.yaml file
func WriteFBC(fbc declcfg.DeclarativeConfig, fbcFilePath, fbcFileName string) error {
var buf bytes.Buffer
err := declcfg.WriteYAML(fbc, &buf)
if err != nil {
if err := declcfg.WriteYAML(fbc, &buf); err != nil {
return err
}

_, err = os.Stat(fbcFilePath)
if os.IsNotExist(err) {
err := os.MkdirAll(fbcFilePath, 0755)
if err != nil {
if _, err := os.Stat(fbcFilePath); os.IsNotExist(err) {
if err := os.MkdirAll(fbcFilePath, 0755); err != nil {
return err
}
}
file, err := os.Create(fbcFilePath + "/" + fbcFileName)
if err != nil {
return err
}
defer file.Close()

err = os.WriteFile(fbcFilePath+"/"+fbcFileName, buf.Bytes(), 0600)
file, err := os.Create(filepath.Join(fbcFilePath, fbcFileName))
if err != nil {
return err
}
defer file.Close()

return nil
err = os.WriteFile(filepath.Join(fbcFilePath, fbcFileName), buf.Bytes(), 0600)
return err
}

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

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

Expand Down
13 changes: 4 additions & 9 deletions test/operator-framework-e2e/generate_dockerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,12 @@ func generateDockerFile(dockerFilePath, yamlFolderName, dockerFileName string) e
}
defer file.Close()

_, err = file.WriteString("FROM scratch\n")
if err != nil {
return err
}
err = t.Execute(file, struct{ YamlDir string }{yamlFolderName})
if err != nil {
if _, err = file.WriteString("FROM scratch\n"); err != nil {
return err
}

return nil
err = t.Execute(file, struct{ YamlDir string }{yamlFolderName})
return err
}

const dockerfileTmpl = `ADD {{.YamlDir}} /configs/{{.YamlDir}}
`
const dockerfileTmpl = "ADD {{.YamlDir}} /configs/{{.YamlDir}}\n"
Loading

0 comments on commit b6e8d9b

Please sign in to comment.