diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-17 02:35:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 02:35:50 -0700 |
commit | d31dcb9bbd521fe8e3e78b0ebe2a893634ab2e6b (patch) | |
tree | 215280684ce6195fac64f18ebd7d29c5baa376cc /cmd/podman/registry/config.go | |
parent | 0d2b5532c417c58bd24e71a56c5c55b43e423a59 (diff) | |
parent | 554c663b5ad2bd0c0fa4c58559ec2a9b19ed399f (diff) | |
download | podman-d31dcb9bbd521fe8e3e78b0ebe2a893634ab2e6b.tar.gz podman-d31dcb9bbd521fe8e3e78b0ebe2a893634ab2e6b.tar.bz2 podman-d31dcb9bbd521fe8e3e78b0ebe2a893634ab2e6b.zip |
Merge pull request #5856 from jwhonce/wip/options
Fix bug where two configurations had been created
Diffstat (limited to 'cmd/podman/registry/config.go')
-rw-r--r-- | cmd/podman/registry/config.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd/podman/registry/config.go b/cmd/podman/registry/config.go index 358f9172e..fc6eb538e 100644 --- a/cmd/podman/registry/config.go +++ b/cmd/podman/registry/config.go @@ -6,6 +6,7 @@ import ( "path/filepath" "runtime" "strings" + "sync" "github.com/containers/common/pkg/config" "github.com/containers/libpod/pkg/domain/entities" @@ -19,11 +20,18 @@ const ( ) var ( - PodmanOptions entities.PodmanConfig + podmanOptions entities.PodmanConfig + podmanSync sync.Once ) -// NewPodmanConfig creates a PodmanConfig from the environment -func NewPodmanConfig() entities.PodmanConfig { +// PodmanConfig returns an entities.PodmanConfig built up from +// environment and CLI +func PodmanConfig() *entities.PodmanConfig { + podmanSync.Do(newPodmanConfig) + return &podmanOptions +} + +func newPodmanConfig() { if err := setXdgDirs(); err != nil { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1) @@ -63,7 +71,7 @@ func NewPodmanConfig() entities.PodmanConfig { cfg.Network.NetworkConfigDir = "" } - return entities.PodmanConfig{Config: cfg, EngineMode: mode} + podmanOptions = entities.PodmanConfig{Config: cfg, EngineMode: mode} } // SetXdgDirs ensures the XDG_RUNTIME_DIR env and XDG_CONFIG_HOME variables are set. |