Skip to content

Commit efed2ea

Browse files
committed
doc: Adds extra documentation on the ApplyReplacement logic
1 parent 91bdd9f commit efed2ea

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

internal/common/customplanmodifier/unknown_replacement.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type UnknownReplacements[ResourceInfo any] struct {
3737

3838
// AddReplacement call will only be used if the attribute is Unknown in the plan. Only valid for `computed` attributes.
3939
func (u *UnknownReplacements[ResourceInfo]) AddReplacement(name string, call UnknownReplacementCall[ResourceInfo]) {
40-
// todo: Validate the name exists in the schema CLOUDP-309460
40+
// todo: Validate the name exists in the schema and that the attribute is marked with `computed` CLOUDP-309460
4141
_, found := u.Replacements[name]
4242
if found {
4343
panic(fmt.Sprintf("Replacement already exists for %s", name))
@@ -65,6 +65,8 @@ func (u *UnknownReplacements[ResourceInfo]) AddKeepUnknownsExtraCall(call AddKee
6565
// If there is no explicit replacement function, it will use the default replacer that respects the keepUnknown attributes.
6666
// The calls are done top-down, for example replication_specs.*.id before replication_specs.*.region_configs.*.electable_specs
6767
// Same levels are sorted alphabetically, for example ...region_configs.electable_specs before ...region_configs.read_only_specs
68+
// If the replacement function is called for a path that is an ancestor of another path, it will skip the replacement for the child path.
69+
// For example: if ..read_only_specs has a replacement function and is called then ..read_only_specs.disk_iops will not be called or use keepUnknown logic.
6870
func (u *UnknownReplacements[ResourceInfo]) ApplyReplacements(ctx context.Context, diags *diag.Diagnostics) {
6971
replacedPaths := []path.Path{}
7072
ancestorHasProcessed := func(p path.Path) bool {

internal/service/advancedclustertpf/model_to_ClusterDescription20240805.go

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ func newReplicationSpec20240805(ctx context.Context, input types.List, diags *di
9494
resp := make([]admin.ReplicationSpec20240805, len(input.Elements()))
9595
for i := range elements {
9696
item := &elements[i]
97+
// Choosing to never send ZoneId in PATCH request. It is inferred by the backend.
9798
resp[i] = admin.ReplicationSpec20240805{
9899
Id: conversion.NilForUnknownOrEmptyString(item.ExternalId),
99100
RegionConfigs: newCloudRegionConfig20240805(ctx, item.RegionConfigs, diags),

internal/service/advancedclustertpf/plan_modifier.go

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ var (
1919
"electable_specs": analyticsAndElectableSpecsReplaceUnknown,
2020
"auto_scaling": autoScalingReplaceUnknown,
2121
"analytics_auto_scaling": autoScalingReplaceUnknown,
22-
// TODO: Add the other computed attributes
2322
}
2423
// Change mappings uses `attribute_name`, it doesn't care about the nested level.
2524
// However, it doesn't stop calling `replication_specs.**.attribute_name`.

0 commit comments

Comments
 (0)