diff --git a/README.md b/README.md index 328bae4..9e55a82 100644 --- a/README.md +++ b/README.md @@ -40,20 +40,20 @@ or install it through command line: On `OSX`: ```bash -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 +curl -sL https://github.com/coveo/tgf/releases/download/v1.19.2/tgf_1.19.2_macOS_64-bits.zip | bsdtar -xf- -C /usr/local/bin ``` On `Linux`: ```bash -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 +curl -sL https://github.com/coveo/tgf/releases/download/v1.19.2/tgf_1.19.2_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.1/tgf_1.19.1_windows_64-bits.zip -OutFile tgf.zip +Invoke-WebRequest https://github.com/coveo/tgf/releases/download/v1.19.2/tgf_1.19.2_windows_64-bits.zip -OutFile tgf.zip ``` ## Configuration @@ -150,7 +150,7 @@ IMPORTANT: Most of the tgf command line arguments are in uppercase to avoid pote It is also possible to specify additional arguments through environment variable TGF_ARGS or enable debugging mode through TGF_DEBUG. -VERSION: 1.19.1 +VERSION: 1.19.2 AUTHOR: Coveo @@ -159,8 +159,9 @@ Flags: -D, --debug-docker Print the docker command issued -F, --flush-cache Invoke terragrunt with --terragrunt-update-source to flush the cache --get-image-name Just return the resulting image name (alias --gi) - --no-home Disable the mapping of the home directory (alias --nh) - --no-temp Disable the mapping of the temp directory (alias --nt) + --no-home Disable the mapping of the home directory (alias --nh) or set TGF_NO_HOME + --no-temp Disable the mapping of the temp directory (alias --nt) or set TGF_NO_TEMP + --no-aws Disable use of AWS to get configuration (alias --na) or set TGF_NO_AWS --refresh-image Force a refresh of the docker image (alias --ri) --local-image If set, TGF will not pull the image when refreshing (alias --li) --interactive On by default, use --no-interactive or --no-it to disable launching Docker in interactive mode or set TGF_INTERACTIVE to 0 or false diff --git a/config.go b/config.go index 9729a42..11e09e2 100644 --- a/config.go +++ b/config.go @@ -404,13 +404,17 @@ func parseSsmConfig(parameterValues map[string]string) string { // We call this function before trying to init an AWS session. This avoid trying to init a session in a non AWS context // and having to wait for metadata resolution or generating an error. func awsConfigExist() bool { + if noAWS { + return false + } + if os.Getenv("AWS_PROFILE")+os.Getenv("AWS_ACCESS_KEY_ID")+os.Getenv("AWS_CONFIG_FILE") != "" { // If any AWS identification variable is defined, we consider that we are in an AWS environment. return true } if _, err := exec.LookPath("aws"); err == nil { - // If aws program is installed, we also consider that we are in an AWS environment. + // If aws program is installed, we also consider that we are in an AWS environment. return true } diff --git a/main.go b/main.go index fa1cccb..5ef0a39 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( ) // Version is initialized at build time through -ldflags "-X main.Version=" -var version = "1.19.1" +var version = "1.19.2" var description = ` DESCRIPTION: @@ -69,6 +69,7 @@ var ( mountPoint string noHome bool noTemp bool + noAWS bool refresh bool useLocalImage bool dockerInteractive = true @@ -96,6 +97,9 @@ const ( envLocation = "TGF_CONFIG_LOCATION" envConfigFiles = "TGF_CONFIG_FILES" envInteractive = "TGF_INTERACTIVE" + envNoHome = "TGF_NO_HOME" + envNoTemp = "TGF_NO_TEMP" + envNoAWS = "TGF_NO_AWS" ) func main() { @@ -143,8 +147,9 @@ func main() { app.Switch("debug-docker", "Print the docker command issued", 'D').BoolVar(&debugMode) app.Switch("flush-cache", "Invoke terragrunt with --terragrunt-update-source to flush the cache", 'F').BoolVar(&flushCache) app.Switch("get-image-name", "Just return the resulting image name (alias --gi)").BoolVar(&getImageName) - app.Switch("no-home", "Disable the mapping of the home directory (alias --nh)").BoolVar(&noHome) - app.Switch("no-temp", "Disable the mapping of the temp directory (alias --nt)").BoolVar(&noTemp) + app.Switch("no-home", "Disable the mapping of the home directory (alias --nh) or set "+envNoHome).Envar(envNoHome).BoolVar(&noHome) + app.Switch("no-temp", "Disable the mapping of the temp directory (alias --nt) or set "+envNoTemp).Envar(envNoTemp).BoolVar(&noTemp) + app.Switch("no-aws", "Disable use of AWS to get configuration (alias --na) or set "+envNoAWS).Envar(envNoAWS).BoolVar(&noAWS) 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", "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) @@ -172,6 +177,7 @@ func main() { app.Switch("gi", "alias for get-image-name").Hidden().BoolVar(&getImageName) app.Switch("nh", "alias for no-home").Hidden().BoolVar(&noHome) app.Switch("nt", "alias for no-temp").Hidden().BoolVar(&noTemp) + app.Switch("na", "alias for no-aws").Hidden().BoolVar(&noAWS) app.Switch("cv", "alias for current-version").Hidden().BoolVar(getCurrentVersion) app.Switch("av", "alias for all-versions").Hidden().BoolVar(getAllVersions) app.Switch("wd", "alias for with-docker").Hidden().BoolVar(withDockerMount) @@ -183,7 +189,7 @@ func main() { app.Argument("iu", "alias for ignore-user-config").Hidden().BoolVar(&disableUserConfig) app.Argument("iuc", "alias for ignore-user-config").Hidden().BoolVar(&disableUserConfig) - // Split up the managed parameters from the unmanaged onese + // Split up the managed parameters from the unmanaged ones if extraArgs, ok := os.LookupEnv(envArgs); ok { os.Args = append(os.Args, strings.Split(extraArgs, " ")...) }