Skip to content

Commit

Permalink
Merge pull request #7619 from rhatdan/pulltype
Browse files Browse the repository at this point in the history
pull types allow initial caps
  • Loading branch information
openshift-merge-robot authored Sep 13, 2020
2 parents 25fb0c2 + 81f99c3 commit 3f5f99b
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions pkg/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,33 +537,21 @@ 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
type PullType = config.PullPolicy

const (
var (
// PullImageAlways always try to pull new image when create or run
PullImageAlways PullType = iota
PullImageAlways = config.PullImageAlways
// PullImageMissing pulls image if it is not locally
PullImageMissing
PullImageMissing = config.PullImageMissing
// PullImageNever will never pull new image
PullImageNever
PullImageNever = config.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", "IfNotPresent":
return PullImageMissing, nil
case "never":
return PullImageNever, nil
case "":
return PullImageMissing, nil
default:
return PullImageMissing, errors.Errorf("invalid pull type %q", pullType)
}
return config.ValidatePullPolicy(pullType)
}

// ExitCode reads the error message when failing to executing container process
Expand Down

0 comments on commit 3f5f99b

Please sign in to comment.