From 85ff36955e9437bdf940c44f8f7a97a01ece5fe9 Mon Sep 17 00:00:00 2001 From: Alexander Untch Date: Mon, 3 Apr 2023 17:19:20 +0200 Subject: [PATCH] fix: include missing param in parsing cache key construction --- config/config_partial.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/config/config_partial.go b/config/config_partial.go index 63718a9395..94b87ac65c 100644 --- a/config/config_partial.go +++ b/config/config_partial.go @@ -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, @@ -169,11 +169,11 @@ 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 @@ -181,7 +181,7 @@ func TerragruntConfigFromPartialConfigString( 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 @@ -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