Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate definition of predicate #563

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/v0.36.1/fix-duplicate-predicate.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/9274
resolvesIssue: false
description: Fixes the issue of multiple declarations of Predicate when multiple snapshots are generated

2 changes: 2 additions & 0 deletions pkg/api/v1/resources/core/metadata_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ func (m *Metadata) Ref() *ResourceRef {
func (m *Metadata) Match(ref *ResourceRef) bool {
return m.GetNamespace() == ref.GetNamespace() && m.GetName() == ref.GetName()
}

type Predicate func(metadata *Metadata) bool
4 changes: 1 addition & 3 deletions pkg/code-generator/codegen/templates/snapshot_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ func (s *{{ .GoName }}Snapshot) RemoveFromResourceList(resource resources.Resour
}
}

type Predicate func(metadata *core.Metadata) bool

func (s *{{ .GoName }}Snapshot) RemoveMatches(predicate Predicate) {
func (s *{{ .GoName }}Snapshot) RemoveMatches(predicate core.Predicate) {
{{- range .Resources }}
var {{ upper_camel .PluralName }} {{ .ImportPrefix }}{{ .Name }}List
for _, res := range s.{{ upper_camel .PluralName }} {
Expand Down
4 changes: 1 addition & 3 deletions test/mocks/v1/testing_snapshot.sk.go

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

4 changes: 1 addition & 3 deletions test/mocks/v1alpha1/testing_snapshot.sk.go

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

4 changes: 1 addition & 3 deletions test/mocks/v2alpha1/testing_snapshot.sk.go

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

Loading