Skip to content

Commit

Permalink
add tb.reset task
Browse files Browse the repository at this point in the history
  • Loading branch information
bakito committed Sep 28, 2024
1 parent 26ff1dc commit 7dfe3b0
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 20 deletions.
10 changes: 7 additions & 3 deletions .toolbox.mk
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,20 @@ tb.semver: $(TB_SEMVER) ## Download semver locally if necessary.
$(TB_SEMVER): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/semver || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/semver@$(TB_SEMVER_VERSION)

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f \
$(TB_LOCALBIN)/deepcopy-gen \
$(TB_LOCALBIN)/ginkgo \
$(TB_LOCALBIN)/golangci-lint \
$(TB_LOCALBIN)/goreleaser \
$(TB_LOCALBIN)/oapi-codegen \
$(TB_LOCALBIN)/semver

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \
k8s.io/code-generator/cmd/deepcopy-gen@github.com/kubernetes/code-generator \
github.com/golangci/golangci-lint/cmd/golangci-lint \
Expand Down
10 changes: 7 additions & 3 deletions pkg/makefile/Makefile.tpl → pkg/makefile/.toolbox.mk.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ $(TB_{{.UpperName}}): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/{{.Name}} || GOBIN=$(TB_LOCALBIN) go install {{.ToolName}}{{- if .Version }}@$(TB_{{.UpperName}}_VERSION){{- end }}
{{- end }}

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f{{- range .Tools }} \
$(TB_LOCALBIN)/{{.Name}}
{{- end }}

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile {{ if $.Renovate }}--renovate {{ end }}-f $(TB_LOCALDIR)/Makefile{{- range .Tools }}{{- if not .FromToolsGo }} \
{{.Tool}}{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion pkg/makefile/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
)

var (
//go:embed Makefile.tpl
//go:embed .toolbox.mk.tpl
tpl string
makefileTemplate = fmt.Sprintf("%s\n%s%s", markerStart, tpl, markerEnd)
)
2 changes: 1 addition & 1 deletion pkg/makefile/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func generate(client *resty.Client, makefile string, renovate bool, argTools []s
}

out := &bytes.Buffer{}
t := template.Must(template.New("Makefile").Parse(makefileTemplate))
t := template.Must(template.New("toolbox.mk").Parse(makefileTemplate))
if err := t.Execute(out, map[string]interface{}{
"Tools": toolData,
"WithVersions": withVersions,
Expand Down
10 changes: 7 additions & 3 deletions testdata/.toolbox.mk.content.expected
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
$(TB_TOOLBOX): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f \
$(TB_LOCALBIN)/controller-gen \
$(TB_LOCALBIN)/semver \
$(TB_LOCALBIN)/toolbox

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile -f $(TB_LOCALDIR)/Makefile \
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
github.com/bakito/semver \
Expand Down
10 changes: 7 additions & 3 deletions testdata/.toolbox.mk.hybrid.expected
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
$(TB_TOOLBOX): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f \
$(TB_LOCALBIN)/controller-gen \
$(TB_LOCALBIN)/semver \
$(TB_LOCALBIN)/toolbox

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile -f $(TB_LOCALDIR)/Makefile \
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
github.com/bakito/toolbox
Expand Down
10 changes: 7 additions & 3 deletions testdata/.toolbox.mk.renovate.expected
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
$(TB_TOOLBOX): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox@$(TB_TOOLBOX_VERSION)

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f \
$(TB_LOCALBIN)/controller-gen \
$(TB_LOCALBIN)/semver \
$(TB_LOCALBIN)/toolbox

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile --renovate -f $(TB_LOCALDIR)/Makefile \
sigs.k8s.io/controller-tools/cmd/controller-gen@github.com/kubernetes-sigs/controller-tools \
github.com/bakito/semver \
Expand Down
10 changes: 7 additions & 3 deletions testdata/.toolbox.mk.tools.go.expected
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ tb.toolbox: $(TB_TOOLBOX) ## Download toolbox locally if necessary.
$(TB_TOOLBOX): $(TB_LOCALBIN)
test -s $(TB_LOCALBIN)/toolbox || GOBIN=$(TB_LOCALBIN) go install github.com/bakito/toolbox

## Update Tools
.PHONY: tb.update
tb.update:
## Reset Tools
.PHONY: tb.reset
tb.reset:
@rm -f \
$(TB_LOCALBIN)/controller-gen \
$(TB_LOCALBIN)/semver \
$(TB_LOCALBIN)/toolbox

## Update Tools
.PHONY: tb.update
tb.update: tb.reset
toolbox makefile -f $(TB_LOCALDIR)/Makefile
## toolbox - end

0 comments on commit 7dfe3b0

Please sign in to comment.