Skip to content

Commit

Permalink
improved the default behavior of build context retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisz100 committed Jun 12, 2018
1 parent 05fe4a4 commit 402f876
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cmd/executor/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,25 @@ func resolveSourceContext() error {
var contextExecutor buildcontext.BuildContext

// if no prefix use Google Cloud Storage as default for backwards compability
if !strings.Contains(bucket, "://") {
bucket = fmt.Sprintf("gc://%s", bucket)
if !strings.Contains(srcContext, "://") {
if bucket != "" {
srcContext = fmt.Sprintf("gc://%s", bucket)
} else if bucket == "" {
srcContext = fmt.Sprintf("dir://%s", srcContext)
}
}

// if no context is set, add default file context.tar.gz
if !strings.HasSuffix(bucket, ".tar.gz") {
bucket += "/" + constants.ContextTar
if !strings.HasSuffix(srcContext, ".tar.gz") {
srcContext += "/" + constants.ContextTar
}

contextExecutor, err := buildcontext.GetBuildContext(bucket)
contextExecutor, err := buildcontext.GetBuildContext(srcContext)
if err != nil {
return err
}

if err := contextExecutor.UnpackTarFromBuildContext(bucket, buildContextPath); err != nil {
if err := contextExecutor.UnpackTarFromBuildContext(srcContext, buildContextPath); err != nil {
return err
}
logrus.Debugf("Unpacked tar from %s to path %s", bucket, buildContextPath)
Expand Down

0 comments on commit 402f876

Please sign in to comment.