Skip to content

Commit 87b0139

Browse files
authored
Merge pull request #4520 from camilamacedo86/fix-doc-envtest-artefacts
📖 doc: update the Artifacts with the latest changes on the EnvTest Makefile target configurations
2 parents 2d657c5 + 02f8e8b commit 87b0139

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

docs/book/src/reference/artifacts.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,26 @@ The artefacts for [ENVTEST][env-test-doc] k8s `1.31` are exclusively available a
4545
You can refer to the Makefile of the Kubebuilder scaffold and observe that the envtest setup is consistently aligned across all controller-runtime releases. Starting from `release-0.19`, it is configured to automatically download the artefact from the correct location, **ensuring that kubebuilder users are not impacted.**
4646

4747
```shell
48-
ENVTEST_K8S_VERSION = 1.31.0
49-
ENVTEST_VERSION ?= release-0.19
48+
## Tool Binaries
49+
..
50+
ENVTEST ?= $(LOCALBIN)/setup-envtest
5051
...
52+
53+
## Tool Versions
54+
...
55+
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
56+
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
57+
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
58+
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
59+
...
60+
.PHONY: setup-envtest
61+
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
62+
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
63+
@$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \
64+
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
65+
exit 1; \
66+
}
67+
5168
.PHONY: envtest
5269
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
5370
$(ENVTEST): $(LOCALBIN)

docs/book/src/reference/envtest.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,29 @@ Installing the binaries is as a simple as running `make envtest`. `envtest` will
99
by default. `make test` is the one-stop shop for downloading the binaries, setting up the test environment, and running the tests.
1010

1111

12-
You can refer to the Makefile of the Kubebuilder scaffold and observe that the envtest setup is consistently aligned across all controller-runtime releases. Starting from `release-0.19`, it is configured to automatically download the artefact from the correct location, **ensuring that kubebuilder users are not impacted.**
12+
You can refer to the Makefile of the Kubebuilder scaffold and observe that the envtest setup is consistently aligned across all controller-runtime releases.Starting from `release-0.19`, it is configured to automatically download the artefact from the correct location, **ensuring that kubebuilder users are not impacted.**
1313

1414
```shell
15-
ENVTEST_K8S_VERSION = 1.31.0
16-
ENVTEST_VERSION ?= release-0.19
15+
## Tool Binaries
16+
..
17+
ENVTEST ?= $(LOCALBIN)/setup-envtest
1718
...
19+
20+
## Tool Versions
21+
...
22+
#ENVTEST_VERSION is the version of controller-runtime release branch to fetch the envtest setup script (i.e. release-0.20)
23+
ENVTEST_VERSION ?= $(shell go list -m -f "{{ .Version }}" sigs.k8s.io/controller-runtime | awk -F'[v.]' '{printf "release-%d.%d", $$2, $$3}')
24+
#ENVTEST_K8S_VERSION is the version of Kubernetes to use for setting up ENVTEST binaries (i.e. 1.31)
25+
ENVTEST_K8S_VERSION ?= $(shell go list -m -f "{{ .Version }}" k8s.io/api | awk -F'[v.]' '{printf "1.%d", $$3}')
26+
...
27+
.PHONY: setup-envtest
28+
setup-envtest: envtest ## Download the binaries required for ENVTEST in the local bin directory.
29+
@echo "Setting up envtest binaries for Kubernetes version $(ENVTEST_K8S_VERSION)..."
30+
@$(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path || { \
31+
echo "Error: Failed to set up envtest binaries for version $(ENVTEST_K8S_VERSION)."; \
32+
exit 1; \
33+
}
34+
1835
.PHONY: envtest
1936
envtest: $(ENVTEST) ## Download setup-envtest locally if necessary.
2037
$(ENVTEST): $(LOCALBIN)

0 commit comments

Comments
 (0)