File: environment.go

package info (click to toggle)
golang-github-containers-image 5.28.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,104 kB
  • sloc: sh: 194; makefile: 73
file content (31 lines) | stat: -rw-r--r-- 818 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package environment

import (
	"errors"
	"os"

	"github.com/containers/image/v5/types"
)

// UpdateRegistriesConf sets the SystemRegistriesConfPath in the system
// context, unless already set.  Possible values are, in priority and only if
// set, the CONTAINERS_REGISTRIES_CONF or REGISTRIES_CONFIG_PATH environment
// variable.
func UpdateRegistriesConf(sys *types.SystemContext) error {
	if sys == nil {
		return errors.New("internal error: UpdateRegistriesConf: nil argument")
	}
	if sys.SystemRegistriesConfPath != "" {
		return nil
	}
	if envOverride, ok := os.LookupEnv("CONTAINERS_REGISTRIES_CONF"); ok {
		sys.SystemRegistriesConfPath = envOverride
		return nil
	}
	if envOverride, ok := os.LookupEnv("REGISTRIES_CONFIG_PATH"); ok {
		sys.SystemRegistriesConfPath = envOverride
		return nil
	}

	return nil
}