summaryrefslogtreecommitdiff
path: root/cmd/podman/shared
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2019-10-25 21:16:37 -0400
committerQi Wang <qiwan@redhat.com>2019-11-05 21:32:18 -0500
commitd7c0f968ca60994306c8c76cd8e4e0a677fe9ada (patch)
tree3eff712a3fbb1c58eac9d7e43a55588a56d67892 /cmd/podman/shared
parentb4b727256c728295e6a3fcb69593347df9e90b23 (diff)
downloadpodman-d7c0f968ca60994306c8c76cd8e4e0a677fe9ada.tar.gz
podman-d7c0f968ca60994306c8c76cd8e4e0a677fe9ada.tar.bz2
podman-d7c0f968ca60994306c8c76cd8e4e0a677fe9ada.zip
fix bug check nonexist authfile
Use GetDefaultAuthFile() from buildah. For podman command(except login), if authfile does not exist returns error. close #4328 Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman/shared')
-rw-r--r--cmd/podman/shared/create.go2
-rw-r--r--cmd/podman/shared/funcs.go21
2 files changed, 9 insertions, 14 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index dc343e694..cb39e334d 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -94,7 +94,7 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.
ArchitectureChoice: c.String("override-arch"),
}
- newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, GetAuthFile(c.String("authfile")), writer, &dockerRegistryOptions, image.SigningOptions{}, nil, pullType)
+ newImage, err := runtime.ImageRuntime().New(ctx, name, rtc.SignaturePolicyPath, c.String("authfile"), writer, &dockerRegistryOptions, image.SigningOptions{}, nil, pullType)
if err != nil {
return nil, nil, err
}
diff --git a/cmd/podman/shared/funcs.go b/cmd/podman/shared/funcs.go
index 9362e8e9b..404d0f288 100644
--- a/cmd/podman/shared/funcs.go
+++ b/cmd/podman/shared/funcs.go
@@ -6,24 +6,19 @@ import (
"path/filepath"
"strings"
- "github.com/containers/libpod/pkg/util"
+ "github.com/containers/image/v5/types"
+ "github.com/containers/libpod/libpod/image"
"github.com/google/shlex"
+ "github.com/pkg/errors"
)
-func GetAuthFile(authfile string) string {
+func GetSystemContext(authfile string) (*types.SystemContext, error) {
if authfile != "" {
- return authfile
- }
-
- authfile = os.Getenv("REGISTRY_AUTH_FILE")
- if authfile != "" {
- return authfile
- }
-
- if runtimeDir, err := util.GetRuntimeDir(); err == nil {
- return filepath.Join(runtimeDir, "containers/auth.json")
+ if _, err := os.Stat(authfile); err != nil {
+ return nil, errors.Wrapf(err, "error checking authfile path %s", authfile)
+ }
}
- return ""
+ return image.GetSystemContext("", authfile, false), nil
}
func substituteCommand(cmd string) (string, error) {