mirror of
https://github.com/containers/podman.git
synced 2025-09-26 08:14:14 +08:00
add --pull flag for podman create&run
Requirement from https://github.com/containers/libpod/issues/3575#issuecomment-512238393 Added --pull for podman create and pull to match the newly added flag in docker CLI. `missing`: default value, podman will pull the image if it does not exist in the local. `always`: podman will always pull the image. `never`: podman will never pull the image. Signed-off-by: Qi Wang <qiwan@redhat.com>
This commit is contained in:
@ -356,3 +356,32 @@ func OpenExclusiveFile(path string) (*os.File, error) {
|
||||
}
|
||||
return os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666)
|
||||
}
|
||||
|
||||
// PullType whether to pull new image
|
||||
type PullType int
|
||||
|
||||
const (
|
||||
// PullImageAlways always try to pull new image when create or run
|
||||
PullImageAlways PullType = iota
|
||||
// PullImageMissing pulls image if it is not locally
|
||||
PullImageMissing
|
||||
// PullImageNever will never pull new image
|
||||
PullImageNever
|
||||
)
|
||||
|
||||
// ValidatePullType check if the pullType from CLI is valid and returns the valid enum type
|
||||
// if the value from CLI is invalid returns the error
|
||||
func ValidatePullType(pullType string) (PullType, error) {
|
||||
switch pullType {
|
||||
case "always":
|
||||
return PullImageAlways, nil
|
||||
case "missing":
|
||||
return PullImageMissing, nil
|
||||
case "never":
|
||||
return PullImageNever, nil
|
||||
case "":
|
||||
return PullImageMissing, nil
|
||||
default:
|
||||
return PullImageMissing, errors.Errorf("invalid pull type %q", pullType)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user