Skip to content

Commit 1d96f63

Browse files
Merge pull request #347 from cert-manager/self-upgrade-main
[CI] Merge self-upgrade-main into main
2 parents 145e65b + 6174c2a commit 1d96f63

File tree

3 files changed

+52
-40
lines changed

3 files changed

+52
-40
lines changed

klone.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,60 @@ targets:
99
- folder_name: api-docs
1010
repo_url: https://github.com/cert-manager/makefile-modules.git
1111
repo_ref: main
12-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
12+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
1313
repo_path: modules/api-docs
1414
- folder_name: boilerplate
1515
repo_url: https://github.com/cert-manager/makefile-modules.git
1616
repo_ref: main
17-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
17+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
1818
repo_path: modules/boilerplate
1919
- folder_name: cert-manager
2020
repo_url: https://github.com/cert-manager/makefile-modules.git
2121
repo_ref: main
22-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
22+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
2323
repo_path: modules/cert-manager
2424
- folder_name: controller-gen
2525
repo_url: https://github.com/cert-manager/makefile-modules.git
2626
repo_ref: main
27-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
27+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
2828
repo_path: modules/controller-gen
2929
- folder_name: generate-verify
3030
repo_url: https://github.com/cert-manager/makefile-modules.git
3131
repo_ref: main
32-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
32+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
3333
repo_path: modules/generate-verify
3434
- folder_name: go
3535
repo_url: https://github.com/cert-manager/makefile-modules.git
3636
repo_ref: main
37-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
37+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
3838
repo_path: modules/go
3939
- folder_name: help
4040
repo_url: https://github.com/cert-manager/makefile-modules.git
4141
repo_ref: main
42-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
42+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
4343
repo_path: modules/help
4444
- folder_name: kind
4545
repo_url: https://github.com/cert-manager/makefile-modules.git
4646
repo_ref: main
47-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
47+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
4848
repo_path: modules/kind
4949
- folder_name: klone
5050
repo_url: https://github.com/cert-manager/makefile-modules.git
5151
repo_ref: main
52-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
52+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
5353
repo_path: modules/klone
5454
- folder_name: oci-build
5555
repo_url: https://github.com/cert-manager/makefile-modules.git
5656
repo_ref: main
57-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
57+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
5858
repo_path: modules/oci-build
5959
- folder_name: repository-base
6060
repo_url: https://github.com/cert-manager/makefile-modules.git
6161
repo_ref: main
62-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
62+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
6363
repo_path: modules/repository-base
6464
- folder_name: tools
6565
repo_url: https://github.com/cert-manager/makefile-modules.git
6666
repo_ref: main
67-
repo_hash: b28a6c7b188e2c3c6540779d4f036db4d54de9f1
67+
repo_hash: 737c51c1bf36dea15a7ef2bc5c070d09845530a2
6868
repo_path: modules/tools

make/_shared/oci-build/00_mod.mk

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
oci_platforms ?= linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le
16-
1715
# Use distroless as minimal base image to package the manager binary
1816
# To get latest SHA run "crane digest quay.io/jetstack/base-static:latest"
1917
base_image_static := quay.io/jetstack/base-static@sha256:1da2e7de36c9d7a1931d765e8054a3c9fe7ed5126bacf728bb7429e923386146
@@ -32,6 +30,7 @@ $(call fatal_if_undefined,build_names)
3230
# Set default config values
3331
CGO_ENABLED ?= 0
3432
GOEXPERIMENT ?= # empty by default
33+
oci_platforms ?= linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le
3534

3635
# Default variables per build_names entry
3736
#
@@ -40,6 +39,7 @@ define default_per_build_variables
4039
go_$1_cgo_enabled ?= $(CGO_ENABLED)
4140
go_$1_goexperiment ?= $(GOEXPERIMENT)
4241
go_$1_flags ?= -tags=
42+
oci_$1_platforms ?= $(oci_platforms)
4343
oci_$1_additional_layers ?=
4444
oci_$1_linux_capabilities ?=
4545
oci_$1_build_args ?=
@@ -105,17 +105,23 @@ ifneq ($(words $(oci_$1_image_name_development)),1)
105105
$$(error oci_$1_image_name_development "$(oci_$1_image_name_development)" should be a single image name)
106106
endif
107107

108+
# Validate that the build name does not end in __local
109+
ifeq ($(1:%__local=__local),__local)
110+
$$(error build_name "$1" SHOULD NOT end in __local)
111+
endif
108112
endef
109113

110114
$(foreach build_name,$(build_names),$(eval $(call check_per_build_variables,$(build_name))))
111115

112116
# Create variables holding targets
113117
#
114118
# We create the following targets for each $(build_names)
115-
# - oci-build-$(build_name) = build the oci directory
119+
# - oci-build-$(build_name) = build the oci directory (multi-arch)
120+
# - oci-build-$(build_name)__local = build the oci directory (local arch: linux/$(HOST_ARCH))
116121
# - oci-load-$(build_name) = load the image into docker using the oci_$(build_name)_image_name_development variable
117122
# - docker-tarball-$(build_name) = build a "docker load" compatible tarball of the image
118123
oci_build_targets := $(build_names:%=oci-build-%)
124+
oci_build_targets += $(build_names:%=oci-build-%__local)
119125
oci_load_targets := $(build_names:%=oci-load-%)
120126
docker_tarball_targets := $(build_names:%=docker-tarball-%)
121127

make/_shared/oci-build/01_mod.mk

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,54 @@ $(bin_dir)/scratch/image:
1717

1818
.PHONY: $(oci_build_targets)
1919
## Build the OCI image.
20+
## - oci-build-$(build_name) = build the oci directory (multi-arch)
21+
## - oci-build-$(build_name)__local = build the oci directory (local arch: linux/$(HOST_ARCH))
2022
## @category [shared] Build
2123
$(oci_build_targets): oci-build-%: | $(NEEDS_KO) $(NEEDS_GO) $(NEEDS_YQ) $(NEEDS_IMAGE-TOOL) $(bin_dir)/scratch/image
22-
rm -rf $(CURDIR)/$(oci_layout_path_$*)
24+
$(eval a := $(patsubst %__local,%,$*))
25+
$(eval is_local := $(if $(findstring $a__local,$*),true))
26+
$(eval layout_path := $(if $(is_local),$(oci_layout_path_$a).local,$(oci_layout_path_$a)))
27+
$(eval digest_path := $(if $(is_local),$(oci_digest_path_$a).local,$(oci_digest_path_$a)))
28+
29+
rm -rf $(CURDIR)/$(layout_path)
2330

2431
echo '{}' | \
25-
$(YQ) '.defaultBaseImage = "$(oci_$*_base_image)"' | \
26-
$(YQ) '.builds[0].id = "$*"' | \
27-
$(YQ) '.builds[0].dir = "$(go_$*_mod_dir)"' | \
28-
$(YQ) '.builds[0].main = "$(go_$*_main_dir)"' | \
29-
$(YQ) '.builds[0].env[0] = "CGO_ENABLED=$(go_$*_cgo_enabled)"' | \
30-
$(YQ) '.builds[0].env[1] = "GOEXPERIMENT=$(go_$*_goexperiment)"' | \
32+
$(YQ) '.defaultBaseImage = "$(oci_$a_base_image)"' | \
33+
$(YQ) '.builds[0].id = "$a"' | \
34+
$(YQ) '.builds[0].dir = "$(go_$a_mod_dir)"' | \
35+
$(YQ) '.builds[0].main = "$(go_$a_main_dir)"' | \
36+
$(YQ) '.builds[0].env[0] = "CGO_ENABLED=$(go_$a_cgo_enabled)"' | \
37+
$(YQ) '.builds[0].env[1] = "GOEXPERIMENT=$(go_$a_goexperiment)"' | \
3138
$(YQ) '.builds[0].ldflags[0] = "-s"' | \
3239
$(YQ) '.builds[0].ldflags[1] = "-w"' | \
3340
$(YQ) '.builds[0].ldflags[2] = "{{.Env.LDFLAGS}}"' | \
34-
$(YQ) '.builds[0].flags[0] = "$(go_$*_flags)"' | \
35-
$(YQ) '.builds[0].linux_capabilities = "$(oci_$*_linux_capabilities)"' \
36-
> $(CURDIR)/$(oci_layout_path_$*).ko_config.yaml
41+
$(YQ) '.builds[0].flags[0] = "$(go_$a_flags)"' | \
42+
$(YQ) '.builds[0].linux_capabilities = "$(oci_$a_linux_capabilities)"' \
43+
> $(CURDIR)/$(layout_path).ko_config.yaml
3744

3845
GOWORK=off \
39-
KO_DOCKER_REPO=$(oci_$*_image_name_development) \
46+
KO_DOCKER_REPO=$(oci_$a_image_name_development) \
4047
KOCACHE=$(CURDIR)/$(bin_dir)/scratch/image/ko_cache \
41-
KO_CONFIG_PATH=$(CURDIR)/$(oci_layout_path_$*).ko_config.yaml \
48+
KO_CONFIG_PATH=$(CURDIR)/$(layout_path).ko_config.yaml \
4249
SOURCE_DATE_EPOCH=$(GITEPOCH) \
4350
KO_GO_PATH=$(GO) \
44-
LDFLAGS="$(go_$*_ldflags)" \
45-
$(KO) build $(go_$*_mod_dir)/$(go_$*_main_dir) \
46-
--platform=$(oci_platforms) \
47-
$(oci_$*_build_args) \
48-
--oci-layout-path=$(oci_layout_path_$*) \
49-
--sbom-dir=$(CURDIR)/$(oci_layout_path_$*).sbom \
51+
LDFLAGS="$(go_$a_ldflags)" \
52+
$(KO) build $(go_$a_mod_dir)/$(go_$a_main_dir) \
53+
--platform=$(if $(is_local),linux/$(HOST_ARCH),$(oci_$a_platforms)) \
54+
$(oci_$a_build_args) \
55+
--oci-layout-path=$(layout_path) \
56+
--sbom-dir=$(CURDIR)/$(layout_path).sbom \
5057
--sbom=spdx \
5158
--push=false \
5259
--bare
5360

5461
$(IMAGE-TOOL) append-layers \
55-
$(CURDIR)/$(oci_layout_path_$*) \
56-
$(oci_$*_additional_layers)
62+
$(CURDIR)/$(layout_path) \
63+
$(oci_$a_additional_layers)
5764

5865
$(IMAGE-TOOL) list-digests \
59-
$(CURDIR)/$(oci_layout_path_$*) \
60-
> $(oci_digest_path_$*)
66+
$(CURDIR)/$(layout_path) \
67+
> $(digest_path)
6168

6269
# Only include the oci-load target if kind is provided by the kind makefile-module
6370
ifdef kind_cluster_name
@@ -72,6 +79,5 @@ endif
7279
## Build Docker tarball image for the local architecture
7380
## @category [shared] Build
7481
.PHONY: $(docker_tarball_targets)
75-
$(docker_tarball_targets): oci_platforms := "linux/$(HOST_ARCH)"
76-
$(docker_tarball_targets): docker-tarball-%: oci-build-% | $(NEEDS_GO) $(NEEDS_IMAGE-TOOL)
77-
$(IMAGE-TOOL) convert-to-docker-tar $(CURDIR)/$(oci_layout_path_$*) $(docker_tarball_path_$*) $(oci_$*_image_name_development):$(oci_$*_image_tag)
82+
$(docker_tarball_targets): docker-tarball-%: oci-build-%__local | $(NEEDS_GO) $(NEEDS_IMAGE-TOOL)
83+
$(IMAGE-TOOL) convert-to-docker-tar $(CURDIR)/$(oci_layout_path_$*).local $(docker_tarball_path_$*) $(oci_$*_image_name_development):$(oci_$*_image_tag)

0 commit comments

Comments
 (0)