diff --git a/cosmovisor/README.md b/cosmovisor/README.md index 00e9a02719..3892efd0db 100644 --- a/cosmovisor/README.md +++ b/cosmovisor/README.md @@ -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). diff --git a/cosmovisor/upgrade.go b/cosmovisor/upgrade.go index 9c1cae8dae..38b6c9f81f 100644 --- a/cosmovisor/upgrade.go +++ b/cosmovisor/upgrade.go @@ -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 diff --git a/cosmovisor/upgrade_test.go b/cosmovisor/upgrade_test.go index c954f270f8..3e628bb7ff 100644 --- a/cosmovisor/upgrade_test.go +++ b/cosmovisor/upgrade_test.go @@ -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,