Skip to content

Commit

Permalink
Revert "implement json.Marshaler in snapshot templates"
Browse files Browse the repository at this point in the history
  • Loading branch information
arianaw66 authored Jun 17, 2024
1 parent ecc4f32 commit ffe0eaa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 49 deletions.
6 changes: 0 additions & 6 deletions changelog/v0.35.1/json-apisnapshot.yaml

This file was deleted.

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 ffe0eaa

Please sign in to comment.