Skip to content

Commit 7dfe3b0

Browse files
committed
add tb.reset task
1 parent 26ff1dc commit 7dfe3b0

8 files changed

+44
-20
lines changed

.toolbox.mk

+7-3
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,20 @@ tb.semver: $(TB_SEMVER) ## Download semver locally if necessary.
5454
$(TB_SEMVER): $(TB_LOCALBIN)
5555
test -s $(TB_LOCALBIN)/semver || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/semver@$(TB_SEMVER_VERSION)
5656

57-
## Update Tools
58-
.PHONY: tb.update
59-
tb.update:
57+
## Reset Tools
58+
.PHONY: tb.reset
59+
tb.reset:
6060
@rm -f \
6161
$(TB_LOCALBIN)/deepcopy-gen \
6262
$(TB_LOCALBIN)/ginkgo \
6363
$(TB_LOCALBIN)/golangci-lint \
6464
$(TB_LOCALBIN)/goreleaser \
6565
$(TB_LOCALBIN)/oapi-codegen \
6666
$(TB_LOCALBIN)/semver
67+
68+
## Update Tools
69+
.PHONY: tb.update
70+
tb.update: tb.reset
6771
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \
6872
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator \
6973
github.com/golangci/golangci-lint/cmd/golangci-lint \

pkg/makefile/Makefile.tpl pkg/makefile/.toolbox.mk.tpl

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ $(TB_{{.UpperName}}): $(TB_LOCALBIN)
3232
test -s $(TB_LOCALBIN)/{{.Name}} || GOBIN=$(TB_LOCALBIN) go install {{.ToolName}}{{- if .Version }}@$(TB_{{.UpperName}}_VERSION){{- end }}
3333
{{- end }}
3434

35-
## Update Tools
36-
.PHONY: tb.update
37-
tb.update:
35+
## Reset Tools
36+
.PHONY: tb.reset
37+
tb.reset:
3838
@rm -f{{- range .Tools }} \
3939
$(TB_LOCALBIN)/{{.Name}}
4040
{{- end }}
41+
42+
## Update Tools
43+
.PHONY: tb.update
44+
tb.update: tb.reset
4145
toolbox makefile {{ if $.Renovate }}--renovate {{ end }}-f $(TB_LOCALDIR)/Makefile{{- range .Tools }}{{- if not .FromToolsGo }} \
4246
{{.Tool}}{{- end }}
4347
{{- end }}

pkg/makefile/consts.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
)
1313

1414
var (
15-
//go:embed Makefile.tpl
15+
//go:embed .toolbox.mk.tpl
1616
tpl string
1717
makefileTemplate = fmt.Sprintf("%s\n%s%s", markerStart, tpl, markerEnd)
1818
)

pkg/makefile/make.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func generate(client *resty.Client, makefile string, renovate bool, argTools []s
4646
}
4747

4848
out := &bytes.Buffer{}
49-
t := template.Must(template.New("Makefile").Parse(makefileTemplate))
49+
t := template.Must(template.New("toolbox.mk").Parse(makefileTemplate))
5050
if err := t.Execute(out, map[string]interface{}{
5151
"Tools": toolData,
5252
"WithVersions": withVersions,

testdata/.toolbox.mk.content.expected

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
3232
$(TB_TOOLBOX): $(TB_LOCALBIN)
3333
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)
3434

35-
## Update Tools
36-
.PHONY: tb.update
37-
tb.update:
35+
## Reset Tools
36+
.PHONY: tb.reset
37+
tb.reset:
3838
@rm -f \
3939
$(TB_LOCALBIN)/controller-gen \
4040
$(TB_LOCALBIN)/semver \
4141
$(TB_LOCALBIN)/toolbox
42+
43+
## Update Tools
44+
.PHONY: tb.update
45+
tb.update: tb.reset
4246
toolbox makefile -f $(TB_LOCALDIR)/Makefile \
4347
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
4448
github.com/bakito/semver \

testdata/.toolbox.mk.hybrid.expected

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
3131
$(TB_TOOLBOX): $(TB_LOCALBIN)
3232
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)
3333

34-
## Update Tools
35-
.PHONY: tb.update
36-
tb.update:
34+
## Reset Tools
35+
.PHONY: tb.reset
36+
tb.reset:
3737
@rm -f \
3838
$(TB_LOCALBIN)/controller-gen \
3939
$(TB_LOCALBIN)/semver \
4040
$(TB_LOCALBIN)/toolbox
41+
42+
## Update Tools
43+
.PHONY: tb.update
44+
tb.update: tb.reset
4145
toolbox makefile -f $(TB_LOCALDIR)/Makefile \
4246
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
4347
github.com/bakito/toolbox

testdata/.toolbox.mk.renovate.expected

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
3535
$(TB_TOOLBOX): $(TB_LOCALBIN)
3636
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)
3737

38-
## Update Tools
39-
.PHONY: tb.update
40-
tb.update:
38+
## Reset Tools
39+
.PHONY: tb.reset
40+
tb.reset:
4141
@rm -f \
4242
$(TB_LOCALBIN)/controller-gen \
4343
$(TB_LOCALBIN)/semver \
4444
$(TB_LOCALBIN)/toolbox
45+
46+
## Update Tools
47+
.PHONY: tb.update
48+
tb.update: tb.reset
4549
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \
4650
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
4751
github.com/bakito/semver \

testdata/.toolbox.mk.tools.go.expected

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
2727
$(TB_TOOLBOX): $(TB_LOCALBIN)
2828
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox
2929

30-
## Update Tools
31-
.PHONY: tb.update
32-
tb.update:
30+
## Reset Tools
31+
.PHONY: tb.reset
32+
tb.reset:
3333
@rm -f \
3434
$(TB_LOCALBIN)/controller-gen \
3535
$(TB_LOCALBIN)/semver \
3636
$(TB_LOCALBIN)/toolbox
37+
38+
## Update Tools
39+
.PHONY: tb.update
40+
tb.update: tb.reset
3741
toolbox makefile -f $(TB_LOCALDIR)/Makefile
3842
## toolbox - end

0 commit comments

Comments
 (0)