Skip to content

Commit

Permalink
Support custom ssm path set by an env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Duchesne committed Nov 2, 2018
1 parent cea99d2 commit 98b23ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import (

const (
// ssm configuration
ssmParameterFolder = "/default/tgf"
defaultSSMParameterFolder = "/default/tgf"
ssmParameterFolderEnvVariable = "TGF_SSM_PATH"

// ssm configuration used to fetch configs from a remote location
remoteDefaultConfigPath = "TGFConfig"
Expand Down Expand Up @@ -134,7 +135,7 @@ func (config *TGFConfig) InitAWS(profile string) error {
// 3. tgf.user.config
// 4. .tgf.config
func (config *TGFConfig) SetDefaultValues() {
config.setDefaultValues(ssmParameterFolder)
config.setDefaultValues(getSSMParameterFolder())
}

func (config *TGFConfig) setDefaultValues(ssmParameterFolder string) {
Expand Down Expand Up @@ -425,6 +426,13 @@ func getTgfConfigFields() []string {
return fields
}

func getSSMParameterFolder() string {
if value, ok := os.LookupEnv(ssmParameterFolderEnvVariable); ok {
return value
}
return defaultSSMParameterFolder
}

// CheckVersionRange compare a version with a range of values
// Check https://github.com/blang/semver/blob/master/README.md for more information
func CheckVersionRange(version, compare string) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func main() {
bold := color.New(color.Bold).SprintfFunc()

descriptionTemplate.Execute(&descriptionBuffer, map[string]interface{}{
"parameterStoreKey": ssmParameterFolder,
"parameterStoreKey": defaultSSMParameterFolder,
"config": configFile,
"options": color.GreenString(strings.Join(getTgfConfigFields(), ", ")),
"readme": link(gitSource + "/blob/master/README.md"),
Expand Down

0 comments on commit 98b23ee

Please sign in to comment.