Skip to content

Commit

Permalink
build: mirror --authfile to filesystem if pointing to FD instead of file
Browse files Browse the repository at this point in the history
Following commit makes sure that podman mirrors --authfile to a temporary
file in filesystem if arg is pointing to an FD instead of actual file
as FD can be only consumed once.

Reference:
* containers/buildah#3498
* containers/buildah#3070

[NO TESTS NEEDED]

Signed-off-by: Aditya Rajan <[email protected]>
  • Loading branch information
flouthoc authored and mheon committed Sep 16, 2021
1 parent 69e3273 commit c407813
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
buildahDefine "github.com/containers/buildah/define"
buildahCLI "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
buildahUtil "github.com/containers/buildah/pkg/util"
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
Expand Down Expand Up @@ -359,6 +360,12 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}

cleanTmpFile := false
flags.Authfile, cleanTmpFile = buildahUtil.MirrorToTempFileIfPathIsDescriptor(flags.Authfile)
if cleanTmpFile {
defer os.Remove(flags.Authfile)
}

args := make(map[string]string)
if c.Flag("build-arg").Changed {
for _, arg := range flags.BuildArg {
Expand Down
81 changes: 81 additions & 0 deletions vendor/github.com/containers/buildah/pkg/util/util.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ github.com/containers/buildah/pkg/overlay
github.com/containers/buildah/pkg/parse
github.com/containers/buildah/pkg/rusage
github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/util
# github.com/containers/common v0.44.0
github.com/containers/common/libimage
Expand Down

0 comments on commit c407813

Please sign in to comment.