Skip to content

Commit

Permalink
Merge 95fe194 into 6bbb42a
Browse files Browse the repository at this point in the history
  • Loading branch information
jocgir committed Apr 19, 2019
2 parents 6bbb42a + 95fe194 commit eec3ce2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ or install it through command line:
On `OSX`:

```bash
curl -sL https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin
curl -sL https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin
```

On `Linux`:

```bash
curl -sL https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_linux_64-bits.zip | gzip -d > /usr/local/bin/tgf && chmod +x /usr/local/bin/tgf
curl -sL https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_linux_64-bits.zip | gzip -d > /usr/local/bin/tgf && chmod +x /usr/local/bin/tgf
```

On `Windows` with Powershell:

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.19.0/tgf_1.19.0_windows_64-bits.zip -OutFile tgf.zip
Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.19.1/tgf_1.19.1_windows_64-bits.zip -OutFile tgf.zip
```

## Configuration
Expand Down
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ func (cb TGFConfigBuild) Dir() string {

// GetTag returns the tag name that should be added to the image
func (cb TGFConfigBuild) GetTag() string {
tag := filepath.Base(filepath.Dir(cb.source))
if cb.Tag != "" {
tag = cb.Tag
tag := cb.Tag
if tag == "" {
tag = fmt.Sprintf("%s-%s", filepath.Base(filepath.Dir(cb.source)), cb.hash())
}
tagRegex := regexp.MustCompile(`[^a-zA-Z0-9\._-]`)
return tagRegex.ReplaceAllString(tag, "")
Expand Down
2 changes: 1 addition & 1 deletion config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestSetConfigDefaultValues(t *testing.T) {
assert.Equal(t, "RUN ls test", config.imageBuildConfigs[1].Instructions)
assert.Equal(t, "/abspath/my-folder", config.imageBuildConfigs[1].Folder)
assert.Equal(t, "/abspath/my-folder", config.imageBuildConfigs[1].Dir())
assert.Equal(t, "AWS", config.imageBuildConfigs[1].GetTag())
assert.Equal(t, "AWS-b74da21c62057607be2582b50624bf40", config.imageBuildConfigs[1].GetTag())

assert.Equal(t, "coveo/stuff", config.Image)
assert.Equal(t, "test", *config.ImageTag)
Expand Down
5 changes: 5 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ func getImage() (name string) {
name += ":latest"
}

lastHash := ""
for i, ib := range config.imageBuildConfigs {
var temp, folder, dockerFile string
var out *os.File
Expand Down Expand Up @@ -244,6 +245,10 @@ func getImage() (name string) {
}()
}

// We remove the last hash from the name to avoid cumulating several hash in the final name
name = strings.Replace(name, lastHash, "", 1)
lastHash = fmt.Sprintf("-%s", ib.hash())

name = name + "-" + ib.GetTag()
if image, tag := Split2(name, ":"); len(tag) > maxDockerTagLength {
name = image + ":" + tag[0:maxDockerTagLength]
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func main() {
app.Switch("no-temp", "Disable the mapping of the temp directory (alias --nt)").BoolVar(&noTemp)
app.Switch("refresh-image", "Force a refresh of the docker image (alias --ri)").BoolVar(&refresh)
app.Switch("local-image", "If set, TGF will not pull the image when refreshing (alias --li)").BoolVar(&useLocalImage)
app.Switch("interactive", "If set, docker will be launched in interactive mode, i.e. the -it flag will be passed to the docker cli (alias --it) or set "+envInteractive).Envar(envInteractive).BoolVar(&dockerInteractive)
app.Switch("interactive", "On by default, use --no-interactive or --no-it to disable launching Docker in interactive mode or set "+envInteractive+" to 0 or false").Envar(envInteractive).BoolVar(&dockerInteractive)
app.Argument("mount-point", "Specify a mount point for the current folder --mp)").StringVar(&mountPoint)
app.Argument("docker-arg", "Supply extra argument to Docker (alias --da)").PlaceHolder("<opt>").StringsVar(&dockerOptions)
app.Argument("ignore-user-config", "Ignore all tgf.user.config files (alias --iuc)").BoolVar(&disableUserConfig)
Expand Down

0 comments on commit eec3ce2

Please sign in to comment.