Skip to content

Commit

Permalink
Merge branch 'refactor/working-dir' into 'master'
Browse files Browse the repository at this point in the history
if artifact download url is provided, remove all source code

See merge request !53
  • Loading branch information
timfeirg committed Feb 4, 2017
2 parents b8aebfc + a805d92 commit c4a3eac
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cluster/calcium/build_image.go
Expand Up @@ -129,16 +129,10 @@ func (c *calcium) BuildImage(repository, version, uid, artifact string) (chan *t
return ch, err
}

// get artifact into cloneDir, only when artifact is not empty
if artifact != "" {
if err := c.source.Artifact(artifact, cloneDir); err != nil {
log.Errorf("Error when downloading artifact: %s", err.Error())
}
}

// ensure .git directory is removed
// we don't want any history files to be retrieved
if err := os.RemoveAll(filepath.Join(cloneDir, ".git")); err != nil {
log.Errorf("Error when removing .git dir")
return ch, err
}

Expand All @@ -153,6 +147,16 @@ func (c *calcium) BuildImage(repository, version, uid, artifact string) (chan *t
return ch, err
}

// if artifact download url is provided, remove all source code to
// improve security
if artifact != "" {
os.RemoveAll(cloneDir)
os.MkdirAll(cloneDir, os.ModeDir)
if err := c.source.Artifact(artifact, cloneDir); err != nil {
log.Errorf("Error when downloading artifact: %s", err.Error())
}
}

// create launcher scripts and dockerfile
rs := richSpecs{specs, "", strings.TrimRight(c.config.AppDir, "/"), uid}
if err := createLauncher(buildDir, rs); err != nil {
Expand Down

0 comments on commit c4a3eac

Please sign in to comment.