Skip to content

Commit

Permalink
Envtest Binary Version Manager Tool
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DirectXMan12 committed Apr 21, 2021
1 parent 4aecab5 commit 6d4fed8
Show file tree
Hide file tree
Showing 9 changed files with 1,405 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tools/setup-envtest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Envtest Binaries Manager

This is a small tool that manages binaries for envtest. It can be used to
download new binaries, list currently installed and available ones, and
clean up versions.

To use it, just go-install it on 1.16+ (it's a separate, self-contained
module):

```shell
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
```

For full documentation, run it with the `--help` flag, but here are some
examples:

```shell
# download the latest envtest, and print out info about it
setup-envtest fetch

# download the latest 1.19 envtest, and print out the path
setup-envtest fetch -k '1.19.+' -p path

# switch to the most recent 1.21 envtest on disk
source <(setup-envtest switch -k '1.21.*' -p env)

# list all available local versions for darwin/amd64
setup-envtest list-installed --os darwin --arch amd64

# remove all 1.16 versions from disk
setup-envtest cleanup -k '1.16.*'
```

## Where does it put all those binaries?

By default, binaries are stored in an OS-specific cache directory, as per
the OS's conventions (see Go's `os.UserCacheDir`).

For example, on Linux this is `$XDG_CACHE_DIR`, or just `~/.config` if
that's unset.

There's an overall folder that holds all files, and inside that is
a folder for each version/platform pair. The exact directory structure is
not guarnateed, except that the leaf directory will contain the names
expected by envtest. You should always use `setup-envtest fetch` or
`setup-envtest switch` (generally with the `-p path` or `-p env` flags) to
get the directory that you should use.
Loading

0 comments on commit 6d4fed8

Please sign in to comment.