Skip to content

Commit a8c2c1d

Browse files
authored
INBOX-3651: Update deps and fix tests (#66)
* INBOX-3651: Update deps, fix tests and modernise code * Update go.mod and sum with up to date deps * Make file, docs and main code changes * Update "works with" version
1 parent 76fff26 commit a8c2c1d

File tree

9 files changed

+500
-713
lines changed

9 files changed

+500
-713
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ _out
1919
# ignore our "real" test data
2020
testdata/ns1/api-key.yaml
2121
testdata/ns1/config.json
22+
23+
bin/

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.20.4-alpine AS build_deps
1+
FROM golang:1.25.7-alpine AS build_deps
22

33
RUN apk add --no-cache git
44

@@ -15,7 +15,7 @@ COPY . .
1515

1616
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o webhook -ldflags '-w -extldflags "-static"' .
1717

18-
FROM alpine:3.18
18+
FROM alpine:3.21
1919

2020
RUN apk add --no-cache ca-certificates
2121

Makefile

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,74 @@ rendered-manifest.yaml:
3636
--set image.repository=$(IMAGE_NAME) \
3737
--set image.tag=$(IMAGE_TAG) \
3838
deploy/$(IMAGE_NAME) > "$(OUT)/rendered-manifest.yaml"
39+
40+
41+
GO ?= $(shell which go)
42+
OS ?= $(shell $(GO) env GOOS)
43+
ARCH ?= $(shell $(GO) env GOARCH)
44+
ENVTEST_K8S_VERSION=1.35.0
45+
OUT := $(shell pwd)/_out
46+
47+
48+
test: setup-envtest
49+
TEST_ASSET_ETCD=$(LOCALBIN)/k8s/$(ENVTEST_K8S_VERSION)-$(OS)-$(ARCH)/etcd \
50+
TEST_ASSET_KUBE_APISERVER=$(LOCALBIN)/k8s/$(ENVTEST_K8S_VERSION)-$(OS)-$(ARCH)/kube-apiserver \
51+
TEST_ASSET_KUBECTL=$(LOCALBIN)/k8s/$(ENVTEST_K8S_VERSION)-$(OS)-$(ARCH)/kubectl \
52+
$(GO) test -v .
53+
54+
.PHONY: clean
55+
clean:
56+
chmod -R u+w $(LOCALBIN) $(OUT) 2>/dev/null || true
57+
rm -rf $(LOCALBIN) $(OUT)
58+
59+
## Location to install dependencies to
60+
LOCALBIN ?= $(shell pwd)/bin
61+
$(LOCALBIN):
62+
mkdir -p "$(LOCALBIN)"
63+
64+
## Tool Binaries
65+
66+
ENVTEST ?= $(LOCALBIN)/setup-envtest
67+
68+
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
69+
ENVTEST_VERSION ?= $(shell v='$(call gomodver,sigs.k8s.io/controller-runtime)'; \
70+
[ -n "$$v" ] || { echo "Set ENVTEST_VERSION manually (controller-runtime replace has no tag)" >&2; exit 1; }; \
71+
printf '%s\n' "$$v" | sed -E 's/^v?([0-9]+)\.([0-9]+).*/release-\1.\2/')
72+
73+
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
74+
ENVTEST_K8S_VERSION ?= $(shell v='$(call gomodver,k8s.io/api)'; \
75+
[ -n "$$v" ] || { echo "Set ENVTEST_K8S_VERSION manually (k8s.io/api replace has no tag)" >&2; exit 1; }; \
76+
printf '%s\n' "$$v" | sed -E 's/^v?[0-9]+\.([0-9]+).*/1.\1/')
77+
78+
.PHONY: setup-envtest
79+
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
80+
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
81+
@"$(ENVTEST)" use $(ENVTEST_K8S_VERSION) --bin-dir "$(LOCALBIN)" -p path || { \
82+
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
83+
exit 1; \
84+
}
85+
86+
.PHONY: envtest
87+
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
88+
$(ENVTEST): $(LOCALBIN)
89+
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))
90+
91+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
92+
# $1 - target path with name of binary
93+
# $2 - package url which can be installed
94+
# $3 - specific version of package
95+
define go-install-tool
96+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
97+
set -e; \
98+
package=$(2)@$(3) ;\
99+
echo "Downloading $${package}" ;\
100+
rm -f "$(1)" ;\
101+
GOBIN="$(LOCALBIN)" go install $${package} ;\
102+
mv "$(LOCALBIN)/$$(basename "$(1)")" "$(1)-$(3)" ;\
103+
} ;\
104+
ln -sf "$$(realpath "$(1)-$(3)")" "$(1)"
105+
endef
106+
107+
define gomodver
108+
$(shell go list -m -f '{{if .Replace}}{{.Replace.Version}}{{else}}{{.Version}}{{end}}' $(1) 2>/dev/null)
109+
endef

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Tested with helm v2.16.1 and v3.0.3
1616
[certmanager](https://cert-manager.io/docs/installation/kubernetes/), the
1717
underlying framework this project plugs into.
1818

19-
Tested with cert-manager v0.13.0 and v1.0.3
19+
Tested with cert-manager v1.19.3
2020

2121
## Installation
2222

@@ -242,18 +242,12 @@ The tests are "live" and require a functioning, DNS-accessible zone, as well as
242242
credentials for the NS1 API. The tests will create (and remove) a TXT record
243243
for the test zone.
244244

245-
1. Prepare testing environment by running the `fetch-test-binaries` script:
245+
1. See the `README` in `testdata/ns1` and copy/edit the files as needed.
246246

247-
```bash
248-
$ scripts/fetch-test-binaries.sh
249-
```
250-
251-
2. See the `README` in `testdata/ns1` and copy/edit the files as needed.
252-
253-
3. Run the tests with `TEST_ZONE_NAME` set to your live, NS1-controlled zone:
247+
2. Run the tests with `TEST_ZONE_NAME` set to your live, NS1-controlled zone:
254248

255249
```bash
256-
$ TEST_ZONE_NAME=example.com. go test .
250+
$ TEST_ZONE_NAME=example.com. make test
257251
```
258252

259253
### Maintaining the Docker image and Helm repository

go.mod

Lines changed: 107 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,120 @@
11
module github.com/ns1/cert-manager-webhook-ns1
22

3-
go 1.23.0
3+
go 1.25.0
44

55
require (
6-
github.com/jetstack/cert-manager v0.16.1
7-
gopkg.in/ns1/ns1-go.v2 v2.6.2
8-
k8s.io/apiextensions-apiserver v0.18.5
9-
k8s.io/apimachinery v0.18.14
10-
k8s.io/client-go v0.18.14
6+
github.com/cert-manager/cert-manager v1.19.3
7+
gopkg.in/ns1/ns1-go.v2 v2.17.2
8+
k8s.io/apiextensions-apiserver v0.35.1
9+
k8s.io/apimachinery v0.35.1
10+
k8s.io/client-go v0.35.1
1111
)
1212

1313
require (
14-
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 // indirect
15-
github.com/PuerkitoBio/purell v1.1.1 // indirect
16-
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
17-
github.com/beorn7/perks v1.0.0 // indirect
18-
github.com/blang/semver v3.5.0+incompatible // indirect
19-
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
20-
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
21-
github.com/davecgh/go-spew v1.1.1 // indirect
22-
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
23-
github.com/evanphx/json-patch v4.9.0+incompatible // indirect
24-
github.com/go-openapi/jsonpointer v0.19.3 // indirect
25-
github.com/go-openapi/jsonreference v0.19.3 // indirect
26-
github.com/go-openapi/spec v0.19.3 // indirect
27-
github.com/go-openapi/swag v0.19.5 // indirect
14+
cel.dev/expr v0.25.1 // indirect
15+
github.com/NYTimes/gziphandler v1.1.1 // indirect
16+
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
17+
github.com/beorn7/perks v1.0.1 // indirect
18+
github.com/blang/semver/v4 v4.0.0 // indirect
19+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
20+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
21+
github.com/coreos/go-semver v0.3.1 // indirect
22+
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
23+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
24+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
25+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
26+
github.com/felixge/httpsnoop v1.0.4 // indirect
27+
github.com/fsnotify/fsnotify v1.9.0 // indirect
28+
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
29+
github.com/go-logr/logr v1.4.3 // indirect
30+
github.com/go-logr/stdr v1.2.2 // indirect
31+
github.com/go-logr/zapr v1.3.0 // indirect
32+
github.com/go-openapi/jsonpointer v0.22.4 // indirect
33+
github.com/go-openapi/jsonreference v0.21.4 // indirect
34+
github.com/go-openapi/swag v0.25.4 // indirect
35+
github.com/go-openapi/swag/cmdutils v0.25.4 // indirect
36+
github.com/go-openapi/swag/conv v0.25.4 // indirect
37+
github.com/go-openapi/swag/fileutils v0.25.4 // indirect
38+
github.com/go-openapi/swag/jsonname v0.25.4 // indirect
39+
github.com/go-openapi/swag/jsonutils v0.25.4 // indirect
40+
github.com/go-openapi/swag/loading v0.25.4 // indirect
41+
github.com/go-openapi/swag/mangling v0.25.4 // indirect
42+
github.com/go-openapi/swag/netutils v0.25.4 // indirect
43+
github.com/go-openapi/swag/stringutils v0.25.4 // indirect
44+
github.com/go-openapi/swag/typeutils v0.25.4 // indirect
45+
github.com/go-openapi/swag/yamlutils v0.25.4 // indirect
2846
github.com/gogo/protobuf v1.3.2 // indirect
29-
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
30-
github.com/golang/protobuf v1.3.2 // indirect
31-
github.com/google/go-cmp v0.3.0 // indirect
32-
github.com/google/gofuzz v1.1.0 // indirect
33-
github.com/google/uuid v1.1.1 // indirect
34-
github.com/googleapis/gnostic v0.3.1 // indirect
47+
github.com/golang/protobuf v1.5.4 // indirect
48+
github.com/google/btree v1.1.3 // indirect
49+
github.com/google/cel-go v0.27.0 // indirect
50+
github.com/google/gnostic-models v0.7.1 // indirect
51+
github.com/google/go-cmp v0.7.0 // indirect
52+
github.com/google/uuid v1.6.0 // indirect
3553
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
36-
github.com/hashicorp/golang-lru v0.5.1 // indirect
37-
github.com/imdario/mergo v0.3.6 // indirect
38-
github.com/inconshreveable/mousetrap v1.0.0 // indirect
39-
github.com/json-iterator/go v1.1.8 // indirect
40-
github.com/mailru/easyjson v0.7.0 // indirect
41-
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
42-
github.com/miekg/dns v1.1.29 // indirect
54+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.28.0 // indirect
55+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
56+
github.com/json-iterator/go v1.1.12 // indirect
57+
github.com/kylelemons/godebug v1.1.0 // indirect
58+
github.com/miekg/dns v1.1.72 // indirect
4359
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
44-
github.com/modern-go/reflect2 v1.0.1 // indirect
60+
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
4561
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
46-
github.com/onsi/gomega v1.8.1 // indirect
47-
github.com/pkg/errors v0.9.1 // indirect
48-
github.com/prometheus/client_golang v1.0.0 // indirect
49-
github.com/prometheus/client_model v0.2.0 // indirect
50-
github.com/prometheus/common v0.4.1 // indirect
51-
github.com/prometheus/procfs v0.0.2 // indirect
52-
github.com/spf13/cobra v1.0.0 // indirect
53-
github.com/spf13/pflag v1.0.5 // indirect
54-
go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738 // indirect
55-
go.uber.org/atomic v1.4.0 // indirect
56-
go.uber.org/multierr v1.1.0 // indirect
57-
go.uber.org/zap v1.10.0 // indirect
58-
golang.org/x/crypto v0.36.0 // indirect
59-
golang.org/x/net v0.38.0 // indirect
60-
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect
61-
golang.org/x/sync v0.12.0 // indirect
62-
golang.org/x/sys v0.31.0 // indirect
63-
golang.org/x/term v0.30.0 // indirect
64-
golang.org/x/text v0.23.0 // indirect
65-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
66-
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
67-
google.golang.org/appengine v1.5.0 // indirect
68-
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
69-
google.golang.org/grpc v1.26.0 // indirect
62+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
63+
github.com/prometheus/client_golang v1.23.2 // indirect
64+
github.com/prometheus/client_model v0.6.2 // indirect
65+
github.com/prometheus/common v0.67.5 // indirect
66+
github.com/prometheus/procfs v0.19.2 // indirect
67+
github.com/spf13/cobra v1.10.2 // indirect
68+
github.com/spf13/pflag v1.0.10 // indirect
69+
github.com/x448/float16 v0.8.4 // indirect
70+
go.etcd.io/etcd/api/v3 v3.6.8 // indirect
71+
go.etcd.io/etcd/client/pkg/v3 v3.6.8 // indirect
72+
go.etcd.io/etcd/client/v3 v3.6.8 // indirect
73+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
74+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.65.0 // indirect
75+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.65.0 // indirect
76+
go.opentelemetry.io/otel v1.40.0 // indirect
77+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 // indirect
78+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.40.0 // indirect
79+
go.opentelemetry.io/otel/metric v1.40.0 // indirect
80+
go.opentelemetry.io/otel/sdk v1.40.0 // indirect
81+
go.opentelemetry.io/otel/trace v1.40.0 // indirect
82+
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
83+
go.uber.org/multierr v1.11.0 // indirect
84+
go.uber.org/zap v1.27.1 // indirect
85+
go.yaml.in/yaml/v2 v2.4.3 // indirect
86+
go.yaml.in/yaml/v3 v3.0.4 // indirect
87+
golang.org/x/crypto v0.48.0 // indirect
88+
golang.org/x/exp v0.0.0-20260218203240-3dfff04db8fa // indirect
89+
golang.org/x/mod v0.33.0 // indirect
90+
golang.org/x/net v0.50.0 // indirect
91+
golang.org/x/oauth2 v0.35.0 // indirect
92+
golang.org/x/sync v0.19.0 // indirect
93+
golang.org/x/sys v0.41.0 // indirect
94+
golang.org/x/term v0.40.0 // indirect
95+
golang.org/x/text v0.34.0 // indirect
96+
golang.org/x/time v0.14.0 // indirect
97+
golang.org/x/tools v0.42.0 // indirect
98+
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
99+
google.golang.org/genproto/googleapis/api v0.0.0-20260217215200-42d3e9bedb6d // indirect
100+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260217215200-42d3e9bedb6d // indirect
101+
google.golang.org/grpc v1.79.1 // indirect
102+
google.golang.org/protobuf v1.36.11 // indirect
103+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
70104
gopkg.in/inf.v0 v0.9.1 // indirect
71-
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
72-
gopkg.in/yaml.v2 v2.2.8 // indirect
73-
k8s.io/api v0.18.14 // indirect
74-
k8s.io/apiserver v0.18.5 // indirect
75-
k8s.io/component-base v0.18.5 // indirect
76-
k8s.io/klog v1.0.0 // indirect
77-
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 // indirect
78-
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 // indirect
79-
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.0.7 // indirect
80-
sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect
81-
sigs.k8s.io/testing_frameworks v0.1.2 // indirect
82-
sigs.k8s.io/yaml v1.2.0 // indirect
105+
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
106+
k8s.io/api v0.35.1 // indirect
107+
k8s.io/apiserver v0.35.1 // indirect
108+
k8s.io/component-base v0.35.1 // indirect
109+
k8s.io/klog/v2 v2.130.1 // indirect
110+
k8s.io/kms v0.35.1 // indirect
111+
k8s.io/kube-openapi v0.0.0-20260127142750-a19766b6e2d4 // indirect
112+
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect
113+
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 // indirect
114+
sigs.k8s.io/controller-runtime v0.23.1 // indirect
115+
sigs.k8s.io/gateway-api v1.4.1 // indirect
116+
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
117+
sigs.k8s.io/randfill v1.0.0 // indirect
118+
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
119+
sigs.k8s.io/yaml v1.6.0 // indirect
83120
)
84-
85-
replace github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.4

0 commit comments

Comments
 (0)