diff options
author | Brent Baude <bbaude@redhat.com> | 2020-04-16 08:39:34 -0500 |
---|---|---|
committer | Brent Baude <bbaude@redhat.com> | 2020-04-16 12:04:46 -0500 |
commit | ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35 (patch) | |
tree | 3554a8bc2a5add5feee1d008d594665f82279fb3 /cmd | |
parent | 8857ba20a0651e8fa71762da90d774e3aa290883 (diff) | |
download | podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.tar.gz podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.tar.bz2 podman-ba430bfe5ef65d5aa5ffa1fef0087da76aafcc35.zip |
podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client
Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/shared/create.go | 3 | ||||
-rw-r--r-- | cmd/podmanV2/common/specgen.go | 4 | ||||
-rw-r--r-- | cmd/podmanV2/registry/config.go | 50 |
3 files changed, 52 insertions, 5 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go index 94b1e63dc..f8178a841 100644 --- a/cmd/podman/shared/create.go +++ b/cmd/podman/shared/create.go @@ -16,6 +16,7 @@ import ( "github.com/containers/image/v5/manifest" "github.com/containers/libpod/cmd/podman/shared/parse" "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/image" ann "github.com/containers/libpod/pkg/annotations" "github.com/containers/libpod/pkg/autoupdate" @@ -715,7 +716,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod. // both memorySwappiness := c.Int64("memory-swappiness") - logDriver := libpod.KubernetesLogging + logDriver := define.KubernetesLogging if c.Changed("log-driver") { logDriver = c.String("log-driver") } diff --git a/cmd/podmanV2/common/specgen.go b/cmd/podmanV2/common/specgen.go index 5245e206e..2232fb4ba 100644 --- a/cmd/podmanV2/common/specgen.go +++ b/cmd/podmanV2/common/specgen.go @@ -11,7 +11,7 @@ import ( "github.com/containers/image/v5/manifest" "github.com/containers/libpod/cmd/podmanV2/parse" - "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/define" ann "github.com/containers/libpod/pkg/annotations" envLib "github.com/containers/libpod/pkg/env" ns "github.com/containers/libpod/pkg/namespaces" @@ -324,7 +324,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string if s.LogConfiguration == nil { s.LogConfiguration = &specgen.LogConfig{} } - s.LogConfiguration.Driver = libpod.KubernetesLogging + s.LogConfiguration.Driver = define.KubernetesLogging if ld := c.LogDriver; len(ld) > 0 { s.LogConfiguration.Driver = ld } diff --git a/cmd/podmanV2/registry/config.go b/cmd/podmanV2/registry/config.go index e68009a50..de9d1f262 100644 --- a/cmd/podmanV2/registry/config.go +++ b/cmd/podmanV2/registry/config.go @@ -1,13 +1,17 @@ package registry import ( + "fmt" "os" + "path/filepath" "runtime" "strings" "github.com/containers/common/pkg/config" - "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/domain/entities" + "github.com/containers/libpod/pkg/rootless" + "github.com/containers/libpod/pkg/util" + "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -21,7 +25,7 @@ var ( // NewPodmanConfig creates a PodmanConfig from the environment func NewPodmanConfig() entities.PodmanConfig { - if err := libpod.SetXdgDirs(); err != nil { + if err := setXdgDirs(); err != nil { logrus.Errorf(err.Error()) os.Exit(1) } @@ -57,3 +61,45 @@ func NewPodmanConfig() entities.PodmanConfig { } return entities.PodmanConfig{Config: cfg, EngineMode: mode} } + +// SetXdgDirs ensures the XDG_RUNTIME_DIR env and XDG_CONFIG_HOME variables are set. +// containers/image uses XDG_RUNTIME_DIR to locate the auth file, XDG_CONFIG_HOME is +// use for the libpod.conf configuration file. +func setXdgDirs() error { + if !rootless.IsRootless() { + return nil + } + + // Setup XDG_RUNTIME_DIR + runtimeDir := os.Getenv("XDG_RUNTIME_DIR") + + if runtimeDir == "" { + var err error + runtimeDir, err = util.GetRuntimeDir() + if err != nil { + return err + } + } + if err := os.Setenv("XDG_RUNTIME_DIR", runtimeDir); err != nil { + return errors.Wrapf(err, "cannot set XDG_RUNTIME_DIR") + } + + if rootless.IsRootless() && os.Getenv("DBUS_SESSION_BUS_ADDRESS") == "" { + sessionAddr := filepath.Join(runtimeDir, "bus") + if _, err := os.Stat(sessionAddr); err == nil { + os.Setenv("DBUS_SESSION_BUS_ADDRESS", fmt.Sprintf("unix:path=%s", sessionAddr)) + } + } + + // Setup XDG_CONFIG_HOME + if cfgHomeDir := os.Getenv("XDG_CONFIG_HOME"); cfgHomeDir == "" { + cfgHomeDir, err := util.GetRootlessConfigHomeDir() + if err != nil { + return err + } + if err := os.Setenv("XDG_CONFIG_HOME", cfgHomeDir); err != nil { + return errors.Wrapf(err, "cannot set XDG_CONFIG_HOME") + } + } + return nil +} |