feat: allow "any" to specify a "binary" with no arch/os deps (#7230)

This commit is contained in:
Michael FIG 2020-09-14 15:32:10 -06:00 committed by GitHub
parent 813be217e3
commit 63c3a6eeca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -122,6 +122,7 @@ as JSON under the `"binaries"` key, eg:
}
}
```
The `"any"` key, if it exists, will be used as a default if there is not a specific os/architecture key.
2. Store a link to a file that contains all information in the above format (eg. if you want
to specify lots of binaries, changelog info, etc without filling up the blockchain).

View File

@ -121,7 +121,10 @@ func GetDownloadURL(info *UpgradeInfo) (string, error) {
if err := json.Unmarshal([]byte(doc), &config); err == nil {
url, ok := config.Binaries[osArch()]
if !ok {
return "", fmt.Errorf("cannot find binary for os/arch: %s", osArch())
url, ok = config.Binaries["any"]
}
if !ok {
return "", fmt.Errorf("cannot find binary for os/arch: neither %s, nor any", osArch())
}
return url, nil

View File

@ -159,6 +159,14 @@ func TestGetDownloadURL(t *testing.T) {
info: `{"binaries": {"linux/amd64": "https://foo.bar/", "windows/amd64": "https://something.else"}}`,
url: "https://foo.bar/",
},
"any architecture not used": {
info: `{"binaries": {"linux/amd64": "https://foo.bar/", "*": "https://something.else"}}`,
url: "https://foo.bar/",
},
"any architecture used": {
info: `{"binaries": {"linux/arm": "https://foo.bar/arm-only", "any": "https://foo.bar/portable"}}`,
url: "https://foo.bar/portable",
},
"missing binary": {
info: `{"binaries": {"linux/arm": "https://foo.bar/"}}`,
isErr: true,