From ee8fdba828942b646696cb0af49d79d0d5044c1d Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Wed, 8 Jul 2020 14:33:36 -0400 Subject: [PATCH] Makefile,hack/image: build and release targets for helm and ansible binaries --- Makefile | 52 ++++++++++++++++--- .../release-helm-ansible-binaries.yaml | 5 ++ hack/image/build-ansible-image.sh | 5 +- hack/image/build-helm-image.sh | 5 +- .../content/en/docs/install-operator-sdk.md | 22 +++++++- 5 files changed, 72 insertions(+), 17 deletions(-) create mode 100644 changelog/fragments/release-helm-ansible-binaries.yaml diff --git a/Makefile b/Makefile index edb6bee0e8..0ecd306ae3 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,9 @@ VERSION = $(shell git describe --dirty --tags --always) GIT_COMMIT = $(shell git rev-parse HEAD) K8S_VERSION = v1.18.2 REPO = github.com/operator-framework/operator-sdk -BUILD_PATH = $(REPO)/cmd/operator-sdk +SDK_BUILD_PATH = $(REPO)/cmd/operator-sdk +ANSIBLE_BUILD_PATH = $(REPO)/cmd/ansible-operator +HELM_BUILD_PATH = $(REPO)/cmd/helm-operator PKGS = $(shell go list ./... | grep -v /vendor/) TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/') SOURCES = $(shell find . -name '*.go' -not -path "*/vendor/*") @@ -68,7 +70,13 @@ help: ## Show this help screen all: format test build/operator-sdk ## Test and Build the Operator SDK install: ## Install the operator-sdk binary - $(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(BUILD_PATH) + $(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(SDK_BUILD_PATH) + +install-ansible: ## Install the ansible-operator binary + $(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(ANSIBLE_BUILD_PATH) + +install-helm: ## Install the helm-operator binary + $(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(HELM_BUILD_PATH) # Code management. .PHONY: format tidy clean cli-doc lint @@ -127,7 +135,17 @@ release_builds := \ build/operator-sdk-$(VERSION)-x86_64-linux-gnu \ build/operator-sdk-$(VERSION)-x86_64-apple-darwin \ build/operator-sdk-$(VERSION)-ppc64le-linux-gnu \ - build/operator-sdk-$(VERSION)-s390x-linux-gnu + build/operator-sdk-$(VERSION)-s390x-linux-gnu \ + build/ansible-operator-$(VERSION)-aarch64-linux-gnu \ + build/ansible-operator-$(VERSION)-x86_64-linux-gnu \ + build/ansible-operator-$(VERSION)-x86_64-apple-darwin \ + build/ansible-operator-$(VERSION)-ppc64le-linux-gnu \ + build/ansible-operator-$(VERSION)-s390x-linux-gnu \ + build/helm-operator-$(VERSION)-aarch64-linux-gnu \ + build/helm-operator-$(VERSION)-x86_64-linux-gnu \ + build/helm-operator-$(VERSION)-x86_64-apple-darwin \ + build/helm-operator-$(VERSION)-ppc64le-linux-gnu \ + build/helm-operator-$(VERSION)-s390x-linux-gnu release: clean $(release_builds) $(release_builds:=.asc) ## Release the Operator SDK @@ -138,8 +156,28 @@ build/operator-sdk-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le build/operator-sdk-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x build/operator-sdk-%-linux-gnu: GOARGS = GOOS=linux -build/%: $(SOURCES) ## Build the operator-sdk binary - $(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(BUILD_PATH) +build/ansible-operator-%-aarch64-linux-gnu: GOARGS = GOOS=linux GOARCH=arm64 +build/ansible-operator-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64 +build/ansible-operator-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64 +build/ansible-operator-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le +build/ansible-operator-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x +build/ansible-operator-%-linux-gnu: GOARGS = GOOS=linux + +build/helm-operator-%-aarch64-linux-gnu: GOARGS = GOOS=linux GOARCH=arm64 +build/helm-operator-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64 +build/helm-operator-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64 +build/helm-operator-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le +build/helm-operator-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x +build/helm-operator-%-linux-gnu: GOARGS = GOOS=linux + +build/operator-%: $(SOURCES) ## Build the operator-sdk binary + $(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(SDK_BUILD_PATH) + +build/ansible-%: $(SOURCES) ## Build the ansible-operator binary + $(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(ANSIBLE_BUILD_PATH) + +build/helm-%: $(SOURCES) ## Build the helm-operator binary + $(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(HELM_BUILD_PATH) build/%.asc: ## Create release signatures for operator-sdk release binaries $(Q){ \ @@ -169,7 +207,7 @@ image-push: image-push-ansible image-push-helm image-push-scorecard-proxy image- image-scaffold-ansible: go run ./hack/image/ansible/scaffold-ansible-image.go -image-build-ansible: build/operator-sdk-dev-linux-gnu +image-build-ansible: build/ansible-operator-dev-linux-gnu ./hack/image/build-ansible-image.sh $(ANSIBLE_BASE_IMAGE):dev image-push-ansible: @@ -184,7 +222,7 @@ image-push-ansible-multiarch: image-scaffold-helm: go run ./hack/image/helm/scaffold-helm-image.go -image-build-helm: build/operator-sdk-dev-linux-gnu +image-build-helm: build/helm-operator-dev-linux-gnu ./hack/image/build-helm-image.sh $(HELM_BASE_IMAGE):dev image-push-helm: diff --git a/changelog/fragments/release-helm-ansible-binaries.yaml b/changelog/fragments/release-helm-ansible-binaries.yaml new file mode 100644 index 0000000000..68224834fd --- /dev/null +++ b/changelog/fragments/release-helm-ansible-binaries.yaml @@ -0,0 +1,5 @@ +entries: + - description: > + Add builds for `ansible-operator` and `helm-operator` binaries + kind: addition + breaking: false diff --git a/hack/image/build-ansible-image.sh b/hack/image/build-ansible-image.sh index 6588bbe146..3da45198b0 100755 --- a/hack/image/build-ansible-image.sh +++ b/hack/image/build-ansible-image.sh @@ -12,15 +12,12 @@ BASEIMAGEDIR="$TMPDIR/ansible-operator" mkdir -p "$BASEIMAGEDIR" go build -o $BASEIMAGEDIR/scaffold-ansible-image ./hack/image/ansible/scaffold-ansible-image.go -# build binary for specific target platform (for purposes of base image only) -env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/ansible-operator-dev-linux-gnu ./cmd/ansible-operator/main.go - # build operator binary and base image pushd "$BASEIMAGEDIR" ./scaffold-ansible-image mkdir -p build/_output/bin/ -cp $BASEIMAGEDIR/ansible-operator-dev-linux-gnu build/_output/bin/ansible-operator +cp $ROOTDIR/build/ansible-operator-dev-linux-gnu build/_output/bin/ansible-operator operator-sdk build $1 # If using a kind cluster, load the image into all nodes. load_image_if_kind "$1" diff --git a/hack/image/build-helm-image.sh b/hack/image/build-helm-image.sh index dcf1f79341..3fbc1cb423 100755 --- a/hack/image/build-helm-image.sh +++ b/hack/image/build-helm-image.sh @@ -12,15 +12,12 @@ BASEIMAGEDIR="$TMPDIR/helm-operator" mkdir -p "$BASEIMAGEDIR" go build -o $BASEIMAGEDIR/scaffold-helm-image ./hack/image/helm/scaffold-helm-image.go -# build binary for specific target platform (for purposes of base image only) -env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/helm-operator-dev-linux-gnu ./cmd/helm-operator/main.go - # build operator binary and base image pushd "$BASEIMAGEDIR" ./scaffold-helm-image mkdir -p build/_output/bin/ -cp $BASEIMAGEDIR/helm-operator-dev-linux-gnu build/_output/bin/helm-operator +cp $ROOTDIR/build/helm-operator-dev-linux-gnu build/_output/bin/helm-operator operator-sdk build $1 # If using a kind cluster, load the image into all nodes. load_image_if_kind "$1" diff --git a/website/content/en/docs/install-operator-sdk.md b/website/content/en/docs/install-operator-sdk.md index e7f14e1a7b..144bc28ba7 100644 --- a/website/content/en/docs/install-operator-sdk.md +++ b/website/content/en/docs/install-operator-sdk.md @@ -18,24 +18,32 @@ $ brew install operator-sdk ## Install from GitHub release -### Download the release binary +### Download the release binaries ```sh # Set the release version variable $ RELEASE_VERSION=v0.18.0 # Linux $ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu # macOS $ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin ``` -#### Verify the downloaded release binary +#### Verify the downloaded release binaries ```sh # Linux $ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc # macOS $ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc +$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc ``` To verify a release binary using the provided asc files, place the binary and corresponding asc file into the same directory and use the corresponding command: @@ -43,8 +51,12 @@ To verify a release binary using the provided asc files, place the binary and co ```sh # Linux $ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc +$ gpg --verify ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc +$ gpg --verify helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc # macOS $ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc +$ gpg --verify ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc +$ gpg --verify helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc ``` If you do not have the maintainers public key on your machine, you will get an error message similar to this: @@ -76,8 +88,12 @@ Now you should be able to verify the binary. ```sh # Linux $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/operator-sdk && rm operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu +$ chmod +x ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/ansible-operator && rm ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu +$ chmod +x helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu && sudo mkdir -p /usr/local/bin/ && sudo cp helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu /usr/local/bin/helm-operator && rm helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu # macOS $ chmod +x operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/operator-sdk && rm operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin +$ chmod +x ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/ansible-operator && rm ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin +$ chmod +x helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin && sudo mkdir -p /usr/local/bin/ && sudo cp helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin /usr/local/bin/helm-operator && rm helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin ``` ## Compile and install from master @@ -95,6 +111,8 @@ $ cd operator-sdk $ git checkout master $ make tidy $ make install +$ make install-ansible +$ make install-helm ``` **Note:** Ensure that your `GOPROXY` is set with its default value for Go