diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index da7f5d8625..04fdeab0aa 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -11,6 +11,7 @@ import ( buildahDefine "github.com/containers/buildah/define" buildahCLI "github.com/containers/buildah/pkg/cli" "github.com/containers/buildah/pkg/parse" + "github.com/containers/common/pkg/auth" "github.com/containers/common/pkg/completion" "github.com/containers/common/pkg/config" encconfig "github.com/containers/ocicrypt/config" @@ -330,6 +331,12 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil pullPolicy = buildahDefine.PullNever } + if c.Flag("authfile").Changed { + if err := auth.CheckAuthFile(flags.Authfile); err != nil { + return nil, err + } + } + args := make(map[string]string) if c.Flag("build-arg").Changed { for _, arg := range flags.BuildArg { diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 2e97c93e0b..5a887c71eb 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -752,6 +752,11 @@ EOF run_podman rmi -f build_test } +@test "podman build --authfile bogus test" { + run_podman 125 build --authfile=/tmp/bogus - <<< "from scratch" + is "$output" ".*/tmp/bogus: no such file or directory" +} + function teardown() { # A timeout or other error in 'build' can leave behind stale images # that podman can't even see and which will cascade into subsequent