From dd767dcb30340be5e393d2ea4980158a54df9717 Mon Sep 17 00:00:00 2001 From: ilackarms Date: Tue, 14 May 2024 13:03:54 -0400 Subject: [PATCH 1/2] fix snapshot template --- .../templates/input/input_snapshot.gotmpl | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/contrib/codegen/templates/input/input_snapshot.gotmpl b/contrib/codegen/templates/input/input_snapshot.gotmpl index 4f30b2c8f..5a2e38ad5 100644 --- a/contrib/codegen/templates/input/input_snapshot.gotmpl +++ b/contrib/codegen/templates/input/input_snapshot.gotmpl @@ -236,22 +236,26 @@ func (s *snapshot{{ $snapshotName }}) SyncStatusesMultiCluster(ctx context.Conte {{/* generate calls to update status here */}} {{- range $group := $groups }} {{ $set_import_prefix := printf "%v_sets" (group_import_name $group) }} + {{- $types_import_prefix := printf "%v_types" (group_import_name $group) }} {{- range $resource := $group.Resources }} {{- $kindPlural := pluralize $resource.Kind }} {{- $kindLowerCamel := lower_camel $resource.Kind }} {{- $kindLowerCamelPlural := pluralize $kindLowerCamel }} {{- if $resource.Status }} if opts.{{ $resource.Kind }} { - for _, obj := range s.{{ $kindPlural }}().List() { - clusterClient, err := mcClient.Cluster(ezkube.GetClusterName(obj)) - if err != nil { - errs = multierror.Append(errs, err) - continue - } - if _, err := controllerutils.UpdateStatusImmutable(ctx, clusterClient, obj); err != nil { - errs = multierror.Append(errs, err) - } - } + + s.{{ $kindPlural }}().Iter(func(_ int, obj *{{ $types_import_prefix }}.{{ $resource.Kind }}) bool { + clusterClient, err := mcClient.Cluster(ezkube.GetClusterName(obj)) + if err != nil { + errs = multierror.Append(errs, err) + return true + } + if _, err := controllerutils.UpdateStatusImmutable(ctx, clusterClient, obj); err != nil { + errs = multierror.Append(errs, err) + } + return true + }) + } {{- end }} {{- end }} From 65920c509e165f9bcbf5f7795c1f2242fd0411a6 Mon Sep 17 00:00:00 2001 From: ilackarms Date: Tue, 14 May 2024 13:05:49 -0400 Subject: [PATCH 2/2] ch --- changelog/v0.39.1/fix-template.yaml | 4 ++++ contrib/codegen/templates/input/input_snapshot.gotmpl | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 changelog/v0.39.1/fix-template.yaml diff --git a/changelog/v0.39.1/fix-template.yaml b/changelog/v0.39.1/fix-template.yaml new file mode 100644 index 000000000..e93c61d23 --- /dev/null +++ b/changelog/v0.39.1/fix-template.yaml @@ -0,0 +1,4 @@ +changelog: +- type: FIX + description: "Fix snapshot template" + issueLink: https://github.com/solo-io/skv2/issues/563 \ No newline at end of file diff --git a/contrib/codegen/templates/input/input_snapshot.gotmpl b/contrib/codegen/templates/input/input_snapshot.gotmpl index 5a2e38ad5..99f05f3e2 100644 --- a/contrib/codegen/templates/input/input_snapshot.gotmpl +++ b/contrib/codegen/templates/input/input_snapshot.gotmpl @@ -255,7 +255,6 @@ func (s *snapshot{{ $snapshotName }}) SyncStatusesMultiCluster(ctx context.Conte } return true }) - } {{- end }} {{- end }}