summaryrefslogtreecommitdiff
path: root/cmd/podman/registry
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-04-17 02:35:50 -0700
committerGitHub <noreply@github.com>2020-04-17 02:35:50 -0700
commitd31dcb9bbd521fe8e3e78b0ebe2a893634ab2e6b (patch)
tree215280684ce6195fac64f18ebd7d29c5baa376cc /cmd/podman/registry
parent0d2b5532c417c58bd24e71a56c5c55b43e423a59 (diff)
parent554c663b5ad2bd0c0fa4c58559ec2a9b19ed399f (diff)
downloadpodman-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')
-rw-r--r--cmd/podman/registry/config.go16
-rw-r--r--cmd/podman/registry/registry.go10
-rw-r--r--cmd/podman/registry/remote.go2
3 files changed, 18 insertions, 10 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.
diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go
index 1c5e5d21b..2e9d59d10 100644
--- a/cmd/podman/registry/registry.go
+++ b/cmd/podman/registry/registry.go
@@ -49,8 +49,8 @@ func ImageEngine() entities.ImageEngine {
// NewImageEngine is a wrapper for building an ImageEngine to be used for PreRunE functions
func NewImageEngine(cmd *cobra.Command, args []string) (entities.ImageEngine, error) {
if imageEngine == nil {
- PodmanOptions.FlagSet = cmd.Flags()
- engine, err := infra.NewImageEngine(PodmanOptions)
+ podmanOptions.FlagSet = cmd.Flags()
+ engine, err := infra.NewImageEngine(&podmanOptions)
if err != nil {
return nil, err
}
@@ -66,8 +66,8 @@ func ContainerEngine() entities.ContainerEngine {
// NewContainerEngine is a wrapper for building an ContainerEngine to be used for PreRunE functions
func NewContainerEngine(cmd *cobra.Command, args []string) (entities.ContainerEngine, error) {
if containerEngine == nil {
- PodmanOptions.FlagSet = cmd.Flags()
- engine, err := infra.NewContainerEngine(PodmanOptions)
+ podmanOptions.FlagSet = cmd.Flags()
+ engine, err := infra.NewContainerEngine(&podmanOptions)
if err != nil {
return nil, err
}
@@ -101,7 +101,7 @@ func Context() context.Context {
}
func ContextWithOptions(ctx context.Context) context.Context {
- cliCtx = context.WithValue(ctx, PodmanOptionsKey{}, PodmanOptions)
+ cliCtx = context.WithValue(ctx, PodmanOptionsKey{}, podmanOptions)
return cliCtx
}
diff --git a/cmd/podman/registry/remote.go b/cmd/podman/registry/remote.go
index 5378701e7..95870750e 100644
--- a/cmd/podman/registry/remote.go
+++ b/cmd/podman/registry/remote.go
@@ -5,5 +5,5 @@ import (
)
func IsRemote() bool {
- return PodmanOptions.EngineMode == entities.TunnelMode
+ return podmanOptions.EngineMode == entities.TunnelMode
}