Skip to content

Commit e13c1e5

Browse files
authored
Merge pull request #9288 from killianmuldoon/pr-remove-go-vcs-dep
⚠️ : Remove go-vcs dependency from releaselink tool
2 parents c074408 + 2c38961 commit e13c1e5

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

docs/book/src/developer/providers/migrations/v1.5-to-v1.6.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ maintainers of providers and consumers of our Go API.
3333

3434
### Other
3535
- `clusterctl move` can be blocked temporarily by a provider when an object to be moved is annotated with `clusterctl.cluster.x-k8s.io/block-move`.
36-
36+
- `mdbook releaselink` has been changed to require a `repo` tag when used in markdown files for generating a book with `mdbook`.
3737

3838
### Suggested changes for providers
3939

docs/book/src/user/quick-start.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,17 @@ If you are unsure you can determine your computers architecture by running `unam
161161
162162
Download for AMD64:
163163
```bash
164-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-amd64" version:"1.5.x"}} -o clusterctl
164+
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
165165
```
166166
167167
Download for ARM64:
168168
```bash
169-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-arm64" version:"1.5.x"}} -o clusterctl
169+
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
170170
```
171171
172172
Download for PPC64LE:
173173
```bash
174-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-linux-ppc64le" version:"1.5.x"}} -o clusterctl
174+
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
175175
```
176176
177177
Install clusterctl:
@@ -191,12 +191,12 @@ If you are unsure you can determine your computers architecture by running `unam
191191
192192
Download for AMD64:
193193
```bash
194-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-amd64" version:"1.5.x"}} -o clusterctl
194+
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
195195
```
196196
197197
Download for M1 CPU ("Apple Silicon") / ARM64:
198198
```bash
199-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-darwin-arm64" version:"1.5.x"}} -o clusterctl
199+
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
200200
```
201201
202202
Make the clusterctl binary executable.
@@ -235,7 +235,7 @@ Go to the working directory where you want clusterctl downloaded.
235235
236236
Download the latest release; on Windows, type:
237237
```powershell
238-
curl.exe -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api" asset:"clusterctl-windows-amd64.exe" version:"1.5.x"}} -o clusterctl.exe
238+
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
239239
```
240240
Append or prepend the path of that directory to the `PATH` environment variable.
241241
@@ -281,7 +281,7 @@ Download the latest binary of `clusterawsadm` from the [AWS provider releases].
281281
282282
Download the latest release; on Linux, type:
283283
```
284-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-linux-amd64" version:">=2.0.0"}} -o clusterawsadm
284+
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
285285
```
286286
287287
Make it executable
@@ -325,12 +325,12 @@ clusterctl init --infrastructure aws
325325
326326
Download the latest release; on macOs, type:
327327
```
328-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-amd64" version:">=2.0.0"}} -o clusterawsadm
328+
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
329329
```
330330
331331
Or if your Mac has an M1 CPU (”Apple Silicon”):
332332
```
333-
curl -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-darwin-arm64" version:">=2.0.0"}} -o clusterawsadm
333+
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
334334
```
335335
336336
Make it executable
@@ -407,7 +407,7 @@ clusterctl init --infrastructure aws
407407
408408
Download the latest release; on Windows, type:
409409
```
410-
curl.exe -L {{#releaselink gomodule:"sigs.k8s.io/cluster-api-provider-aws" asset:"clusterawsadm-windows-amd64" version:">=2.0.0"}} -o clusterawsadm.exe
410+
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
411411
```
412412
413413
Append or prepend the path of that directory to the `PATH` environment variable.

hack/tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ require (
1212
github.com/pkg/errors v0.9.1
1313
github.com/spf13/pflag v1.0.5
1414
github.com/valyala/fastjson v1.6.4
15-
golang.org/x/tools v0.9.3
1615
google.golang.org/api v0.138.0
1716
k8s.io/api v0.28.0
1817
k8s.io/apiextensions-apiserver v0.28.0
@@ -118,6 +117,7 @@ require (
118117
golang.org/x/term v0.11.0 // indirect
119118
golang.org/x/text v0.12.0 // indirect
120119
golang.org/x/time v0.3.0 // indirect
120+
golang.org/x/tools v0.9.3 // indirect
121121
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
122122
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
123123
google.golang.org/appengine v1.6.7 // indirect

hack/tools/mdbook/releaselink/releaselink.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"strings"
3030

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

3534
"sigs.k8s.io/cluster-api/internal/goproxy"
@@ -49,10 +48,19 @@ func (ReleaseLink) SupportsOutput(_ string) bool { return true }
4948
// Process modifies the book in the input, which gets returned as the result of the plugin.
5049
func (l ReleaseLink) Process(input *plugin.Input) error {
5150
return plugin.EachCommand(&input.Book, "releaselink", func(chapter *plugin.BookChapter, args string) (string, error) {
52-
tags := reflect.StructTag(strings.TrimSpace(args))
51+
var gomodule, asset, repo string
52+
var found bool
5353

54-
gomodule := tags.Get("gomodule")
55-
asset := tags.Get("asset")
54+
tags := reflect.StructTag(strings.TrimSpace(args))
55+
if gomodule, found = tags.Lookup("gomodule"); !found {
56+
return "", fmt.Errorf("releaselink requires tag \"gomodule\" to be set")
57+
}
58+
if asset, found = tags.Lookup("asset"); !found {
59+
return "", fmt.Errorf("releaselink requires tag \"asset\" to be set")
60+
}
61+
if repo, found = tags.Lookup("repo"); !found {
62+
return "", fmt.Errorf("releaselink requires tag \"repo\" to be set")
63+
}
5664
versionRange := semver.MustParseRange(tags.Get("version"))
5765
includePrereleases := tags.Get("prereleases") == "true"
5866

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

6775
goproxyClient := goproxy.NewClient(scheme, host)
6876

69-
repo, err := vcs.RepoRootForImportPath(gomodule, false)
70-
if err != nil {
71-
return "", err
72-
}
73-
7477
parsedTags, err := goproxyClient.GetVersions(context.Background(), gomodule)
7578
if err != nil {
7679
return "", err
@@ -86,7 +89,7 @@ func (l ReleaseLink) Process(input *plugin.Input) error {
8689
}
8790
}
8891

89-
return fmt.Sprintf("%s/releases/download/v%s/%s", repo.Repo, picked, asset), nil
92+
return fmt.Sprintf("%s/releases/download/v%s/%s", repo, picked, asset), nil
9093
})
9194
}
9295

0 commit comments

Comments
 (0)