Skip to content

Commit 351d223

Browse files
authored
Makefile,hack/image: build and release targets for helm and ansible binaries (#3363)
1 parent bd8520c commit 351d223

File tree

5 files changed

+72
-17
lines changed

5 files changed

+72
-17
lines changed

Makefile

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ VERSION = $(shell git describe --dirty --tags --always)
1313
GIT_COMMIT = $(shell git rev-parse HEAD)
1414
K8S_VERSION = v1.18.2
1515
REPO = github.com/operator-framework/operator-sdk
16-
BUILD_PATH = $(REPO)/cmd/operator-sdk
16+
SDK_BUILD_PATH = $(REPO)/cmd/operator-sdk
17+
ANSIBLE_BUILD_PATH = $(REPO)/cmd/ansible-operator
18+
HELM_BUILD_PATH = $(REPO)/cmd/helm-operator
1719
PKGS = $(shell go list ./... | grep -v /vendor/)
1820
TEST_PKGS = $(shell go list ./... | grep -v -E 'github.com/operator-framework/operator-sdk/test/')
1921
SOURCES = $(shell find . -name '*.go' -not -path "*/vendor/*")
@@ -68,7 +70,13 @@ help: ## Show this help screen
6870
all: format test build/operator-sdk ## Test and Build the Operator SDK
6971

7072
install: ## Install the operator-sdk binary
71-
$(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(BUILD_PATH)
73+
$(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(SDK_BUILD_PATH)
74+
75+
install-ansible: ## Install the ansible-operator binary
76+
$(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(ANSIBLE_BUILD_PATH)
77+
78+
install-helm: ## Install the helm-operator binary
79+
$(Q)$(GOARGS) go install $(GO_BUILD_ARGS) $(HELM_BUILD_PATH)
7280

7381
# Code management.
7482
.PHONY: format tidy clean cli-doc lint
@@ -127,7 +135,17 @@ release_builds := \
127135
build/operator-sdk-$(VERSION)-x86_64-linux-gnu \
128136
build/operator-sdk-$(VERSION)-x86_64-apple-darwin \
129137
build/operator-sdk-$(VERSION)-ppc64le-linux-gnu \
130-
build/operator-sdk-$(VERSION)-s390x-linux-gnu
138+
build/operator-sdk-$(VERSION)-s390x-linux-gnu \
139+
build/ansible-operator-$(VERSION)-aarch64-linux-gnu \
140+
build/ansible-operator-$(VERSION)-x86_64-linux-gnu \
141+
build/ansible-operator-$(VERSION)-x86_64-apple-darwin \
142+
build/ansible-operator-$(VERSION)-ppc64le-linux-gnu \
143+
build/ansible-operator-$(VERSION)-s390x-linux-gnu \
144+
build/helm-operator-$(VERSION)-aarch64-linux-gnu \
145+
build/helm-operator-$(VERSION)-x86_64-linux-gnu \
146+
build/helm-operator-$(VERSION)-x86_64-apple-darwin \
147+
build/helm-operator-$(VERSION)-ppc64le-linux-gnu \
148+
build/helm-operator-$(VERSION)-s390x-linux-gnu
131149

132150
release: clean $(release_builds) $(release_builds:=.asc) ## Release the Operator SDK
133151

@@ -138,8 +156,28 @@ build/operator-sdk-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le
138156
build/operator-sdk-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
139157
build/operator-sdk-%-linux-gnu: GOARGS = GOOS=linux
140158

141-
build/%: $(SOURCES) ## Build the operator-sdk binary
142-
$(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(BUILD_PATH)
159+
build/ansible-operator-%-aarch64-linux-gnu: GOARGS = GOOS=linux GOARCH=arm64
160+
build/ansible-operator-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64
161+
build/ansible-operator-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64
162+
build/ansible-operator-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le
163+
build/ansible-operator-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
164+
build/ansible-operator-%-linux-gnu: GOARGS = GOOS=linux
165+
166+
build/helm-operator-%-aarch64-linux-gnu: GOARGS = GOOS=linux GOARCH=arm64
167+
build/helm-operator-%-x86_64-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64
168+
build/helm-operator-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64
169+
build/helm-operator-%-ppc64le-linux-gnu: GOARGS = GOOS=linux GOARCH=ppc64le
170+
build/helm-operator-%-s390x-linux-gnu: GOARGS = GOOS=linux GOARCH=s390x
171+
build/helm-operator-%-linux-gnu: GOARGS = GOOS=linux
172+
173+
build/operator-%: $(SOURCES) ## Build the operator-sdk binary
174+
$(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(SDK_BUILD_PATH)
175+
176+
build/ansible-%: $(SOURCES) ## Build the ansible-operator binary
177+
$(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(ANSIBLE_BUILD_PATH)
178+
179+
build/helm-%: $(SOURCES) ## Build the helm-operator binary
180+
$(Q)$(GOARGS) go build $(GO_BUILD_ARGS) -o $@ $(HELM_BUILD_PATH)
143181

144182
build/%.asc: ## Create release signatures for operator-sdk release binaries
145183
$(Q){ \
@@ -169,7 +207,7 @@ image-push: image-push-ansible image-push-helm image-push-scorecard-proxy image-
169207
image-scaffold-ansible:
170208
go run ./hack/image/ansible/scaffold-ansible-image.go
171209

172-
image-build-ansible: build/operator-sdk-dev-linux-gnu
210+
image-build-ansible: build/ansible-operator-dev-linux-gnu
173211
./hack/image/build-ansible-image.sh $(ANSIBLE_BASE_IMAGE):dev
174212

175213
image-push-ansible:
@@ -184,7 +222,7 @@ image-push-ansible-multiarch:
184222
image-scaffold-helm:
185223
go run ./hack/image/helm/scaffold-helm-image.go
186224

187-
image-build-helm: build/operator-sdk-dev-linux-gnu
225+
image-build-helm: build/helm-operator-dev-linux-gnu
188226
./hack/image/build-helm-image.sh $(HELM_BASE_IMAGE):dev
189227

190228
image-push-helm:
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
entries:
2+
- description: >
3+
Add builds for `ansible-operator` and `helm-operator` binaries
4+
kind: addition
5+
breaking: false

hack/image/build-ansible-image.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ BASEIMAGEDIR="$TMPDIR/ansible-operator"
1212
mkdir -p "$BASEIMAGEDIR"
1313
go build -o $BASEIMAGEDIR/scaffold-ansible-image ./hack/image/ansible/scaffold-ansible-image.go
1414

15-
# build binary for specific target platform (for purposes of base image only)
16-
env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/ansible-operator-dev-linux-gnu ./cmd/ansible-operator/main.go
17-
1815
# build operator binary and base image
1916
pushd "$BASEIMAGEDIR"
2017
./scaffold-ansible-image
2118

2219
mkdir -p build/_output/bin/
23-
cp $BASEIMAGEDIR/ansible-operator-dev-linux-gnu build/_output/bin/ansible-operator
20+
cp $ROOTDIR/build/ansible-operator-dev-linux-gnu build/_output/bin/ansible-operator
2421
operator-sdk build $1
2522
# If using a kind cluster, load the image into all nodes.
2623
load_image_if_kind "$1"

hack/image/build-helm-image.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ BASEIMAGEDIR="$TMPDIR/helm-operator"
1212
mkdir -p "$BASEIMAGEDIR"
1313
go build -o $BASEIMAGEDIR/scaffold-helm-image ./hack/image/helm/scaffold-helm-image.go
1414

15-
# build binary for specific target platform (for purposes of base image only)
16-
env GOOS=linux GOARCH=amd64 go build -o $BASEIMAGEDIR/helm-operator-dev-linux-gnu ./cmd/helm-operator/main.go
17-
1815
# build operator binary and base image
1916
pushd "$BASEIMAGEDIR"
2017
./scaffold-helm-image
2118

2219
mkdir -p build/_output/bin/
23-
cp $BASEIMAGEDIR/helm-operator-dev-linux-gnu build/_output/bin/helm-operator
20+
cp $ROOTDIR/build/helm-operator-dev-linux-gnu build/_output/bin/helm-operator
2421
operator-sdk build $1
2522
# If using a kind cluster, load the image into all nodes.
2623
load_image_if_kind "$1"

website/content/en/docs/install-operator-sdk.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,45 @@ $ brew install operator-sdk
1818

1919
## Install from GitHub release
2020

21-
### Download the release binary
21+
### Download the release binaries
2222

2323
```sh
2424
# Set the release version variable
2525
$ RELEASE_VERSION=v0.18.0
2626
# Linux
2727
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu
28+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu
29+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu
2830
# macOS
2931
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin
32+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin
33+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin
3034
```
3135

32-
#### Verify the downloaded release binary
36+
#### Verify the downloaded release binaries
3337

3438
```sh
3539
# Linux
3640
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
41+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc
42+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc
3743
# macOS
3844
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc
45+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc
46+
$ curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${RELEASE_VERSION}/helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc
3947
```
4048

4149
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:
4250

4351
```sh
4452
# Linux
4553
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-linux-gnu.asc
54+
$ gpg --verify ansible-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc
55+
$ gpg --verify helm-operator-${RELEASE_VERSION}-x86_64-linux-gnu.asc
4656
# macOS
4757
$ gpg --verify operator-sdk-${RELEASE_VERSION}-x86_64-apple-darwin.asc
58+
$ gpg --verify ansible-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc
59+
$ gpg --verify helm-operator-${RELEASE_VERSION}-x86_64-apple-darwin.asc
4860
```
4961

5062
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.
7688
```sh
7789
# Linux
7890
$ 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
91+
$ 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
92+
$ 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
7993
# macOS
8094
$ 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
95+
$ 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
96+
$ 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
8197
```
8298
8399
## Compile and install from master
@@ -95,6 +111,8 @@ $ cd operator-sdk
95111
$ git checkout master
96112
$ make tidy
97113
$ make install
114+
$ make install-ansible
115+
$ make install-helm
98116
```
99117
100118
**Note:** Ensure that your `GOPROXY` is set with its default value for Go

0 commit comments

Comments
 (0)