Skip to content

Commit

Permalink
Improve debug logging in param parsing
Browse files Browse the repository at this point in the history
Co-authored-by: George L. Yermulnik <yz@yz.kiev.ua>
  • Loading branch information
MatthewJohn and yermulnik committed Jun 14, 2024
1 parent f8eb79d commit 665e0d0
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/param_parsing/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import "os"
func GetParamsFromEnvironment(params Params) Params {
if envVersion := os.Getenv("TF_VERSION"); envVersion != "" {
params.Version = envVersion
logger.Debugf("Found environment variable TF_VERSION: %q", envVersion)
logger.Debugf("Using version from environment variable \"TF_VERSION\": %q", envVersion)
}
if envProduct := os.Getenv("TF_PRODUCT"); envProduct != "" {
params.Product = envProduct
logger.Debugf("Found environment variable TF_PRODUCT: %q", envProduct)
logger.Debugf("Using product from environment variable \"TF_PRODUCT\": %q", envProduct)
}
return params
}
2 changes: 1 addition & 1 deletion lib/param_parsing/terragrunt.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func GetVersionFromTerragrunt(params Params) (Params, error) {
return params, fmt.Errorf("no version found matching %q", versionFromTerragrunt.TerraformVersionConstraint)
}
params.Version = version
logger.Debugf("Using version from Terragrunt file %q: %q", filePath, params.Version)
logger.Debugf(""Using version from %q: %q", filePath, params.Version)

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / integration_tests_linux (ubuntu-latest, 1.22)

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / integration_tests_linux (ubuntu-latest, 1.22)

newline in string

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / integration_tests_windows (windows-latest, 1.22)

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / integration_tests_windows (windows-latest, 1.22)

newline in string

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / fmt_and_vet

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 38 in lib/param_parsing/terragrunt.go

View workflow job for this annotation

GitHub Actions / fmt_and_vet

newline in string
}
return params, nil
}
Expand Down
2 changes: 1 addition & 1 deletion lib/param_parsing/tfswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func GetParamsFromTfSwitch(params Params) (Params, error) {
return params, err
}
params.Version = strings.TrimSpace(string(content))
logger.Debugf("Found version .tfswitchrc file %q: %q", filePath, params.Version)
logger.Debugf(""Using version from %q: %q", filePath, params.Version)

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / integration_tests_linux (ubuntu-latest, 1.22)

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / integration_tests_linux (ubuntu-latest, 1.22)

newline in string

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / integration_tests_windows (windows-latest, 1.22)

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / integration_tests_windows (windows-latest, 1.22)

newline in string

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / fmt_and_vet

syntax error: unexpected Using in argument list; possibly missing comma or )

Check failure on line 23 in lib/param_parsing/tfswitch.go

View workflow job for this annotation

GitHub Actions / fmt_and_vet

newline in string
}
return params, nil
}
Expand Down
6 changes: 3 additions & 3 deletions lib/param_parsing/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ func getParamsTOML(params Params) (Params, error) {

if viperParser.Get("bin") != nil {
params.CustomBinaryPath = viperParser.GetString("bin")
logger.Debugf("Using bin from toml file %q: %q", tomlPath, params.CustomBinaryPath)
logger.Debugf("Using \"bin\" from %q: %q", tomlPath, params.CustomBinaryPath)
}
if viperParser.Get("log-level") != nil {
params.LogLevel = viperParser.GetString("log-level")
}
if viperParser.Get("version") != nil {
params.Version = viperParser.GetString("version")
logger.Debugf("Using version from toml file %q: %q", tomlPath, params.Version)
logger.Debugf("Using \"version\" from %q: %q", tomlPath, params.Version)
}
if configKey := "product"; viperParser.Get(configKey) != nil {
params.Product = viperParser.GetString(configKey)
logger.Debugf("Using product from toml file %q: %q", tomlPath, params.Product)
logger.Debugf("Using %q from %q: %q", configKey, tomlPath, params.Product)
}
}
return params, nil
Expand Down
4 changes: 2 additions & 2 deletions lib/param_parsing/versiontf.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func GetVersionFromVersionsTF(params Params) (Params, error) {
logger.Errorf("No version found matching %q", tfConstraint)
return params, err2
}
logger.Debugf("Using version from Terraform in %q: %q", relPath, params.Version)
params.Version = version
logger.Debugf("Using version from Terraform module at %q: %q", relPath, params.Version)
return params, nil
}

Expand All @@ -70,7 +70,7 @@ func isTerraformModule(params Params) bool {
return false
}
if len(module.RequiredCore) == 0 {
logger.Debugf("No required versions specified by Terraform module: %q", params.ChDirPath)
logger.Debugf("No required version constraints defined by Terraform module at %q", params.ChDirPath)
}
return err == nil && len(module.RequiredCore) > 0
}

0 comments on commit 665e0d0

Please sign in to comment.