From 7308f9d5a4da8ea4e2a9a0748ceb0921333c11f4 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Wed, 11 Sep 2024 16:04:43 +0200 Subject: 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. --- prog/rand.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'prog/rand.go') 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 { -- cgit mrf-deployment