feat: support local apps.json loading

This logic supports the following cases:

- Download a fresh apps.json and load it if missing
- Check if a local apps.json is old and get a fresh one if so
- Always save a local copy after downloading a fresh apps.json

The http.Head() call is faster than a http.Get() call (only carries back
respones headers) and aims to make the more general case more
performant: you have the latest copy of the apps.json and don't need to
download another one. This a direct port of our Bash implementation
logic.

Closes https://git.autonomic.zone/coop-cloud/go-abra/issues/9.
This commit is contained in:
2021-07-21 18:21:45 +02:00
parent 6b370599fa
commit 1f6c0e8c4b
2 changed files with 105 additions and 32 deletions

View File

@ -16,6 +16,7 @@ import (
var ABRA_DIR = os.ExpandEnv("$HOME/.abra")
var ABRA_SERVER_FOLDER = path.Join(ABRA_DIR, "servers")
var APPS_JSON = path.Join(ABRA_DIR, "apps.json")
// Type aliases to make code hints easier to understand
type AppEnv = map[string]string