Skip to content

Commit

Permalink
Revert "implement json.Marshaler in snapshot templates"
Browse files Browse the repository at this point in the history
Revert "implement json.Marshaler in snapshot templates"
  • Loading branch information
sam-heilbron authored Jun 17, 2024
2 parents ecc4f32 + 218c77d commit 1baf6de
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 43 deletions.
8 changes: 8 additions & 0 deletions changelog/v0.35.3/revert-json-apisnapshot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/gloo-mesh-enterprise/issues/16010
resolvesIssue: false
description: |
Reverts the change in https://github.com/solo-io/solo-kit/pull/554 (released in v0.35.1) that implemented json.Marshaler in snapshot templates.
That change was unused (the initial issue was resolved without it).
However, when pulled into the https://github.com/solo-io/gloo repo to get the subsequent change, it resulted in test failures; reverting to fix the tests.
11 changes: 1 addition & 10 deletions pkg/code-generator/codegen/templates/snapshot_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import (
"text/template"
)

const backtick = "`"

var ResourceGroupSnapshotTemplate = template.Must(template.New("resource_group_snapshot").Funcs(Funcs).Parse(
`package {{ .Project.ProjectConfig.Version }}
{{/* creating a variable that lets us understand how many resources are hashable input resources. */}}
import (
"encoding/binary"
"encoding/json"
"fmt"
"hash"
"hash/fnv"
Expand All @@ -27,11 +24,9 @@ import (
"go.uber.org/zap"
)
var _ json.Marshaler = new({{ .GoName }}Snapshot)
type {{ .GoName }}Snapshot struct {
{{- range .Resources}}
{{ upper_camel .PluralName }} {{ .ImportPrefix }}{{ .Name }}List ` + backtick + `json:"{{ lower_camel .PluralName }}"` + backtick + `
{{ upper_camel .PluralName }} {{ .ImportPrefix }}{{ .Name }}List
{{- end}}
}
Expand Down Expand Up @@ -88,10 +83,6 @@ func (s {{ .GoName }}Snapshot) HashFields() []zap.Field {
return append(fields, zap.Uint64("snapshotHash", snapshotHash))
}
func (s {{ .GoName }}Snapshot) MarshalJSON() ([]byte, error) {
return json.Marshal(&s)
}
func (s *{{ .GoName }}Snapshot) GetResourcesList(resource resources.Resource) (resources.ResourceList, error) {
switch resource.(type) {
{{- range .Resources }}
Expand Down
23 changes: 8 additions & 15 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.

9 changes: 1 addition & 8 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.

13 changes: 3 additions & 10 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.

0 comments on commit 1baf6de

Please sign in to comment.