Skip to content

Commit 180546f

Browse files
committed
Always write JSON
1 parent 39f8ca8 commit 180546f

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

schema/schema.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package schema
22

33
import (
4+
"encoding/json"
45
"errors"
56
"fmt"
67
"os"
@@ -65,12 +66,12 @@ func Generate() (*serializers.Schema, error) {
6566
// Write a schema to disk after alpha-sorting its resources
6667
func Write(schema *serializers.Schema) error {
6768
SortAlphabetically(schema)
68-
out, err := yaml.Marshal(schema)
69+
out, err := json.MarshalIndent(schema, "", " ")
6970
if err != nil {
7071
return err
7172
}
7273

73-
err = os.WriteFile("testtrack/schema.yml", out, 0644)
74+
err = os.WriteFile("testtrack/schema.json", out, 0644)
7475
if err != nil {
7576
return err
7677
}

serializers/serializers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,21 @@ type IdentifierType struct {
8080

8181
// SchemaSplit is the schema-file YAML-marshalable representation of a split's state
8282
type SchemaSplit struct {
83-
Name string `yaml:"name"`
84-
Weights map[string]int `yaml:"weights"`
85-
Decided bool `yaml:"decided,omitempty"`
86-
Owner string `yaml:"owner,omitempty"`
83+
Name string `yaml:"name" json:"name"`
84+
Weights map[string]int `yaml:"weights" json:"weights"`
85+
Decided bool `yaml:"decided,omitempty" json:"decided,omitempty"`
86+
Owner string `yaml:"owner,omitempty" json:"owner,omitempty"`
8787
}
8888

8989
// Schema is the YAML-marshalable representation of the TestTrack schema for
9090
// migration validation and bootstrapping of new ecosystems
9191
type Schema struct {
92-
SerializerVersion int `yaml:"serializer_version"`
93-
SchemaVersion string `yaml:"schema_version"`
94-
Splits []SchemaSplit `yaml:"splits,omitempty"`
95-
IdentifierTypes []IdentifierType `yaml:"identifier_types,omitempty"`
96-
RemoteKills []RemoteKill `yaml:"remote_kills,omitempty"`
97-
FeatureCompletions []FeatureCompletion `yaml:"feature_completions,omitempty"`
92+
SerializerVersion int `yaml:"serializer_version" json:"serializer_version"`
93+
SchemaVersion string `yaml:"schema_version" json:"schema_version"`
94+
Splits []SchemaSplit `yaml:"splits,omitempty" json:"splits,omitempty"`
95+
IdentifierTypes []IdentifierType `yaml:"identifier_types,omitempty" json:"identifier_types,omitempty"`
96+
RemoteKills []RemoteKill `yaml:"remote_kills,omitempty" json:"remote_kills,omitempty"`
97+
FeatureCompletions []FeatureCompletion `yaml:"feature_completions,omitempty" json:"feature_completions,omitempty"`
9898
}
9999

100100
// LegacySchema represents the Rails migration-piggybacked testtrack schema files of old

0 commit comments

Comments
 (0)