Skip to content

Commit e6f1925

Browse files
authored
Merge pull request #680 from jetstack/makefile-modules-govulncheck
fix: manual makefile modules upgrade for govulncheck
2 parents 342c0e3 + 7b8fe70 commit e6f1925

File tree

9 files changed

+160
-139
lines changed

9 files changed

+160
-139
lines changed

.github/workflows/govulncheck.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
govulncheck:
1818
runs-on: ubuntu-latest
1919

20-
if: github.repository_owner == 'cert-manager'
20+
if: github.repository_owner == 'jetstack'
2121

2222
steps:
2323
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

klone.yaml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,55 +10,55 @@ targets:
1010
- folder_name: generate-verify
1111
repo_url: https://github.com/cert-manager/makefile-modules.git
1212
repo_ref: main
13-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
13+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
1414
repo_path: modules/generate-verify
1515
- folder_name: go
1616
repo_url: https://github.com/cert-manager/makefile-modules.git
1717
repo_ref: main
18-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
18+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
1919
repo_path: modules/go
2020
- folder_name: helm
2121
repo_url: https://github.com/cert-manager/makefile-modules.git
2222
repo_ref: main
23-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
23+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
2424
repo_path: modules/helm
2525
- folder_name: help
2626
repo_url: https://github.com/cert-manager/makefile-modules.git
2727
repo_ref: main
28-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
28+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
2929
repo_path: modules/help
3030
- folder_name: kind
3131
repo_url: https://github.com/cert-manager/makefile-modules.git
3232
repo_ref: main
33-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
33+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
3434
repo_path: modules/kind
3535
- folder_name: klone
3636
repo_url: https://github.com/cert-manager/makefile-modules.git
3737
repo_ref: main
38-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
38+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
3939
repo_path: modules/klone
4040
- folder_name: licenses
4141
repo_url: https://github.com/cert-manager/makefile-modules.git
4242
repo_ref: main
43-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
43+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
4444
repo_path: modules/licenses
4545
- folder_name: oci-build
4646
repo_url: https://github.com/cert-manager/makefile-modules.git
4747
repo_ref: main
48-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
48+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
4949
repo_path: modules/oci-build
5050
- folder_name: oci-publish
5151
repo_url: https://github.com/cert-manager/makefile-modules.git
5252
repo_ref: main
53-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
53+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
5454
repo_path: modules/oci-publish
5555
- folder_name: repository-base
5656
repo_url: https://github.com/cert-manager/makefile-modules.git
5757
repo_ref: main
58-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
58+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
5959
repo_path: modules/repository-base
6060
- folder_name: tools
6161
repo_url: https://github.com/cert-manager/makefile-modules.git
6262
repo_ref: main
63-
repo_hash: 2a0b032b3a629076796e8760c59c29428c60ce0d
63+
repo_hash: 684d99b0a6378fb3625c188bc5a0081ae9d2bbdc
6464
repo_path: modules/tools

make/00_mod.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ helm_chart_image_name := quay.io/jetstack/charts/venafi-kubernetes-agent
4242
helm_chart_version := $(VERSION)
4343
helm_labels_template_name := preflight.labels
4444

45+
govulncheck_generate_org := jetstack
46+
4547
# Allows us to replace the Helm values.yaml's image.repository and image.tag
4648
# with the right values.
4749
define helm_values_mutation_function

make/_shared/go/01_mod.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,16 @@ default_govulncheck_generate_base_dir := $(dir $(lastword $(MAKEFILE_LIST)))/bas
6363
# pipeline (eg. a GitLab pipeline).
6464
govulncheck_generate_base_dir ?= $(default_govulncheck_generate_base_dir)
6565

66+
# The org name used in the govulncheck GH action. This is used to prevent the govulncheck job
67+
# being run on every fork of the repo.
68+
govulncheck_generate_org ?= cert-manager
69+
6670
.PHONY: generate-govulncheck
6771
## Generate base files in the repository
6872
## @category [shared] Generate/ Verify
6973
generate-govulncheck:
70-
cp -r $(govulncheck_generate_base_dir)/. ./
74+
@mkdir -p ./.github/workflows
75+
sed 's/ORGNAMEHERE/$(govulncheck_generate_org)/g' $(govulncheck_generate_base_dir)/.github/workflows/govulncheck.yaml > .github/workflows/govulncheck.yaml
7176

7277
shared_generate_targets += generate-govulncheck
7378

make/_shared/go/base/.github/workflows/govulncheck.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
govulncheck:
1818
runs-on: ubuntu-latest
1919

20-
if: github.repository_owner == 'cert-manager'
20+
if: github.repository_owner == 'ORGNAMEHERE'
2121

2222
steps:
2323
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{- end }}
1+
{{- end }}

make/_shared/helm/crd.template.header.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ metadata:
88
helm.sh/resource-policy: keep
99
{{- end }}
1010
labels:
11-
{{- include "REPLACE_LABELS_TEMPLATE" . | nindent 4 }}
11+
{{- include "REPLACE_LABELS_TEMPLATE" . | nindent 4 }}

make/_shared/helm/crds.mk

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ endif
4040
crds_dir ?= deploy/crds
4141
crds_dir_readme := $(dir $(lastword $(MAKEFILE_LIST)))/crds_dir.README.md
4242
crds_expression ?= .Values.crds.enabled
43+
crds_template_include_pattern := *.yaml
44+
# Space-separated list of basenames to exclude (e.g. foo.yaml *_test.yaml)
45+
crds_template_exclude_pattern ?=
46+
47+
define filter-out-basenames
48+
$(if $(strip $(2)), \
49+
$(foreach f,$(1),$(if $(filter $(2),$(notdir $(f))),,$(f))), \
50+
$(1))
51+
endef
4352

4453
.PHONY: generate-crds
4554
## Generate CRD manifests.
@@ -57,15 +66,20 @@ generate-crds: | $(NEEDS_CONTROLLER-GEN) $(NEEDS_YQ)
5766

5867
@echo "Updating CRDs with helm templating, writing to $(helm_chart_source_dir)/templates"
5968

60-
@for i in $$(ls $(crds_gen_temp)); do \
61-
crd_name=$$($(YQ) eval '.metadata.name' $(crds_gen_temp)/$$i); \
62-
cat $(crd_template_header) > $(helm_chart_source_dir)/templates/crd-$$i; \
63-
echo "" >> $(helm_chart_source_dir)/templates/crd-$$i; \
64-
$(sed_inplace) "s/REPLACE_CRD_EXPRESSION/$(crds_expression)/g" $(helm_chart_source_dir)/templates/crd-$$i; \
65-
$(sed_inplace) "s/REPLACE_CRD_NAME/$$crd_name/g" $(helm_chart_source_dir)/templates/crd-$$i; \
66-
$(sed_inplace) "s/REPLACE_LABELS_TEMPLATE/$(helm_labels_template_name)/g" $(helm_chart_source_dir)/templates/crd-$$i; \
67-
$(YQ) -I2 '{"spec": .spec}' $(crds_gen_temp)/$$i >> $(helm_chart_source_dir)/templates/crd-$$i; \
68-
cat $(crd_template_footer) >> $(helm_chart_source_dir)/templates/crd-$$i; \
69+
$(eval crds_gen_temp_all_files := $(wildcard $(crds_gen_temp)/$(crds_template_include_pattern)))
70+
$(eval crds_gen_temp_files := $(if $(crds_template_exclude_pattern), \
71+
$(call filter-out-basenames,$(crds_gen_temp_all_files),$(crds_template_exclude_pattern)), \
72+
$(crds_gen_temp_all_files)))
73+
74+
@for f in $(crds_gen_temp_files); do \
75+
crd_name=$$($(YQ) eval '.metadata.name' $$f); \
76+
crd_template_file="$(helm_chart_source_dir)/templates/crd-$$(basename $$f)"; \
77+
cat $(crd_template_header) > $$crd_template_file; \
78+
$(sed_inplace) "s/REPLACE_CRD_EXPRESSION/$(crds_expression)/g" $$crd_template_file; \
79+
$(sed_inplace) "s/REPLACE_CRD_NAME/$$crd_name/g" $$crd_template_file; \
80+
$(sed_inplace) "s/REPLACE_LABELS_TEMPLATE/$(helm_labels_template_name)/g" $$crd_template_file; \
81+
$(YQ) -I2 '{"spec": .spec}' $$f >> $$crd_template_file; \
82+
cat $(crd_template_footer) >> $$crd_template_file; \
6983
done
7084

7185
@if [ -n "$$(ls $(crds_gen_temp) 2>/dev/null)" ]; then \

0 commit comments

Comments
 (0)