Skip to content

Commit

Permalink
Remove go-vcs dependency from releaselink binary
Browse files Browse the repository at this point in the history
Signed-off-by: killianmuldoon <kmuldoon@vmware.com>
  • Loading branch information
killianmuldoon committed Aug 23, 2023
1 parent c074408 commit d10b3eb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 23 deletions.
20 changes: 10 additions & 10 deletions docs/book/src/user/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,17 @@ If you are unsure you can determine your computers architecture by running `unam
Download for AMD64:
```bash
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-amd64" version:"1.5.x"}} -o clusterctl
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-amd64" version:"1.5.x"}} -o clusterctl
```
Download for ARM64:
```bash
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-arm64" version:"1.5.x"}} -o clusterctl
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-arm64" version:"1.5.x"}} -o clusterctl
```
Download for PPC64LE:
```bash
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-ppc64le" version:"1.5.x"}} -o clusterctl
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-ppc64le" version:"1.5.x"}} -o clusterctl
```
Install clusterctl:
Expand All @@ -191,12 +191,12 @@ If you are unsure you can determine your computers architecture by running `unam
Download for AMD64:
```bash
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-amd64" version:"1.5.x"}} -o clusterctl
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-amd64" version:"1.5.x"}} -o clusterctl
```
Download for M1 CPU ("Apple Silicon") / ARM64:
```bash
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-arm64" version:"1.5.x"}} -o clusterctl
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-arm64" version:"1.5.x"}} -o clusterctl
```
Make the clusterctl binary executable.
Expand Down Expand Up @@ -235,7 +235,7 @@ Go to the working directory where you want clusterctl downloaded.
Download the latest release; on Windows, type:
```powershell
curl.exe -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-windows-amd64.exe" version:"1.5.x"}} -o clusterctl.exe
curl.exe -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-windows-amd64.exe" version:"1.5.x"}} -o clusterctl.exe
```
Append or prepend the path of that directory to the `PATH` environment variable.
Expand Down Expand Up @@ -281,7 +281,7 @@ Download the latest binary of `clusterawsadm` from the [AWS provider releases].
Download the latest release; on Linux, type:
```
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-linux-amd64" version:">=2.0.0"}} -o clusterawsadm
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-linux-amd64" version:">=2.0.0"}} -o clusterawsadm
```
Make it executable
Expand Down Expand Up @@ -325,12 +325,12 @@ clusterctl init --infrastructure aws
Download the latest release; on macOs, type:
```
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-amd64" version:">=2.0.0"}} -o clusterawsadm
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-amd64" version:">=2.0.0"}} -o clusterawsadm
```
Or if your Mac has an M1 CPU (”Apple Silicon”):
```
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-arm64" version:">=2.0.0"}} -o clusterawsadm
curl -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-arm64" version:">=2.0.0"}} -o clusterawsadm
```
Make it executable
Expand Down Expand Up @@ -407,7 +407,7 @@ clusterctl init --infrastructure aws
Download the latest release; on Windows, type:
```
curl.exe -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-windows-amd64" version:">=2.0.0"}} -o clusterawsadm.exe
curl.exe -L {{#releaselink repo:"https://github.com/kubernetes-sigs/cluster-api" gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-windows-amd64" version:">=2.0.0"}} -o clusterawsadm.exe
```
Append or prepend the path of that directory to the `PATH` environment variable.
Expand Down
2 changes: 1 addition & 1 deletion hack/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
github.com/valyala/fastjson v1.6.4
golang.org/x/tools v0.9.3
google.golang.org/api v0.138.0
k8s.io/api v0.28.0
k8s.io/apiextensions-apiserver v0.28.0
Expand Down Expand Up @@ -118,6 +117,7 @@ require (
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.9.3 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
Expand Down
25 changes: 16 additions & 9 deletions hack/tools/mdbook/releaselink/releaselink.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"strings"

"github.com/blang/semver/v4"
"golang.org/x/tools/go/vcs"
"sigs.k8s.io/kubebuilder/docs/book/utils/plugin"

"sigs.k8s.io/cluster-api/internal/goproxy"
Expand All @@ -49,10 +48,23 @@ func (ReleaseLink) SupportsOutput(_ string) bool { return true }
// Process modifies the book in the input, which gets returned as the result of the plugin.
func (l ReleaseLink) Process(input *plugin.Input) error {
return plugin.EachCommand(&input.Book, "releaselink", func(chapter *plugin.BookChapter, args string) (string, error) {
var gomodule, asset, repo string
var found bool

tags := reflect.StructTag(strings.TrimSpace(args))
if gomodule, found = tags.Lookup("gomodule"); !found {
return "", fmt.Errorf("releaselink requires tag \"gomodule\" to be set")

Check failure on line 57 in hack/tools/mdbook/releaselink/releaselink.go

View workflow job for this annotation

GitHub Actions / lint (hack/tools)

unnecessary trailing newline (whitespace)
}
if asset, found = tags.Lookup("asset"); !found {
return "", fmt.Errorf("releaselink requires tag \"asset\" to be set")

Check failure on line 61 in hack/tools/mdbook/releaselink/releaselink.go

View workflow job for this annotation

GitHub Actions / lint (hack/tools)

unnecessary trailing newline (whitespace)
}
if repo, found = tags.Lookup("repo"); !found {
return "", fmt.Errorf("releaselink requires tag \"repo\" to be set")

Check failure on line 65 in hack/tools/mdbook/releaselink/releaselink.go

View workflow job for this annotation

GitHub Actions / lint (hack/tools)

unnecessary trailing newline (whitespace)
}

gomodule := tags.Get("gomodule")
asset := tags.Get("asset")
versionRange := semver.MustParseRange(tags.Get("version"))
includePrereleases := tags.Get("prereleases") == "true"

Expand All @@ -66,11 +78,6 @@ func (l ReleaseLink) Process(input *plugin.Input) error {

goproxyClient := goproxy.NewClient(scheme, host)

repo, err := vcs.RepoRootForImportPath(gomodule, false)
if err != nil {
return "", err
}

parsedTags, err := goproxyClient.GetVersions(context.Background(), gomodule)
if err != nil {
return "", err
Expand All @@ -86,7 +93,7 @@ func (l ReleaseLink) Process(input *plugin.Input) error {
}
}

return fmt.Sprintf("%s/releases/download/v%s/%s", repo.Repo, picked, asset), nil
return fmt.Sprintf("%s/releases/download/v%s/%s", repo, picked, asset), nil
})
}

Expand Down
2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ require (
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions test/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down

0 comments on commit d10b3eb

Please sign in to comment.