feat: allow "any" to specify a "binary" with no arch/os deps (#7230)
This commit is contained in:
parent
813be217e3
commit
63c3a6eeca
|
@ -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).
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue