Merge pull request #374 from priyawadhwa/cachebug

Check --cache-repo is provided with --cache and --no-push
This commit is contained in:
priyawadhwa 2018-09-28 13:39:01 -07:00 committed by GitHub
commit 139d372e77
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -55,6 +55,9 @@ var RootCmd = &cobra.Command{
if !opts.NoPush && len(opts.Destinations) == 0 { if !opts.NoPush && len(opts.Destinations) == 0 {
return errors.New("You must provide --destination, or use --no-push") return errors.New("You must provide --destination, or use --no-push")
} }
if err := cacheFlagsValid(); err != nil {
return errors.Wrap(err, "cache flags invalid")
}
if err := resolveSourceContext(); err != nil { if err := resolveSourceContext(); err != nil {
return errors.Wrap(err, "error resolving source context") return errors.Wrap(err, "error resolving source context")
} }
@ -113,6 +116,19 @@ func checkContained() bool {
return err == nil return err == nil
} }
// cacheFlagsValid makes sure the flags passed in related to caching are valid
func cacheFlagsValid() error {
if !opts.Cache {
return nil
}
// If --cache=true and --no-push=true, then cache repo must be provided
// since cache can't be inferred from destination
if opts.CacheRepo == "" && opts.NoPush {
return errors.New("if using cache with --no-push, specify cache repo with --cache-repo")
}
return nil
}
// resolveDockerfilePath resolves the Dockerfile path to an absolute path // resolveDockerfilePath resolves the Dockerfile path to an absolute path
func resolveDockerfilePath() error { func resolveDockerfilePath() error {
if util.FilepathExists(opts.DockerfilePath) { if util.FilepathExists(opts.DockerfilePath) {