Skip to content

Commit f7f4acd

Browse files
committed
Envtest Binary Version Manager Tool
This introduces an envtest binary manager tool. It can download binaries from GCS, list available versions, print out help for switching between them, and remove old ones. By default, it downloads binaries into an OS-specific cache directory, as per the OS's conventions, but this can be overridden.
1 parent 4aecab5 commit f7f4acd

File tree

9 files changed

+1410
-0
lines changed

9 files changed

+1410
-0
lines changed

tools/setup-envtest/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Envtest Binaries Manager
2+
3+
This is a small tool that manages binaries for envtest. It can be used to
4+
download new binaries, list currently installed and available ones, and
5+
clean up versions.
6+
7+
To use it, just go-install it on 1.16+ (it's a separate, self-contained
8+
module):
9+
10+
```shell
11+
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
12+
```
13+
14+
For full documentation, run it with the `--help` flag, but here are some
15+
examples:
16+
17+
```shell
18+
# download the latest envtest, and print out info about it
19+
setup-envtest fetch
20+
21+
# download the latest 1.19 envtest, and print out the path
22+
setup-envtest fetch -k '1.19.+' -p path
23+
24+
# switch to the most recent 1.21 envtest on disk
25+
source <(setup-envtest switch -k '1.21.*' -p env)
26+
27+
# list all available local versions for darwin/amd64
28+
setup-envtest list-installed --os darwin --arch amd64
29+
30+
# remove all 1.16 versions from disk
31+
setup-envtest cleanup -k '1.16.*'
32+
```
33+
34+
## Where does it put all those binaries?
35+
36+
By default, binaries are stored in an OS-specific cache directory, as per
37+
the OS's conventions (see Go's `os.UserCacheDir`).
38+
39+
For example, on Linux this is `$XDG_CACHE_DIR`, or just `~/.config` if
40+
that's unset.
41+
42+
There's an overall folder that holds all files, and inside that is
43+
a folder for each version/platform pair. The exact directory structure is
44+
not guarnateed, except that the leaf directory will contain the names
45+
expected by envtest. You should always use `setup-envtest fetch` or
46+
`setup-envtest switch` (generally with the `-p path` or `-p env` flags) to
47+
get the directory that you should use.

0 commit comments

Comments
 (0)