Skip to content

Commit

Permalink
[olm] Include script to generate olm bindata
Browse files Browse the repository at this point in the history
  • Loading branch information
varshaprasad96 committed Sep 19, 2020
1 parent ad071c1 commit 9a584e7
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 30 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ GIT_VERSION = $(shell git describe --dirty --tags --always)
GIT_COMMIT = $(shell git rev-parse HEAD)
K8S_VERSION = v1.18.2
GOLANGCI_LINT_VER = "1.30.0"
OLM_VERSION = "0.15.1"
REPO = github.com/operator-framework/operator-sdk
PKGS = $(shell go list ./... | grep -v /vendor/)
TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/')
Expand Down Expand Up @@ -303,3 +304,6 @@ test-e2e-helm: image-build-helm

test-integration: ## Run integration tests
./hack/tests/integration.sh

olm-manifests:
./hack/generate/olm_bindata.sh $(OLM_VERSION)
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.4.0
github.com/stretchr/testify v1.5.1
golang.org/x/tools v0.0.0-20200916150407-587cf2330ce8
golang.org/x/tools v0.0.0-20200918232735-d647fc253266
gomodules.xyz/jsonpatch/v3 v3.0.1
helm.sh/helm/v3 v3.2.4
k8s.io/api v0.18.6
Expand All @@ -31,7 +31,6 @@ require (
k8s.io/cli-runtime v0.18.2
k8s.io/client-go v0.18.6
k8s.io/kubectl v0.18.2
rsc.io/letsencrypt v0.0.3 // indirect
sigs.k8s.io/controller-runtime v0.6.2
sigs.k8s.io/controller-tools v0.3.0
sigs.k8s.io/kubebuilder v1.0.9-0.20200805184228-f7a3b65dd250
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -906,8 +906,8 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b h1:AFZdJUT7jJYXQEC29hYH/WZkoV7+KhwxQGmdZ19yYoY=
golang.org/x/tools v0.0.0-20200403190813-44a64ad78b9b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200916150407-587cf2330ce8 h1:lIJ1QeajWjHg0sYO9manyujReNonmQQ4OpYx+BtgawI=
golang.org/x/tools v0.0.0-20200916150407-587cf2330ce8/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/tools v0.0.0-20200918232735-d647fc253266 h1:k7tVuG0g1JwmD3Jh8oAl1vQ1C3jb4Hi/dUl1wWDBJpQ=
golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
Expand Down
35 changes: 35 additions & 0 deletions hack/generate/olm_bindata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

filename="olm_bindata-"$1.go
echo $filename

function get_olm_manifests() {
mkdir olm-manifests
echo "downloading olm manifests for version ${1}"
wget -O olm-manifests/olm.yaml "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${1}/olm.yaml"
wget -O olm-manifests/crds.yaml "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/${1}/crds.yaml"
}

function remove_olm_manifests {
rm -rf olm-manifests
}

# check for files starting with the name "olm-bindata" inside internal/olm folder
function delete_old_olmbindata {
echo "Deleting previous versions of olm-bindata files if they exist"
find internal/olmbindata -maxdepth 1 -type f -name olm_bindata-* -exec rm {} \;
}

FILE=internal/olm/$filename
if [ ! -f "$FILE" ]; then
delete_old_olmbindata
get_olm_manifests $1

go get -u github.com/go-bindata/go-bindata/...
$(go env GOPATH)/bin/go-bindata -o olm_bindata-$1.go -pkg olmbindata olm-manifests/
mv olm_bindata-$1.go internal/olmbindata/

remove_olm_manifests
fi

go mod tidy
4 changes: 2 additions & 2 deletions internal/olm/installer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const (
olmOperatorName = "olm-operator"
catalogOperatorName = "catalog-operator"
packageServerName = "packageserver"
olmManifestBindataPath = "internal/olmbindata/olm.yaml"
crdManifestBindataPath = "internal/olmbindata/crds.yaml"
olmManifestBindataPath = "olm-manifests/olm.yaml"
crdManifestBindataPath = "olm-manifests/crds.yaml"
)

type Client struct {
Expand Down
46 changes: 22 additions & 24 deletions internal/olmbindata/olm_bindata-0.15.1.go

Large diffs are not rendered by default.

0 comments on commit 9a584e7

Please sign in to comment.