Skip to content

Commit

Permalink
Add DarwinArchAll filter (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickhoefler authored Jun 7, 2022
1 parent 12f074d commit e9a3f3f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/cmd/api_discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ func discover(
"ARMUpper": func(in string) string {
return strings.Replace(in, "arm", "ARM", 1)
},
"DarwinArchAll": func(in string) string {
if tool.OS == "darwin" {
return "all"
}
return in
},
"DarwinMacOS": func(in string) string {
return strings.Replace(in, "darwin", "macOS", 1)
},
Expand Down
17 changes: 17 additions & 0 deletions internal/cmd/api_discover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,23 @@ URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.Linux.ARM64`,
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.darwin.arm64.+
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.Linux.64bit.+
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.Linux.arm64`,
},
// -------------------------------------------------------------------------
{
name: "DarwinArchAll template functions",
cliArgs: []string{"toolctl-test-tool-template-func"},
supportedTools: []supportedTool{
{
name: "toolctl-test-tool-template-func",
version: "0.1.0",
downloadURLTemplatePath: "/v{{.Version}}/{{.Name}}-v{{.Version}}.{{.OS}}.{{.Arch | DarwinArchAll}}",
tarGz: true,
},
},
wantOutRegex: `(?s)URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.darwin.all.+
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.darwin.all.+
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.linux.amd64.+
URL: .+/v0.1.1/toolctl-test-tool-template-func-v0.1.1.linux.arm64`,
},
// -------------------------------------------------------------------------
{
Expand Down

0 comments on commit e9a3f3f

Please sign in to comment.