From 2781a2c330ce3f8aa6899cf7958907e1e6df69ca Mon Sep 17 00:00:00 2001 From: Lubomir Kaplan Date: Mon, 20 Apr 2026 12:43:55 +0200 Subject: [PATCH 1/2] fix(): expand ignore changes path for converted singleton lists Signed-off-by: Lubomir Kaplan --- pkg/controller/external_tfpluginsdk.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/pkg/controller/external_tfpluginsdk.go b/pkg/controller/external_tfpluginsdk.go index ad3334ed..87caafca 100644 --- a/pkg/controller/external_tfpluginsdk.go +++ b/pkg/controller/external_tfpluginsdk.go @@ -323,7 +323,7 @@ func (c *TerraformPluginSDKConnector) Connect(ctx context.Context, mg xpresource }, nil } -func filterInitExclusiveDiffs(tr resource.Terraformed, instanceDiff *tf.InstanceDiff) error { //nolint:gocyclo +func filterInitExclusiveDiffs(config *config.Resource, tr resource.Terraformed, instanceDiff *tf.InstanceDiff) error { //nolint:gocyclo if instanceDiff == nil || instanceDiff.Empty() { return nil } @@ -338,6 +338,25 @@ func filterInitExclusiveDiffs(tr resource.Terraformed, instanceDiff *tf.Instance } initProviderExclusiveParamKeys := getTerraformIgnoreChanges(paramsForProvider, paramsInitProvider) + + /* process singleton list expansions */ + initProviderExclusiveParamKeysConverted := []string{} + for _, key := range initProviderExclusiveParamKeys { + matched := false + for _, p := range config.TFListConversionPaths() { + matchPrefix := fmt.Sprintf("%s.", p) + if strings.HasPrefix(key, matchPrefix) { + initProviderExclusiveParamKeysConverted = append(initProviderExclusiveParamKeysConverted, strings.Replace(key, matchPrefix, fmt.Sprintf("%s0.", matchPrefix), 1)) + matched = true + continue + } + } + if !matched { + initProviderExclusiveParamKeysConverted = append(initProviderExclusiveParamKeysConverted, key) + } + } + initProviderExclusiveParamKeys = initProviderExclusiveParamKeysConverted + for _, keyToIgnore := range initProviderExclusiveParamKeys { for attributeKey := range instanceDiff.Attributes { keyToIgnoreAsPrefix := fmt.Sprintf("%s.", keyToIgnore) @@ -451,7 +470,7 @@ func (n *terraformPluginSDKExternal) getResourceDataDiff(tr resource.Terraformed } if resourceExists { - if err := filterInitExclusiveDiffs(tr, instanceDiff); err != nil { + if err := filterInitExclusiveDiffs(n.config, tr, instanceDiff); err != nil { return nil, errors.Wrap(err, "failed to filter the diffs exclusive to spec.initProvider in the terraform.InstanceDiff") } } From adc87b258a1eddd705d7ec557a3946cabf5c4df2 Mon Sep 17 00:00:00 2001 From: Lubomir Kaplan Date: Mon, 20 Apr 2026 13:25:02 +0200 Subject: [PATCH 2/2] fix cycle continuation istead of break in singleton list expansions Signed-off-by: Lubomir Kaplan --- pkg/controller/external_tfpluginsdk.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/external_tfpluginsdk.go b/pkg/controller/external_tfpluginsdk.go index 87caafca..9c0d0a97 100644 --- a/pkg/controller/external_tfpluginsdk.go +++ b/pkg/controller/external_tfpluginsdk.go @@ -348,7 +348,7 @@ func filterInitExclusiveDiffs(config *config.Resource, tr resource.Terraformed, if strings.HasPrefix(key, matchPrefix) { initProviderExclusiveParamKeysConverted = append(initProviderExclusiveParamKeysConverted, strings.Replace(key, matchPrefix, fmt.Sprintf("%s0.", matchPrefix), 1)) matched = true - continue + break } } if !matched {