8000 rancher/gotools at main · dominictayloruk/rancher · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
 
 

gotools

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Gotools

This directory contains Go-based tools to use with go tool.

Each tool is within its own directory with its own go.mod file to avoid dependency conflicts.

Managing tools

Using a tool

go tool -modfile <path to modfile> <tool>

For example, to use controller-gen:

go tool -modfile gotools/controller-gen/go.mod controller-gen -h

Add a new tool

From repository root:

TOOLNAME=<tool name>
mkdir -p gotools/"$TOOLNAME"
go mod init -modfile=gotools/"$TOOLNAME"/go.mod github.com/rancher/rancher/gotools/"$TOOLNAME"
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod <module>@<version>

For example, controller-gen was added this way:

TOOLNAME=controller-gen
mkdir -p gotools/"$TOOLNAME"
go mod init -modfile=gotools/"$TOOLNAME"/go.mod github.com/rancher/rancher/gotools/"$TOOLNAME"
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.1

Update existing tool

From repository root:

TOOLNAME=<tool name>
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod <module>@<new version>

Some modfiles replace the deprecated gopkg.in/yaml.v2 and .v3 modules with the maintained go.yaml.in/yaml ones. Keep the replacement version different from the go.yaml.in/yaml version required by the modfile, otherwise Go rejects the same version for two module paths.

For example, to update controller-gen to v0.17.3:

TOOLNAME=controller-gen
go get -tool -modfile=gotools/"$TOOLNAME"/go.mod sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.3
0