diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-09-11 16:04:43 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-09-11 14:55:22 +0000 |
| commit | 7308f9d5a4da8ea4e2a9a0748ceb0921333c11f4 (patch) | |
| tree | 3c4c0d6bdfd082e089a5514c0c06e7eabec864f9 /prog/rand.go | |
| parent | fd0ad8a3f899365059471f5fdefdc73082ce0777 (diff) | |
prog: allow deeper nesting of conditional fields patching
There is a totally valid situation when we could be recursively patching
conditional fields: if by changing a field's value we insert new
resource constructor calls. It's a bug to skip conditional field
patching for them.
Allow up to 2 nested patchConditionalFields() calls and panic if there
happen to be more.
Add a test that reproduces the situation described above.
Diffstat (limited to 'prog/rand.go')
| -rw-r--r-- | prog/rand.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/prog/rand.go b/prog/rand.go index b15871b8a..760f7a904 100644 --- a/prog/rand.go +++ b/prog/rand.go @@ -25,10 +25,10 @@ const ( type randGen struct { *rand.Rand - target *Target - inGenerateResource bool - inPatchConditional bool - recDepth map[string]int + target *Target + inGenerateResource bool + patchConditionalDepth int + recDepth map[string]int } func newRand(target *Target, rs rand.Source) *randGen { |
