Merge pull request #20124 from vrothberg/build-docs

podman build: correct default pull policy
This commit is contained in:
OpenShift Merge Robot 2023-09-25 12:22:41 -04:00 committed by GitHub
commit c59d1df75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -65,11 +65,11 @@ func DefineBuildFlags(cmd *cobra.Command, buildOpts *BuildFlagsWrapper) {
// --pull flag // --pull flag
flag := budFlags.Lookup("pull") flag := budFlags.Lookup("pull")
if err := flag.Value.Set("true"); err != nil { flag.DefValue = "missing"
logrus.Errorf("Unable to set --pull to true: %v", err) if err := flag.Value.Set("missing"); err != nil {
logrus.Errorf("Unable to set --pull to 'missing': %v", err)
} }
flag.DefValue = "true" flag.Usage = `Pull image policy ("always/true"|"missing"|"never/false"|"newer")`
flag.Usage = "Always attempt to pull the image (errors are fatal)"
flags.AddFlagSet(&budFlags) flags.AddFlagSet(&budFlags)
// Add the completion functions // Add the completion functions

View File

@ -653,7 +653,7 @@ the help of emulation provided by packages like `qemu-user-static`.
#### **--pull**=*policy* #### **--pull**=*policy*
Pull image policy. The default is **always**. Pull image policy. The default is **missing**.
- **always**, **true**: Always pull the image and throw an error if the pull fails. - **always**, **true**: Always pull the image and throw an error if the pull fails.
- **missing**: Only pull the image when it does not exist in the local containers storage. Throw an error if no image is found and the pull fails. - **missing**: Only pull the image when it does not exist in the local containers storage. Throw an error if no image is found and the pull fails.

View File

@ -24,6 +24,10 @@ EOF
PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker $tmpdir PODMAN_TIMEOUT=240 run_podman build -t build_test --format=docker $tmpdir
is "$output" ".*COMMIT" "COMMIT seen in log" is "$output" ".*COMMIT" "COMMIT seen in log"
# $IMAGE is preloaded, so we should never re-pull
assert "$output" !~ "Trying to pull" "Default pull policy should be 'missing'"
assert "$output" !~ "Writing manifest" "Default pull policy should be 'missing'"
run_podman run --rm build_test cat /$rand_filename run_podman run --rm build_test cat /$rand_filename
is "$output" "$rand_content" "reading generated file in image" is "$output" "$rand_content" "reading generated file in image"