mirror of https://github.com/containers/podman.git
Use GetRuntimeDir to setup auth.json for login
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
9bee6907a5
commit
d27e71374e
|
@ -6,6 +6,7 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/containers/libpod/pkg/util"
|
||||
"github.com/google/shlex"
|
||||
)
|
||||
|
||||
|
@ -13,13 +14,14 @@ func GetAuthFile(authfile string) string {
|
|||
if authfile != "" {
|
||||
return authfile
|
||||
}
|
||||
|
||||
authfile = os.Getenv("REGISTRY_AUTH_FILE")
|
||||
if authfile != "" {
|
||||
return authfile
|
||||
}
|
||||
runtimeDir := os.Getenv("XDG_RUNTIME_DIR")
|
||||
if runtimeDir != "" {
|
||||
return filepath.Join(runtimeDir, "containers/auth.json")
|
||||
|
||||
if runtimeDir, err := util.GetRuntimeDir(); err == nil {
|
||||
return filepath.Join(runtimeDir, "auth.json")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func init() {
|
|||
func varlinkCmd(c *cliconfig.VarlinkValues) error {
|
||||
varlinkURI := adapter.DefaultAddress
|
||||
if rootless.IsRootless() {
|
||||
xdg, err := util.GetRootlessRuntimeDir()
|
||||
xdg, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) {
|
|||
func (r *OCIRuntime) updateContainerStatus(ctr *Container, useRuntime bool) error {
|
||||
exitFile := ctr.exitFilePath()
|
||||
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container, useRuntime bool) erro
|
|||
// Sets time the container was started, but does not save it.
|
||||
func (r *OCIRuntime) startContainer(ctr *Container) error {
|
||||
// TODO: streams should probably *not* be our STDIN/OUT/ERR - redirect to buffers?
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ func (r *OCIRuntime) startContainer(ctr *Container) error {
|
|||
// killContainer sends the given signal to the given container
|
||||
func (r *OCIRuntime) killContainer(ctr *Container, signal uint) error {
|
||||
logrus.Debugf("Sending signal %d to container %s", signal, ctr.ID())
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ func (r *OCIRuntime) killContainer(ctr *Container, signal uint) error {
|
|||
|
||||
// deleteContainer deletes a container from the OCI runtime
|
||||
func (r *OCIRuntime) deleteContainer(ctr *Container) error {
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ func (r *OCIRuntime) deleteContainer(ctr *Container) error {
|
|||
|
||||
// pauseContainer pauses the given container
|
||||
func (r *OCIRuntime) pauseContainer(ctr *Container) error {
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -388,7 +388,7 @@ func (r *OCIRuntime) pauseContainer(ctr *Container) error {
|
|||
|
||||
// unpauseContainer unpauses the given container
|
||||
func (r *OCIRuntime) unpauseContainer(ctr *Container) error {
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
func (r *OCIRuntime) createOCIContainer(ctr *Container, restoreOptions *ContainerCheckpointOptions) (err error) {
|
||||
var stderrBuf bytes.Buffer
|
||||
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ func (r *OCIRuntime) execContainer(c *Container, cmd, capAdd, env []string, tty
|
|||
}
|
||||
}()
|
||||
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return -1, nil, err
|
||||
}
|
||||
|
@ -437,7 +437,7 @@ func (r *OCIRuntime) stopContainer(ctr *Container, timeout uint) error {
|
|||
args = []string{"kill", "--all", ctr.ID(), "KILL"}
|
||||
}
|
||||
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ func (r *OCIRuntime) execStopContainer(ctr *Container, timeout uint) error {
|
|||
if len(execSessions) == 0 {
|
||||
return nil
|
||||
}
|
||||
runtimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -365,7 +365,7 @@ func SetXdgDirs() error {
|
|||
|
||||
if runtimeDir == "" {
|
||||
var err error
|
||||
runtimeDir, err = util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err = util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -391,11 +391,11 @@ func getDefaultTmpDir() (string, error) {
|
|||
return "/var/run/libpod", nil
|
||||
}
|
||||
|
||||
rootlessRuntimeDir, err := util.GetRootlessRuntimeDir()
|
||||
runtimeDir, err := util.GetRuntimeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
libpodRuntimeDir := filepath.Join(rootlessRuntimeDir, "libpod")
|
||||
libpodRuntimeDir := filepath.Join(runtimeDir, "libpod")
|
||||
|
||||
if err := os.Mkdir(libpodRuntimeDir, 0700|os.ModeSticky); err != nil {
|
||||
if !os.IsExist(err) {
|
||||
|
|
|
@ -16,8 +16,8 @@ import (
|
|||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// GetRootlessRuntimeDir returns the runtime directory when running as non root
|
||||
func GetRootlessRuntimeDir() (string, error) {
|
||||
// GetRuntimeDir returns the runtime directory
|
||||
func GetRuntimeDir() (string, error) {
|
||||
var rootlessRuntimeDirError error
|
||||
|
||||
rootlessRuntimeDirOnce.Do(func() {
|
||||
|
@ -100,7 +100,7 @@ func GetRootlessConfigHomeDir() (string, error) {
|
|||
// GetRootlessPauseProcessPidPath returns the path to the file that holds the pid for
|
||||
// the pause process
|
||||
func GetRootlessPauseProcessPidPath() (string, error) {
|
||||
runtimeDir, err := GetRootlessRuntimeDir()
|
||||
runtimeDir, err := GetRuntimeDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ func GetRootlessPauseProcessPidPath() (string, error) {
|
|||
return "", errors.Wrap(errNotImplemented, "GetRootlessPauseProcessPidPath")
|
||||
}
|
||||
|
||||
// GetRootlessRuntimeDir returns the runtime directory when running as non root
|
||||
func GetRootlessRuntimeDir() (string, error) {
|
||||
return "", errors.Wrap(errNotImplemented, "GetRootlessRuntimeDir")
|
||||
// GetRuntimeDir returns the runtime directory
|
||||
func GetRuntimeDir() (string, error) {
|
||||
return "", errors.New("this function is not implemented for windows")
|
||||
}
|
||||
|
||||
// GetRootlessConfigHomeDir returns the config home directory when running as non root
|
||||
func GetRootlessConfigHomeDir() (string, error) {
|
||||
return "", errors.Wrap(errNotImplemented, "GetRootlessConfigHomeDir")
|
||||
return "", errors.New("this function is not implemented for windows")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue