Skip to content

Commit

Permalink
use const for DOCKER_CONFIG env var
Browse files Browse the repository at this point in the history
  • Loading branch information
skylenet committed Oct 28, 2024
1 parent 3ab25bb commit 922f5aa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
dockerregistry "github.com/docker/docker/registry"
)

const (
ENV_DOCKER_CONFIG string = "DOCKER_CONFIG"
)

// RegistryAuthConfig holds authentication configuration for a container registry
type RegistryAuthConfig struct {
Auths map[string]registry.AuthConfig `json:"auths"`
Expand All @@ -22,7 +26,7 @@ type RegistryAuthConfig struct {

// loadDockerAuth loads the authentication configuration from the config.json file located in $DOCKER_CONFIG or ~/.docker
func loadDockerAuth() (RegistryAuthConfig, error) {
configFilePath := os.Getenv("DOCKER_CONFIG")
configFilePath := os.Getenv(ENV_DOCKER_CONFIG)
if configFilePath == "" {
configFilePath = os.Getenv("HOME") + "/.docker/config.json"
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func writeStaticConfig(t *testing.T, configContent string) string {
}

// Set the DOCKER_CONFIG environment variable to the temp directory
os.Setenv("DOCKER_CONFIG", tmpDir)
os.Setenv(ENV_DOCKER_CONFIG, tmpDir)
return tmpDir
}

Expand Down

0 comments on commit 922f5aa

Please sign in to comment.