-
Notifications
You must be signed in to change notification settings - Fork 6
feat: JSON schemas #70
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3885df5
Read JSON schemas
rzane 2bea3de
Separate validation from parsing
rzane 2f167a8
Stop using yaml.MapSlice
rzane 39f8ca8
Remove WeightsFromYAML and ToYAML
rzane 60c986e
Write JSON by default, but continue writing YAML if yaml exists
rzane e25bd6f
Bump the version
rzane ecb6eef
Fix segfault in `testtrack schema generate` (unrelated fix)
rzane 188e546
Fix broken symlink detection logic
rzane 3cff4bb
Change the signature for `findSchemaPath`
rzane 49bb2d8
Update docs/help information to include schema.json
rzane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| SHELL = /bin/sh | ||
|
|
||
| VERSION=1.7.1 | ||
| VERSION=1.8.0 | ||
| BUILD=`git rev-parse HEAD` | ||
|
|
||
| LDFLAGS=-ldflags "-w -s \ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,13 +83,14 @@ func IsFeatureGateFromName(name string) bool { | |
|
|
||
| // FromFile reifies a migration from the yaml serializable representation | ||
| func FromFile(migrationVersion *string, serializable *serializers.SplitYAML) (migrations.IMigration, error) { | ||
| weights, err := WeightsFromYAML(serializable.Weights) | ||
| weights, err := NewWeights(serializable.Weights) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &Split{ | ||
| migrationVersion: migrationVersion, | ||
| name: &serializable.Name, | ||
| owner: &serializable.Owner, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Manual testing revealed that the |
||
| weights: weights, | ||
| }, nil | ||
| } | ||
|
|
@@ -111,7 +112,7 @@ func (s *Split) File() *serializers.MigrationFile { | |
| SerializerVersion: serializers.SerializerVersion, | ||
| Split: &serializers.SplitYAML{ | ||
| Name: *s.name, | ||
| Weights: s.weights.ToYAML(), | ||
| Weights: *s.weights, | ||
| Owner: *s.owner, | ||
| }, | ||
| } | ||
|
|
@@ -152,13 +153,13 @@ func (s *Split) SameResourceAs(other migrations.IMigration) bool { | |
| func (s *Split) ApplyToSchema(schema *serializers.Schema, migrationRepo migrations.Repository, _idempotently bool) error { | ||
| for i, candidate := range schema.Splits { // Replace | ||
| if candidate.Name == *s.name { | ||
| schemaWeights, err := WeightsFromYAML(candidate.Weights) | ||
| schemaWeights, err := NewWeights(candidate.Weights) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| schemaWeights.Merge(*s.weights) | ||
| schema.Splits[i].Decided = false | ||
| schema.Splits[i].Weights = schemaWeights.ToYAML() | ||
| schema.Splits[i].Weights = *schemaWeights | ||
| return nil | ||
| } | ||
| } | ||
|
|
@@ -169,15 +170,15 @@ func (s *Split) ApplyToSchema(schema *serializers.Schema, migrationRepo migratio | |
| weights.Merge(*s.weights) | ||
| schema.Splits = append(schema.Splits, serializers.SchemaSplit{ | ||
| Name: *s.name, | ||
| Weights: weights.ToYAML(), | ||
| Weights: *weights, | ||
| Decided: false, | ||
| }) | ||
| return nil | ||
| } | ||
| } | ||
| schemaSplit := serializers.SchemaSplit{ // Create | ||
| Name: *s.name, | ||
| Weights: s.weights.ToYAML(), | ||
| Weights: *s.weights, | ||
| Decided: false, | ||
| Owner: *s.owner, | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is trying to detect a broken symlink, and it isn't working correctly on main.
The reason it wasn't working is because
os.Readlinksucceeds, even for broken symlinks, which causesos.ReadFileto be called, which fails.I removed the symlink detection stuff. I don't think we really care if these are symlinks or not, and
os.ReadFileis capable of reading a symlink. If theos.ReadFilesuggests that the file doesn't exist, we'll skip it.