Skip to content

Commit 09f7d3f

Browse files
committed
Add makefile-modules
1 parent 42ec40d commit 09f7d3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1568
-698
lines changed

.github/workflows/govulncheck.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
2+
# Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/go/base/.github/workflows/govulncheck.yaml instead.
3+
4+
# Run govulncheck at midnight every night on the main branch,
5+
# to alert us to recent vulnerabilities which affect the Go code in this
6+
# project.
7+
name: govulncheck
8+
on:
9+
workflow_dispatch: {}
10+
schedule:
11+
- cron: '0 0 * * *'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
govulncheck:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
22+
# Adding `fetch-depth: 0` makes sure tags are also fetched. We need
23+
# the tags so `git describe` returns a valid version.
24+
# see https://github.com/actions/checkout/issues/701 for extra info about this option
25+
with: { fetch-depth: 0 }
26+
27+
- id: go-version
28+
run: |
29+
make print-go-version >> "$GITHUB_OUTPUT"
30+
31+
- uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
32+
with:
33+
go-version: ${{ steps.go-version.outputs.result }}
34+
35+
- run: make verify-govulncheck

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/bin
22
coverage.out
33
.debug
4+
_bin
5+
.vscode

.golangci.yaml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
exclusions:
5+
generated: lax
6+
presets: [comments, common-false-positives, legacy, std-error-handling]
7+
rules:
8+
- linters:
9+
- gomoddirectives
10+
- promlinter
11+
text: .*
12+
paths: [third_party$, builtin$, examples$]
13+
warn-unused: true
14+
settings:
15+
staticcheck:
16+
checks: ["all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1003", "-QF1008"]
17+
enable:
18+
- asasalint
19+
- asciicheck
20+
- bidichk
21+
- bodyclose
22+
- canonicalheader
23+
- contextcheck
24+
- copyloopvar
25+
- decorder
26+
- dogsled
27+
- dupword
28+
- durationcheck
29+
- errcheck
30+
- errchkjson
31+
- errname
32+
- exhaustive
33+
- exptostd
34+
- forbidigo
35+
- ginkgolinter
36+
- gocheckcompilerdirectives
37+
- gochecksumtype
38+
- gocritic
39+
- goheader
40+
- goprintffuncname
41+
- gosec
42+
- gosmopolitan
43+
- govet
44+
- grouper
45+
- importas
46+
- ineffassign
47+
- interfacebloat
48+
- intrange
49+
- loggercheck
50+
- makezero
51+
- mirror
52+
- misspell
53+
- musttag
54+
- nakedret
55+
- nilerr
56+
- nilnil
57+
- noctx
58+
- nosprintfhostport
59+
- predeclared
60+
- promlinter
61+
- protogetter
62+
- reassign
63+
- sloglint
64+
- staticcheck
65+
- tagalign
66+
- testableexamples
67+
- unconvert
68+
- unparam
69+
- unused
70+
- usestdlibvars
71+
- usetesting
72+
- wastedassign
73+
formatters:
74+
enable: [gci, gofmt]
75+
settings:
76+
gci:
77+
sections:
78+
- standard # Standard section: captures all standard packages.
79+
- default # Default section: contains all imports that could not be matched to another section type.
80+
- prefix(github.com/jetstack/version-checker) # Custom section: groups all imports with the specified Prefix.
81+
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
82+
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
83+
exclusions:
84+
generated: lax
85+
paths: [third_party$, builtin$, examples$]

Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
##################################
3131

3232
# Some modules build their dependencies from variables, we want these to be
33-
# evalutated at the last possible moment. For this we use second expansion to
33+
# evaluated at the last possible moment. For this we use second expansion to
3434
# re-evaluate the generate and verify targets a second time.
3535
#
3636
# See https://www.gnu.org/software/make/manual/html_node/Secondary-Expansion.html
@@ -52,10 +52,6 @@ noop: # do nothing
5252
# warning from happening when running make without arguments
5353
MAKECMDGOALS ?=
5454

55-
image: ## build docker image
56-
GOARCH=$(ARCH) GOOS=linux CGO_ENABLED=0 go build -o ./bin/version-checker-linux ./cmd/.
57-
docker build -t quay.io/jetstack/version-checker:v0.9.0 .
58-
5955
##################################
6056
# Host OS and architecture setup #
6157
##################################

deploy/charts/version-checker/values.linter.exceptions

Whitespace-only changes.

go.mod

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@ require (
4040
github.com/google/go-github/v70 v70.0.0
4141
github.com/hashicorp/go-cleanhttp v0.5.2
4242
github.com/jarcoal/httpmock v1.3.1
43+
github.com/onsi/ginkgo/v2 v2.22.0
44+
github.com/onsi/gomega v1.36.1
4345
github.com/patrickmn/go-cache v2.1.0+incompatible
4446
github.com/stretchr/testify v1.10.0
4547
sigs.k8s.io/controller-runtime v0.20.4
46-
github.com/onsi/ginkgo/v2 v2.19.0
47-
github.com/onsi/gomega v1.33.1
4848
)
4949

50-
require github.com/itchyny/timefmt-go v0.1.6 // indirect
50+
require (
51+
github.com/itchyny/timefmt-go v0.1.6 // indirect
52+
golang.org/x/tools v0.29.0 // indirect
53+
)
5154

5255
require (
5356
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
@@ -91,13 +94,12 @@ require (
9194
github.com/google/gnostic-models v0.6.9 // indirect
9295
github.com/google/go-querystring v1.1.0 // indirect
9396
github.com/google/gofuzz v1.2.0 // indirect
94-
github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 // indirect
97+
github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db // indirect
9598
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
9699
github.com/google/uuid v1.6.0 // indirect
97100
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
98101
github.com/inconshreveable/mousetrap v1.1.0 // indirect
99102
github.com/itchyny/gojq v0.12.16
100-
github.com/jmespath/go-jmespath v0.4.0 // indirect
101103
github.com/josharian/intern v1.0.0 // indirect
102104
github.com/json-iterator/go v1.1.12 // indirect
103105
github.com/klauspost/compress v1.18.0 // indirect

klone.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This klone.yaml file describes the Makefile modules and versions that are
2+
# cloned into the "make/_shared" folder. These modules are dynamically imported
3+
# by the root Makefile. The "make upgrade-klone" target can be used to pull
4+
# the latest version from the upstream repositories (using the repo_ref value).
5+
#
6+
# More info can be found here: https://github.com/cert-manager/makefile-modules
7+
8+
targets:
9+
make/_shared:
10+
- folder_name: generate-verify
11+
repo_url: https://github.com/cert-manager/makefile-modules.git
12+
repo_ref: main
13+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
14+
repo_path: modules/generate-verify
15+
- folder_name: go
16+
repo_url: https://github.com/cert-manager/makefile-modules.git
17+
repo_ref: main
18+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
19+
repo_path: modules/go
20+
- folder_name: helm
21+
repo_url: https://github.com/cert-manager/makefile-modules.git
22+
repo_ref: main
23+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
24+
repo_path: modules/helm
25+
- folder_name: help
26+
repo_url: https://github.com/cert-manager/makefile-modules.git
27+
repo_ref: main
28+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
29+
repo_path: modules/help
30+
- folder_name: kind
31+
repo_url: https://github.com/cert-manager/makefile-modules.git
32+
repo_ref: main
33+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
34+
repo_path: modules/kind
35+
- folder_name: klone
36+
repo_url: https://github.com/cert-manager/makefile-modules.git
37+
repo_ref: main
38+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
39+
repo_path: modules/klone
40+
- folder_name: oci-build
41+
repo_url: https://github.com/cert-manager/makefile-modules.git
42+
repo_ref: main
43+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
44+
repo_path: modules/oci-build
45+
- folder_name: oci-publish
46+
repo_url: https://github.com/cert-manager/makefile-modules.git
47+
repo_ref: main
48+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
49+
repo_path: modules/oci-publish
50+
- folder_name: repository-base
51+
repo_url: https://github.com/cert-manager/makefile-modules.git
52+
repo_ref: main
53+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
54+
repo_path: modules/repository-base
55+
- folder_name: tools
56+
repo_url: https://github.com/cert-manager/makefile-modules.git
57+
repo_ref: main
58+
repo_hash: 9c9f116938e082201a6bae0aedc7c7cf525fd8bf
59+
repo_path: modules/tools

make/00_mod.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ deploy_name := version-checker
3232
deploy_namespace := version-checker
3333

3434
helm_chart_source_dir := deploy/charts/version-checker
35-
helm_chart_name := version-checker
35+
helm_chart_image_name := version-checker
3636
helm_chart_version := $(VERSION)
3737
helm_labels_template_name := version-checker.labels
3838
helm_docs_use_helm_tool := 1
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
shared_generate_targets ?=
16+
shared_generate_targets_dirty ?=
17+
shared_verify_targets ?=
18+
shared_verify_targets_dirty ?=
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2023 The cert-manager Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
.PHONY: generate
16+
## Generate all generate targets.
17+
## @category [shared] Generate/ Verify
18+
generate: $$(shared_generate_targets)
19+
@echo "The following targets cannot be run simultaneously with each other or other generate scripts:"
20+
$(foreach TARGET,$(shared_generate_targets_dirty), $(MAKE) $(TARGET))
21+
22+
verify_script := $(dir $(lastword $(MAKEFILE_LIST)))/util/verify.sh
23+
24+
# Run the supplied make target argument in a temporary workspace and diff the results.
25+
verify-%: FORCE
26+
+$(verify_script) $(MAKE) $*
27+
28+
verify_generated_targets = $(shared_generate_targets:%=verify-%)
29+
verify_generated_targets_dirty = $(shared_generate_targets_dirty:%=verify-%)
30+
31+
verify_targets = $(sort $(verify_generated_targets) $(shared_verify_targets))
32+
verify_targets_dirty = $(sort $(verify_generated_targets_dirty) $(shared_verify_targets_dirty))
33+
34+
.PHONY: verify
35+
## Verify code and generate targets.
36+
## @category [shared] Generate/ Verify
37+
verify: $$(verify_targets)
38+
@echo "The following targets create temporary files in the current directory, that is why they have to be run last:"
39+
$(foreach TARGET,$(verify_targets_dirty), $(MAKE) $(TARGET))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The cert-manager Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Verify that the supplied command does not make any changes to the repository.
18+
#
19+
# This is called from the Makefile to verify that all code generation scripts
20+
# have been run and that their changes have been committed to the repository.
21+
#
22+
# Runs any of the scripts or Make targets in this repository, after making a
23+
# copy of the repository, then reports any changes to the files in the copy.
24+
25+
# For example:
26+
#
27+
# make verify-helm-chart-update || \
28+
# make helm-chart-update
29+
#
30+
set -o errexit
31+
set -o nounset
32+
set -o pipefail
33+
34+
projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../.." && pwd )"
35+
36+
cd "${projectdir}"
37+
38+
# Use short form arguments here to support BSD/macOS. `-d` instructs
39+
# it to make a directory, `-t` provides a prefix to use for the directory name.
40+
tmp="$(mktemp -d /tmp/verify.sh.XXXXXXXX)"
41+
42+
cleanup() {
43+
rm -rf "${tmp}"
44+
}
45+
trap "cleanup" EXIT SIGINT
46+
47+
# Why not just "cp" to the tmp dir?
48+
# A dumb "cp" will fail sometimes since _bin can get changed while it's being copied if targets are run in parallel,
49+
# and cp doesn't have some universal "exclude" option to ignore "_bin"
50+
#
51+
# We previously used "rsync" here, but:
52+
# 1. That's another tool we need to depend on
53+
# 2. rsync on macOS 15.4 and newer is actually openrsync, which has different permissions and throws errors when copying git objects
54+
#
55+
# So, we use find to list all files except _bin, and then copy each in turn
56+
find . -maxdepth 1 -not \( -path "./_bin" \) -not \( -path "." \) | xargs -I% cp -af "${projectdir}/%" "${tmp}/"
57+
58+
pushd "${tmp}" >/dev/null
59+
60+
"$@"
61+
62+
popd >/dev/null
63+
64+
if ! diff \
65+
--exclude=".git" \
66+
--exclude="_bin" \
67+
--new-file --unified --show-c-function --recursive "${projectdir}" "${tmp}"
68+
then
69+
echo
70+
echo "Project '${projectdir}' is out of date."
71+
echo "Please run '${*}' or apply the above diffs"
72+
exit 1
73+
fi

0 commit comments

Comments
 (0)