feat: add registry:auth-status to read back login state
There was no way to ask whether Dokku was already logged in to a registry with a given credential, so tooling converging a declared state onto a server had to re-run `registry:login` on every pass purely to discover that nothing needed to change. The new `registry:auth-status` command compares a supplied credential against the stored one and reports the result through its exit code alone, distinguishing a server with no credential from one whose credential differs, and from one whose secret a docker credential helper or an identity token puts out of reach. An `auth-servers` triad on `registry:report` exposes which servers have credentials without emitting any part of one.
This commit is contained in:
11 files changed
+877
-12
No files matched your search
@@ -2,7 +2,6 @@ package registry
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -58,13 +57,12 @@ func HasAppRegistryAuth(appName string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var config map[string]interface{}
|
||||
if err := json.Unmarshal(content, &config); err != nil {
|
||||
config, err := parseDockerConfig(content)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
auths, ok := config["auths"].(map[string]interface{})
|
||||
return ok && len(auths) > 0
|
||||
return len(config.Auths) > 0
|
||||
}
|
||||
|
||||
// GetDockerConfigArgs returns docker --config arguments if per-app config exists
|
||||
|
||||
Reference in new issue
Block a user