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 4f30b2c8f..99f05f3e2 100644 --- a/contrib/codegen/templates/input/input_snapshot.gotmpl +++ b/contrib/codegen/templates/input/input_snapshot.gotmpl @@ -236,22 +236,25 @@ 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 }}