Skip to content

Commit 25ebaf1

Browse files
committed
extend logging
1 parent a81df27 commit 25ebaf1

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

.toolbox.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ tools:
2323
terraform:
2424
github: hashicorp/terraform
2525
downloadURL: https://releases.hashicorp.com/terraform/{{ .VersionNum }}/terraform_{{ .VersionNum }}_{{ .OS }}_{{ .Arch }}.zip
26+
jf:
27+
github: jfrog/jfrog-cli
28+
downloadURL: https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/{{ .VersionNum }}/jfrog-cli-{{ .OS }}-{{ .Arch }}/jf{{ .FileExt }}
2629
target: ./download

main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ func main() {
7979
if err := handleTool(client, ver, tmp, tb, tool); err != nil {
8080
panic(err)
8181
}
82-
8382
}
8483

8584
// save versions
@@ -107,6 +106,7 @@ func handleTool(client *resty.Client, ver map[string]string, tmp string, tb *typ
107106
SetResult(ghr).
108107
SetHeader("Accept", "application/json")
109108
if t, ok := os.LookupEnv("GITHUB_TOKEN"); ok {
109+
log.Printf("Using github toklen\n")
110110
ghc = ghc.SetAuthToken(t)
111111
}
112112
_, err := ghc.
@@ -147,19 +147,25 @@ func handleTool(client *resty.Client, ver map[string]string, tmp string, tb *typ
147147
}
148148
} else if ghr != nil {
149149
matching := findMatching(tool.Name, ghr.Assets)
150+
tool.CouldNotBeFound = true
150151
if matching != nil {
152+
tool.CouldNotBeFound = false
151153
if err := fetchTool(tmp, tool.Name, tool.Name, matching.BrowserDownloadURL, tb.Target); err != nil {
152154
return err
153155
}
154156
}
155157
for _, add := range tool.Additional {
156158
matching := findMatching(add, ghr.Assets)
157159
if matching != nil {
160+
tool.CouldNotBeFound = false
158161
if err := fetchTool(tmp, add, add, matching.BrowserDownloadURL, tb.Target); err != nil {
159162
return err
160163
}
161164
}
162165
}
166+
if tool.CouldNotBeFound {
167+
log.Printf("❌ Couldn't find a file here!\n")
168+
}
163169
}
164170
return nil
165171
}

pkg/types/types.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,21 @@ func (t *Toolbox) GetTools() []*Tool {
3636
func (t *Toolbox) Versions() Versions {
3737
v := Versions{Versions: map[string]string{}}
3838
for _, t := range t.Tools {
39-
v.Versions[t.Name] = t.Version
39+
if !t.CouldNotBeFound {
40+
v.Versions[t.Name] = t.Version
41+
}
4042
}
4143
return v
4244
}
4345

4446
type Tool struct {
45-
Name string `yaml:"name"`
46-
Github string `yaml:"github"`
47-
Google string `yaml:"google"`
48-
DownloadURL string `yaml:"downloadURL"`
49-
Version string `yaml:"version"`
50-
Additional []string `yaml:"additional"`
47+
Name string `yaml:"name"`
48+
Github string `yaml:"github"`
49+
Google string `yaml:"google"`
50+
DownloadURL string `yaml:"downloadURL"`
51+
Version string `yaml:"version"`
52+
Additional []string `yaml:"additional"`
53+
CouldNotBeFound bool `yaml:"-"`
5154
}
5255

5356
type ToolVersion struct {

0 commit comments

Comments
 (0)