MCPcopy Create free account
hub / github.com/docker/cli / parseEnvConfig

Function parseEnvConfig

cli/config/configfile/file.go:353–380  ·  view source on GitHub ↗
(v string)

Source from the content-addressed store, hash-verified

351}
352
353func parseEnvConfig(v string) (map[string]types.AuthConfig, error) {
354 envConfig := &configEnv{}
355 decoder := json.NewDecoder(strings.NewReader(v))
356 decoder.DisallowUnknownFields()
357 if err := decoder.Decode(envConfig); err != nil && !errors.Is(err, io.EOF) {
358 return nil, err
359 }
360 if decoder.More() {
361 return nil, errors.New("DOCKER_AUTH_CONFIG does not support more than one JSON object")
362 }
363
364 authConfigs := make(map[string]types.AuthConfig)
365 for addr, envAuth := range envConfig.AuthConfigs {
366 if envAuth.Auth == "" {
367 return nil, fmt.Errorf("DOCKER_AUTH_CONFIG environment variable is missing key `auth` for %s", addr)
368 }
369 username, password, err := decodeAuth(envAuth.Auth)
370 if err != nil {
371 return nil, err
372 }
373 authConfigs[addr] = types.AuthConfig{
374 Username: username,
375 Password: password,
376 ServerAddress: addr,
377 }
378 }
379 return authConfigs, nil
380}
381
382// var for unit testing.
383var newNativeStore = func(configFile *ConfigFile, helperSuffix string) credentials.Store {

Callers 2

TestParseEnvConfigFunction · 0.85
GetCredentialsStoreMethod · 0.85

Calls 1

decodeAuthFunction · 0.85

Tested by 1

TestParseEnvConfigFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…