Skip to content

Commit

Permalink
fix initial map (#497)
Browse files Browse the repository at this point in the history
* fix initial map

* changelog

* go 1.18

* go 1.18

* revert the proto change
  • Loading branch information
EItanya authored Jul 1, 2022
1 parent 39c9025 commit 460d42b
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PACKAGE_PATH:=github.com/solo-io/solo-kit
OUTPUT_DIR ?= $(ROOTDIR)/_output
SOURCES := $(shell find . -name "*.go" | grep -v test.go)

GO_BUILD_FLAGS := GO111MODULE=on CGO_ENABLED=0 GOARCH=amd64
GO_BUILD_FLAGS := GO111MODULE=on CGO_ENABLED=0

#----------------------------------------------------------------------------------
# Version, Release
Expand Down
6 changes: 6 additions & 0 deletions changelog/v0.30.1/fix-emitter-initial-map.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/gloo/issues/5554
resolvesIssue: false
description: >
Ensure that the emitter namespaced map is hydrated with the initial list data.
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ func (c *{{ lower_camel .GoName }}Emitter) Snapshots(watchNamespaces []string, o
currentSnapshot := {{ .GoName }}Snapshot{}
{{- range .Resources}}
{{- if not .ClusterScoped }}
{{ lower_camel .PluralName }}ByNamespace := make(map[string]{{ .ImportPrefix }}{{ .Name }}List)
{{- end }}
{{- end }}
for _, namespace := range watchNamespaces {
{{- range .Resources}}
{{- if (not .ClusterScoped) }}
Expand All @@ -188,6 +194,7 @@ func (c *{{ lower_camel .GoName }}Emitter) Snapshots(watchNamespaces []string, o
return nil, nil, errors.Wrapf(err, "initial {{ .Name }} list")
}
initial{{ upper_camel .Name }}List = append(initial{{ upper_camel .Name }}List, {{ lower_camel .PluralName }}...)
{{ lower_camel .PluralName }}ByNamespace[namespace] = {{ lower_camel .PluralName }}
}
{{ lower_camel .Name }}NamespacesChan, {{ lower_camel .Name }}Errs, err := c.{{ lower_camel .Name }}.Watch(namespace, opts)
if err != nil {
Expand Down Expand Up @@ -282,11 +289,6 @@ func (c *{{ lower_camel .GoName }}Emitter) Snapshots(watchNamespaces []string, o
}
}
{{- range .Resources}}
{{- if not .ClusterScoped }}
{{ lower_camel .PluralName }}ByNamespace := make(map[string]{{ .ImportPrefix }}{{ .Name }}List)
{{- end }}
{{- end }}
defer func() {
close(snapshots)
// we must wait for done before closing the error chan,
Expand Down
4 changes: 3 additions & 1 deletion pkg/multicluster/v1/kubeconfigs_snapshot_emitter.sk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions test/mocks/v1/testing_snapshot_emitter.sk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion test/mocks/v1alpha1/testing_snapshot_emitter.sk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions test/mocks/v2alpha1/testing_snapshot_emitter.sk.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 460d42b

Please sign in to comment.