Use github.com/docker/cli/cli/config/configfile.DockerEnvConfigKey

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2025-07-10 00:04:09 +02:00
parent 5e86ec4a9f
commit f35440564f
1 changed files with 5 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/containers/image/v5/types"
dockerReference "github.com/distribution/reference"
"github.com/docker/cli/cli/config"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/credentials"
configtypes "github.com/docker/cli/cli/config/types"
"github.com/docker/docker/registry"
@ -459,12 +460,12 @@ func TestGetCredentialsInteroperability(t *testing.T) {
const testUser = "some-user"
const testPassword = "some-password"
// Unset DOCKER_AUTH_CONFIG, which is read by github.com/docker/cli/cli/config/configfile.ConfigFile.GetCredentialsStore
// Unset DockerEnvConfigKey, which is read by github.com/docker/cli/cli/config/configfile.ConfigFile.GetCredentialsStore
// and might interfere with the test.
// Use t.Setenv() to ensure DOCKER_AUTH_CONFIG is restored to the original value after the test;
// Use t.Setenv() to ensure DockerEnvConfigKey is restored to the original value after the test;
// (Sadly there isnt a t.Unsetenv() as of Go 1.17.)
t.Setenv("DOCKER_AUTH_CONFIG", "")
os.Unsetenv("DOCKER_AUTH_CONFIG")
t.Setenv(configfile.DockerEnvConfigKey, "")
os.Unsetenv(configfile.DockerEnvConfigKey)
for _, c := range []struct {
loginKey string // or "" for Docker's default. We must special-case that because (docker login docker.io) works, but (docker logout docker.io) doesn't!