Add support for private registries #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The scope: 3 files, ~40 lines of code
The only place auth is needed is internal/registry/inspect.go — remote.Get calls the registry directly. Pulls go through the Docker daemon, which handles its own auth (ImagePull uses daemon-side ~/.docker/config.json).
internal/config/config.go:
Or, simpler and more secure for env vars — one flat LAGOM_REGISTRY_USERNAME / LAGOM_REGISTRY_PASSWORD pair (covers the single-registry case most users have). A single env var like LAGOM_REGISTRY_AUTH=registry.example.com:user:pass is also an option, but multi-registry gets ugly fast.
Recommendation: Support ~/.docker/config.json via authn.DefaultKeychain automatically (zero config for users who docker login), plus an explicit LAGOM_REGISTRY_AUTH JSON blob for headless/container use:
LAGOM_REGISTRY_AUTH='{"ghcr.io":{"username":"me","password":"token"}}'
internal/registry/inspect.go:
For explicit credentials, create an authn.Basic authenticator for the registry and use remote.WithAuth:
Priority: explicit config > DefaultKeychain (Docker config.json) > anonymous.
Three call sites — all in internal/cmd/:
If InspectTag reads cfg directly (package-level init), no plumbing needed — just read it in the function. That's simpler:
var authConfig map[string]RegistryCredential // set at startup from cfg
Or pass it as a parameter — cleaner but more diff.
What this doesn't cover (v2):