summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTomSweeneyRedHat <tsweeney@redhat.com>2020-10-20 17:39:06 -0400
committerTomSweeneyRedHat <tsweeney@redhat.com>2020-10-21 19:24:56 -0400
commit852f2cbe858a8880c356869c622b49ee362c5307 (patch)
treecb37f2a673d08acc9258daf9bc278d6f734d9ca2 /cmd
parent2bd920b00540280696d19dc95ab6e562aebd6b7d (diff)
downloadpodman-852f2cbe858a8880c356869c622b49ee362c5307.tar.gz
podman-852f2cbe858a8880c356869c622b49ee362c5307.tar.bz2
podman-852f2cbe858a8880c356869c622b49ee362c5307.zip
Fix pull method selection
When using 'podman build --pull=true', the image was not pulled if the image being pulled was present locally, but a newer version was in the repository. It was only pulled if there was no image in local storage. In addition, the pull-never option was ignored. The line `if flags.Pull{` at line 244 was always returning true negating the default pullPolicy of PullNever. Reworked the algorthim for the selection process. Now PullIfNewer is set to the default, and then we set the pullPolicy appropriately based on the other flags passed in to this routine. As an FYI, logic run in the calling functions ensures that we have only one pull flag in the command. Addresses: #8024 Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/images/build.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 18c31313b..c53798589 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -240,14 +240,18 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
- pullPolicy := imagebuildah.PullNever
- if flags.Pull {
+ pullPolicy := imagebuildah.PullIfNewer
+ if c.Flags().Changed("pull") && !flags.Pull {
pullPolicy = imagebuildah.PullIfMissing
}
if flags.PullAlways {
pullPolicy = imagebuildah.PullAlways
}
+ if flags.PullNever {
+ pullPolicy = imagebuildah.PullNever
+ }
+
args := make(map[string]string)
if c.Flag("build-arg").Changed {
for _, arg := range flags.BuildArg {