Skip to content

Commit a64587b

Browse files
authored
build: Tidy up goreleaser config (#745)
This commit tidies up the goreleaser config that contained some configuration that is no longer required, e.g. deleting the `v` prefix handling code; templating the arch specific Docker image builds (now handled by loading the arch specific image into KinD and e2e environment); and removing the caren buildx build container (changing the helm registry Dockerfile to be a multistage build to only run the host compatible architecture of mindthegap binary).
1 parent b79f78f commit a64587b

File tree

7 files changed

+51
-60
lines changed

7 files changed

+51
-60
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223
kind load docker-image \
224224
--name chart-testing \
225225
"ko.local/cluster-api-runtime-extensions-nutanix:$(devbox run -- gojq -r .version dist/metadata.json)" \
226-
"ghcr.io/nutanix-cloud-native/caren-helm-reg:$(devbox run -- gojq -r .version dist/metadata.json)"
226+
"ghcr.io/nutanix-cloud-native/caren-helm-reg:$(devbox run -- gojq -r .version dist/metadata.json)-$(devbox run -- go env GOARCH)"
227227
228228
- if: steps.list-changed.outputs.changed == 'true'
229229
name: Setup Cluster API and cert-manager

.goreleaser.yml

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,18 @@ before:
4141
name: caren-system
4242
$(helm template {{ .ProjectName }} ./charts/{{ .ProjectName }} \
4343
--namespace caren-system \
44-
--set-string image.tag=v{{ trimprefix .Version "v" }} \
45-
--set-string helmRepositoryImage.tag=v{{ trimprefix .Version "v" }} \
46-
{{ if .IsSnapshot }}--set-string image.repository=ko.local/{{ .ProjectName }}{{ end }} \
44+
--set-string image.tag={{ .Version }} \
45+
--set-string helmRepositoryImage.tag={{ .Version }}{{ if .IsSnapshot }}-{{ .Env.GOARCH }} \
46+
--set-string image.repository=ko.local/{{ .ProjectName }}{{ end }} \
4747
)
4848
EOF'
49-
- sed -i -e 's/\${/$${/g' -e 's/v0.0.0-dev/v{{ trimprefix .Version "v" }}/g' runtime-extension-components.yaml
49+
- sed -i -e 's/\${/$${/g' -e 's/v0.0.0-dev/{{ .Version }}/g' runtime-extension-components.yaml
5050
- |
5151
sh -ec 'gojq --yaml-input --yaml-output \
5252
".releaseSeries |= (. + [{contract: \"v1beta1\", major: {{ .Major }}, minor: {{ .Minor }}}] | unique)" \
5353
metadata.yaml >release-metadata.yaml'
5454
- make template-helm-repository
5555

56-
5756
builds:
5857
- id: cluster-api-runtime-extensions-nutanix
5958
dir: ./cmd
@@ -67,7 +66,7 @@ builds:
6766
- -X 'k8s.io/component-base/version.buildDate={{ .CommitDate }}'
6867
- -X 'k8s.io/component-base/version.gitCommit={{ .FullCommit }}'
6968
- -X 'k8s.io/component-base/version.gitTreeState={{ .Env.GIT_TREE_STATE }}'
70-
- -X 'k8s.io/component-base/version.gitVersion=v{{ trimprefix .Version "v" }}'
69+
- -X 'k8s.io/component-base/version.gitVersion={{ .Version }}'
7170
- -X 'k8s.io/component-base/version.major={{ .Major }}'
7271
- -X 'k8s.io/component-base/version.minor={{ .Minor }}'
7372
- -X 'k8s.io/component-base/version/verflag.programName={{ .ProjectName }}'
@@ -86,66 +85,52 @@ builds:
8685
KO_DOCKER_REPO=ko.local/{{ .ProjectName }} \
8786
ko build \
8887
--bare \
89-
-t v{{ trimprefix .Version "v" }} \
88+
-t {{ .Version }} \
9089
./cmd
9190
fi'
9291
9392
archives:
94-
- name_template: '{{ .ProjectName }}_v{{ trimprefix .Version "v" }}_{{ .Os }}_{{ .Arch }}'
93+
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
9594
builds:
9695
- cluster-api-runtime-extensions-nutanix
9796

9897
dockers:
9998
- image_templates:
100-
# Specify the image tag including `-amd64` suffix if the build is not a snapshot build or is not being built on
101-
# amd64 machine. This allows for using the snapshot image build without the architecture specific suffix
102-
# consistently on local machines, i.e. can always use `ghcr.io/nutanix-cloud-native/caren-helm-reg:v<VERSION>` on the machine the snapshot
103-
# is built on.
104-
#
105-
# For a release build the `-amd64` suffix will always be included and the `docker_manifests` specification below
106-
# will create the final multiplatform manifest to be pushed to the registry.
107-
- 'ghcr.io/nutanix-cloud-native/caren-helm-reg:v{{ trimprefix .Version "v" }}{{ if or (not .IsSnapshot) (not (eq .Runtime.Goarch "amd64")) }}-amd64{{ end }}'
99+
- 'ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}-amd64'
108100
use: buildx
109101
dockerfile: ./hack/addons/mindthegap-helm-registry/Dockerfile
110102
extra_files:
111103
- hack/addons/mindthegap-helm-registry/repos.yaml
112104
build_flag_templates:
113105
- "--platform=linux/amd64"
114-
- "--builder=caren"
115106
- "--pull"
116107
- "--label=org.opencontainers.image.created={{.CommitDate}}"
117108
- "--label=org.opencontainers.image.title=caren-helm-reg"
118109
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
119-
- '--label=org.opencontainers.image.version=v{{ trimprefix .Version "v" }}'
110+
- '--label=org.opencontainers.image.version={{ .Version }}'
120111
- "--label=org.opencontainers.image.source={{.GitURL}}"
112+
goarch: amd64
121113
- image_templates:
122-
# Specify the image tag including `-arm64` suffix if the build is not a snapshot build or is not being built on
123-
# arm64 machine. This allows for using the snapshot image build without the architecture specific suffix
124-
# consistently on local machines, i.e. can always use `ghcr.io/nutanix-cloud-native/caren-helm-reg:v<VERSION>` on the machine the snapshot
125-
# is built on.
126-
#
127-
# For a release build the `-arm64` suffix will always be included and the `docker_manifests` specification below
128-
# will create the final multiplatform manifest to be pushed to the registry.
129-
- 'ghcr.io/nutanix-cloud-native/caren-helm-reg:v{{ trimprefix .Version "v" }}{{ if or (not .IsSnapshot) (not (eq .Runtime.Goarch "arm64")) }}-arm64{{ end }}'
114+
- 'ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}-arm64'
130115
use: buildx
131116
dockerfile: ./hack/addons/mindthegap-helm-registry/Dockerfile
132117
extra_files:
133118
- hack/addons/mindthegap-helm-registry/repos.yaml
134119
build_flag_templates:
135120
- "--platform=linux/arm64"
136-
- "--builder=caren"
137121
- "--pull"
138122
- "--label=org.opencontainers.image.created={{.CommitDate}}"
139123
- "--label=org.opencontainers.image.title=caren-helm-reg"
140124
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
141-
- '--label=org.opencontainers.image.version=v{{ trimprefix .Version "v" }}'
125+
- '--label=org.opencontainers.image.version={{ .Version }}'
142126
- "--label=org.opencontainers.image.source={{.GitURL}}"
127+
goarch: arm64
143128

144129
docker_manifests:
145-
- name_template: ghcr.io/nutanix-cloud-native/caren-helm-reg:v{{ trimprefix .Version "v" }}
130+
- name_template: ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}
146131
image_templates:
147-
- ghcr.io/nutanix-cloud-native/caren-helm-reg:v{{ trimprefix .Version "v" }}-amd64
148-
- ghcr.io/nutanix-cloud-native/caren-helm-reg:v{{ trimprefix .Version "v" }}-arm64
132+
- ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}-amd64
133+
- ghcr.io/nutanix-cloud-native/caren-helm-reg:{{ .Version }}-arm64
149134

150135
kos:
151136
- id: cluster-api-runtime-extensions-nutanix
@@ -156,23 +141,23 @@ kos:
156141
- -X 'k8s.io/component-base/version.buildDate={{ .CommitDate }}'
157142
- -X 'k8s.io/component-base/version.gitCommit={{ .FullCommit }}'
158143
- -X 'k8s.io/component-base/version.gitTreeState={{ .Env.GIT_TREE_STATE }}'
159-
- -X 'k8s.io/component-base/version.gitVersion=v{{ trimprefix .Version "v" }}'
144+
- -X 'k8s.io/component-base/version.gitVersion={{ .Version }}'
160145
- -X 'k8s.io/component-base/version.major={{ .Major }}'
161146
- -X 'k8s.io/component-base/version.minor={{ .Minor }}'
162147
- -X 'k8s.io/component-base/version/verflag.programName={{ .ProjectName }}'
163148
labels:
164149
org.opencontainers.image.created: "{{ .CommitDate }}"
165150
org.opencontainers.image.title: "{{ .ProjectName }}"
166151
org.opencontainers.image.revision: "{{ .FullCommit }}"
167-
org.opencontainers.image.version: v{{ trimprefix .Version "v" }}
152+
org.opencontainers.image.version: "{{ .Version }}"
168153
org.opencontainers.image.source: "{{ .GitURL }}"
169154
platforms:
170155
- linux/amd64
171156
- linux/arm64
172157
repository: ghcr.io/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix
173158
bare: true
174159
tags:
175-
- v{{ trimprefix .Version "v" }}
160+
- "{{ .Version }}"
176161

177162
checksum:
178163
name_template: 'checksums.txt'
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
FROM ghcr.io/mesosphere/mindthegap:v1.14.3
1+
ARG MINDTHEGAP_VERSION=v1.14.3
2+
3+
FROM --platform=${BUILDPLATFORM} ghcr.io/mesosphere/mindthegap:${MINDTHEGAP_VERSION} as bundle_builder
24
# this gets called by goreleaser so the copy source has to be the path relative to the repo root.
3-
RUN --mount=source=./hack/addons/mindthegap-helm-registry/repos.yaml,target=/repos.yaml ["/ko-app/mindthegap", "create", "bundle", "--helm-charts-file=/repos.yaml", "--output-file=/tmp/helm-charts.tar"]
5+
RUN --mount=source=./hack/addons/mindthegap-helm-registry/repos.yaml,target=/repos.yaml \
6+
["/ko-app/mindthegap", "create", "bundle", "--helm-charts-file=/repos.yaml", "--output-file=/tmp/helm-charts.tar"]
7+
8+
FROM --platform=${TARGETPLATFORM} ghcr.io/mesosphere/mindthegap:${MINDTHEGAP_VERSION}
9+
COPY --from=bundle_builder /tmp/helm-charts.tar /tmp/helm-charts.tar
410
VOLUME /certs
5-
CMD ["serve", "bundle", "--bundle=/tmp/helm-charts.tar", "--listen-port=5000", "--listen-address=0.0.0.0", "--tls-private-key-file=/certs/tls.key", "--tls-cert-file=/certs/tls.crt"]
11+
CMD [ "serve", "bundle", \
12+
"--bundle=/tmp/helm-charts.tar", \
13+
"--listen-port=5000", \
14+
"--listen-address=0.0.0.0", \
15+
"--tls-private-key-file=/certs/tls.key", \
16+
"--tls-cert-file=/certs/tls.crt" ]

make/dev.mk

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55
dev.run-on-kind: export KUBECONFIG := $(KIND_KUBECONFIG)
66
dev.run-on-kind: kind.create clusterctl.init
77
ifndef SKIP_BUILD
8-
$(MAKE) release-snapshot
8+
dev.run-on-kind: release-snapshot
99
endif
10+
dev.run-on-kind:
1011
kind load docker-image --name $(KIND_CLUSTER_NAME) \
11-
ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json)
12-
kind load docker-image --name $(KIND_CLUSTER_NAME) \
13-
ghcr.io/nutanix-cloud-native/caren-helm-reg:$$(gojq -r .version dist/metadata.json)
12+
ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json) \
13+
ghcr.io/nutanix-cloud-native/caren-helm-reg:$$(gojq -r .version dist/metadata.json)-$(GOARCH)
1414
helm upgrade --install cluster-api-runtime-extensions-nutanix ./charts/cluster-api-runtime-extensions-nutanix \
1515
--set-string image.repository=ko.local/cluster-api-runtime-extensions-nutanix \
1616
--set-string image.tag=$$(gojq -r .version dist/metadata.json) \
17-
--set-string helmRepositoryImage.tag=$$(gojq -r .version dist/metadata.json) \
17+
--set-string helmRepositoryImage.tag=$$(gojq -r .version dist/metadata.json)-$(GOARCH) \
1818
--wait --wait-for-jobs
1919
kubectl rollout restart deployment cluster-api-runtime-extensions-nutanix
2020
kubectl rollout status deployment cluster-api-runtime-extensions-nutanix
2121

2222
.PHONY: dev.update-webhook-image-on-kind
2323
dev.update-webhook-image-on-kind: export KUBECONFIG := $(KIND_KUBECONFIG)
24-
dev.update-webhook-image-on-kind:
2524
ifndef SKIP_BUILD
26-
$(MAKE) release-snapshot
25+
dev.update-webhook-image-on-kind: release-snapshot
2726
endif
27+
dev.update-webhook-image-on-kind:
2828
kind load docker-image --name $(KIND_CLUSTER_NAME) \
29-
ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json)
30-
kubectl set image deployment cluster-api-runtime-extensions-nutanix webhook=ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json)
29+
ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json)
30+
kubectl set image deployment \
31+
cluster-api-runtime-extensions-nutanix webhook=ko.local/cluster-api-runtime-extensions-nutanix:$$(gojq -r .version dist/metadata.json)
3132
kubectl rollout restart deployment cluster-api-runtime-extensions-nutanix
3233
kubectl rollout status deployment cluster-api-runtime-extensions-nutanix
3334

34-
3535
.PHONY: dev.update-bootstrap-credentials-aws
3636
dev.update-bootstrap-credentials-aws: export KUBECONFIG := $(KIND_KUBECONFIG)
3737
dev.update-bootstrap-credentials-aws:

make/go.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ test.%: go-generate ; $(info $(M) running tests$(if $(GOTEST_RUN), matching "$(G
5252

5353
.PHONY: integration-test
5454
integration-test: ## Runs integration tests for all modules in repository
55-
integration-test:
56-
$(MAKE) GOTEST_RUN=Integration test
55+
integration-test: GOTEST_RUN := Integration
56+
integration-test: test
5757

5858
.PHONY: integration-test.%
5959
integration-test.%: ## Runs integration tests for a specific module
60-
integration-test.%:
61-
$(MAKE) GOTEST_RUN=Integration test.$*
60+
integration-test.%: GOTEST_RUN := Integration
61+
integration-test.%: test.$*
6262

6363
.PHONY: bench
6464
bench: ## Runs go benchmarks for all modules in repository

make/goreleaser.mk

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ ifndef GORELEASER_CURRENT_TAG
88
export GORELEASER_CURRENT_TAG=$(GIT_TAG)
99
endif
1010

11-
.PHONY: docker-buildx
12-
docker-buildx: ## Creates buildx builder container that supports multiple platforms.
13-
docker-buildx:
14-
docker buildx create --name=caren --platform=linux/arm64,linux/amd64 || true
15-
1611
.PHONY: build-snapshot
1712
build-snapshot: ## Builds a snapshot with goreleaser
1813
build-snapshot: go-generate ; $(info $(M) building snapshot $*)
@@ -25,7 +20,7 @@ build-snapshot: go-generate ; $(info $(M) building snapshot $*)
2520

2621
.PHONY: release
2722
release: ## Builds a release with goreleaser
28-
release: docker-buildx go-generate ; $(info $(M) building release $*)
23+
release: go-generate ; $(info $(M) building release $*)
2924
goreleaser --verbose=$(GORELEASER_VERBOSE) \
3025
release \
3126
--clean \
@@ -35,7 +30,7 @@ release: docker-buildx go-generate ; $(info $(M) building release $*)
3530

3631
.PHONY: release-snapshot
3732
release-snapshot: ## Builds a snapshot release with goreleaser
38-
release-snapshot: docker-buildx go-generate ; $(info $(M) building snapshot release $*)
33+
release-snapshot: go-generate ; $(info $(M) building snapshot release $*)
3934
goreleaser --verbose=$(GORELEASER_VERBOSE) \
4035
release \
4136
--snapshot \

test/e2e/config/caren.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ managementClusterName: caren-e2e
66
images:
77
- name: ko.local/cluster-api-runtime-extensions-nutanix:${E2E_IMAGE_TAG}
88
loadBehavior: mustLoad
9-
- name: ghcr.io/nutanix-cloud-native/caren-helm-reg:${E2E_IMAGE_TAG}
9+
- name: ghcr.io/nutanix-cloud-native/caren-helm-reg:${E2E_IMAGE_TAG}-${GOARCH}
1010
loadBehavior: mustLoad
1111

1212
providers:

0 commit comments

Comments
 (0)