summaryrefslogtreecommitdiff
path: root/cmd/podman/common.go
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-07-09 12:57:12 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-07-09 14:21:15 +0200
commit714d36b0887158c7a951813b8d04739b354dd1c0 (patch)
tree3af5564d48031e7ca1f076e7d95dbf2eae088280 /cmd/podman/common.go
parentf7407f2eb512e1407f8281009eb829f37405119b (diff)
downloadpodman-714d36b0887158c7a951813b8d04739b354dd1c0.tar.gz
podman-714d36b0887158c7a951813b8d04739b354dd1c0.tar.bz2
podman-714d36b0887158c7a951813b8d04739b354dd1c0.zip
podman: create and run honors auth file location
if the auth file was overriden, be sure create and run honors it. Closes: https://github.com/containers/libpod/issues/3524 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'cmd/podman/common.go')
-rw-r--r--cmd/podman/common.go22
1 files changed, 2 insertions, 20 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 3cc645f95..9d7c52273 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -4,11 +4,11 @@ import (
"context"
"fmt"
"os"
- "path/filepath"
"strings"
"github.com/containers/buildah"
"github.com/containers/libpod/cmd/podman/cliconfig"
+ "github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/pkg/rootless"
"github.com/containers/storage"
@@ -112,7 +112,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"Attach to STDIN, STDOUT or STDERR (default [])",
)
createFlags.String(
- "authfile", getAuthFile(""),
+ "authfile", shared.GetAuthFile(""),
"Path of the authentication file. Use REGISTRY_AUTH_FILE environment variable to override",
)
createFlags.String(
@@ -502,24 +502,6 @@ func getFormat(c *cliconfig.PodmanCommand) (string, error) {
return "", errors.Errorf("unrecognized image type %q", format)
}
-func getAuthFile(authfile string) string {
- if authfile != "" {
- return authfile
- }
- if remote {
- return ""
- }
- 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")
- }
- return ""
-}
-
// scrubServer removes 'http://' or 'https://' from the front of the
// server/registry string if either is there. This will be mostly used
// for user input from 'podman login' and 'podman logout'.