Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2517 fix parsing cache key construction #2518

Merged
merged 5 commits into from
Jul 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions config/config_partial.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func PartialParseConfigFile(
var terragruntConfigCache = NewTerragruntConfigCache()

// Wrapper of PartialParseConfigString which checks for cached configs.
// configString, includeFromChild and decodeList are used for the cache key,
// filename, configString, includeFromChild and decodeList are used for the cache key,
// by getting the default value (%#v) through fmt.
func TerragruntConfigFromPartialConfigString(
configString string,
Expand All @@ -169,19 +169,19 @@ func TerragruntConfigFromPartialConfigString(
decodeList []PartialDecodeSectionType,
) (*TerragruntConfig, error) {
if terragruntOptions.UsePartialParseConfigCache {
var cacheKey = fmt.Sprintf("%#v-%#v-%#v", configString, includeFromChild, decodeList)
var cacheKey = fmt.Sprintf("%#v-%#v-%#v-%#v", filename, configString, includeFromChild, decodeList)
var config, found = terragruntConfigCache.Get(cacheKey)

if !found {
terragruntOptions.Logger.Debugf("Cache miss for '%s' (partial parsing).", filename)
terragruntOptions.Logger.Debugf("Cache miss for '%s' (partial parsing), decodeList: '%v'.", filename, decodeList)
tgConfig, err := PartialParseConfigString(configString, terragruntOptions, includeFromChild, filename, decodeList)
if err != nil {
return nil, err
}
config = *tgConfig
terragruntConfigCache.Put(cacheKey, config)
} else {
terragruntOptions.Logger.Debugf("Cache hit for '%s' (partial parsing).", filename)
terragruntOptions.Logger.Debugf("Cache hit for '%s' (partial parsing), decodeList: '%v'.", filename, decodeList)
}

return &config, nil
Expand All @@ -193,13 +193,14 @@ func TerragruntConfigFromPartialConfigString(
// PartialParseConfigString partially parses and decodes the provided string. Which blocks/attributes to decode is
// controlled by the function parameter decodeList. These blocks/attributes are parsed and set on the output
// TerragruntConfig. Valid values are:
// - DependenciesBlock: Parses the `dependencies` block in the config
// - DependencyBlock: Parses the `dependency` block in the config
// - TerraformBlock: Parses the `terraform` block in the config
// - TerragruntFlags: Parses the boolean flags `prevent_destroy` and `skip` in the config
// - TerragruntVersionConstraints: Parses the attributes related to constraining terragrunt and terraform versions in
// the config.
// - RemoteStateBlock: Parses the `remote_state` block in the config
// - DependenciesBlock: Parses the `dependencies` block in the config
// - DependencyBlock: Parses the `dependency` block in the config
// - TerraformBlock: Parses the `terraform` block in the config
// - TerragruntFlags: Parses the boolean flags `prevent_destroy` and `skip` in the config
// - TerragruntVersionConstraints: Parses the attributes related to constraining terragrunt and terraform versions in
// the config.
// - RemoteStateBlock: Parses the `remote_state` block in the config
//
// Note that the following blocks are always decoded:
// - locals
// - include
Expand Down