Skip to content

Commit

Permalink
Add docker-options on .tgf.config file
Browse files Browse the repository at this point in the history
  • Loading branch information
jocgir committed Nov 17, 2017
1 parent bc6f365 commit d17224c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,19 @@ or install it through command line:
On `OSX`:

```bash
curl -sL https://github.com/coveo/tgf/releases/download/v1.15.1/tgf_1.15.1_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin && chmod +x /usr/local/bin/tgf
curl -sL https://github.com/coveo/tgf/releases/download/v1.15.2/tgf_1.15.2_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin && chmod +x /usr/local/bin/tgf
```

On `Linux`:

```bash
curl -sL https://github.com/coveo/tgf/releases/download/v1.15.1/tgf_1.15.1_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.15.2/tgf_1.15.2_linux_64-bits.zip | gzip -d > /usr/local/bin/tgf && chmod +x /usr/local/bin/tgf
```

On `Windows` with Powershell:

```powershell
Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.15.1/tgf_1.15.1_windows_64-bits.zip -OutFile tgf.zip
Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.15.2/tgf_1.15.2_windows_64-bits.zip -OutFile tgf.zip
```

## Configuration
Expand Down Expand Up @@ -91,6 +91,7 @@ Key | Description | Default value
| docker-image-tag | Identify the image tag (could specify specialized version such as k8s, full) | latest
| docker-image-build | List of Dockerfile instructions to customize the specified docker image) |
| docker-refresh | Delay before checking if a newer version of the docker image is available | 1h (1 hour)
| docker-options | Additional options to supply to the Docker command |
| logging-level | Terragrunt logging level (only apply to Terragrunt entry point).<br>*Critical (0), Error (1), Warning (2), Notice (3), Info (4), Debug (5), Full (6)* | Notice
| entry-point | The program that will be automatically launched when the docker starts | terragrunt
| tgf-recommended-version | The minimal tgf version recommended in your context (should not be placed in `.tgf.config file`) | *no default*
Expand All @@ -113,7 +114,7 @@ It then looks in your current folder and all its parents to find a file named '.
default configuration. If not all configurable values are satisfied and you have an AWS configuration, it
will then try to retrieve the missing elements from the AWS Parameter Store under the key '/default/tgf'.
Configurable values are: docker-image, docker-image-version, docker-image-tag, docker-refresh, recommended-image-version, required-image-version, logging-level, entry-point, tgf-recommended-version.
Configurable values are: docker-image, docker-image-version, docker-image-tag, docker-refresh, docker-options, recommended-image-version, required-image-version, logging-level, entry-point, tgf-recommended-version.
You can get the full documentation at https://github.com/coveo/tgf/blob/master/README.md and check for new
version at https://github.com/coveo/tgf/releases/latest.
Expand All @@ -131,7 +132,7 @@ Any non conflicting argument will be passed to the entry point wherever it is lo
tgf ls -- -D # Avoid -D to be interpretated by tgf as --debug-docker
VERSION: 1.15.1
VERSION: 1.15.2
AUTHOR: Coveo
Expand All @@ -158,7 +159,7 @@ Example:

```bash
> tgf --current-version
tgf v1.15.1
tgf v1.15.2
```

Returns the current version of the tgf tool
Expand Down
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
dockerImageTag = "docker-image-tag"
dockerImageBuild = "docker-image-build"
dockerRefresh = "docker-refresh"
dockerOptionsTag = "docker-options"
loggingLevel = "logging-level"
entryPoint = "entry-point"
tgfVersion = "tgf-recommended-version"
Expand All @@ -42,6 +43,7 @@ type tgfConfig struct {
LogLevel string
EntryPoint string
Refresh time.Duration
DockerOptions []string
RecommendedImageVersion string
RequiredVersionRange string
RecommendedTGFVersion string
Expand Down Expand Up @@ -79,6 +81,7 @@ func (config tgfConfig) String() (result string) {

ifNotZero(dockerImageBuild, buildScript)
}
ifNotZero(dockerOptionsTag, config.DockerOptions)
ifNotZero(recommendedImageVersion, config.RecommendedImageVersion)
ifNotZero(requiredImageVersion, config.RequiredVersionRange)
ifNotZero(dockerRefresh, config.Refresh)
Expand Down Expand Up @@ -143,6 +146,8 @@ func (config *tgfConfig) SetValue(key, value string) {
fmt.Fprintf(os.Stderr, warningString("Parameter %s should not contains the image name: %s\n", key, value))
}
config.apply(key, ":"+value)
case dockerOptionsTag:
config.DockerOptions = append(config.DockerOptions, strings.Split(value, " ")...)
case dockerImageBuild:
// We concatenate the various levels of docker build instructions
config.ImageBuild = strings.Join([]string{strings.TrimSpace(value), strings.TrimSpace(config.ImageBuild)}, "\n")
Expand Down
2 changes: 2 additions & 0 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ func callDocker(args ...string) int {
"-v", fmt.Sprintf("%v:%v", convertDrive(home), homeWithoutVolume),
"-e", fmt.Sprintf("HOME=%v", homeWithoutVolume),
}...)

dockerArgs = append(dockerArgs, config.DockerOptions...)
}

os.Setenv("TERRAGRUNT_CACHE", "/var/tgf")
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func main() {
"parameterStoreKey": parameterFolder,
"config": configFile,
"options": color.GreenString(strings.Join([]string{
dockerImage, dockerImageVersion, dockerImageTag, dockerImageBuild,
dockerRefresh, recommendedImageVersion, requiredImageVersion, loggingLevel, entryPoint, tgfVersion,
dockerImage, dockerImageVersion, dockerImageTag, dockerImageBuild, dockerRefresh, dockerOptionsTag,
recommendedImageVersion, requiredImageVersion, loggingLevel, entryPoint, tgfVersion,
}, ", ")),
"readme": link(gitSource + "/blob/master/README.md"),
"latest": link(gitSource + "/releases/latest"),
Expand Down

0 comments on commit d17224c

Please sign in to comment.