Skip to content

Commit

Permalink
Merge pull request #480 from zoncoen/config
Browse files Browse the repository at this point in the history
fix: keep orders of protocol options
  • Loading branch information
zoncoen authored Dec 22, 2024
2 parents bfc1fda + c557b0a commit daba67b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
12 changes: 3 additions & 9 deletions schema/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ func TestLoadConfig(t *testing.T) {
Position: yaml.CommentLinePosition,
},
},
"$.protocols.grpc.request.auth": {
{
Texts: []string{" TODO: fix order issue", " proto:", " imports:", " - proto"},
Position: yaml.CommentHeadPosition,
},
},
},
},
}
Expand Down Expand Up @@ -100,11 +94,11 @@ func TestLoadConfig(t *testing.T) {
{
Key: "grpc",
Value: RawMessage(`request:
auth:
insecure: true
proto:
imports:
- proto`),
- proto
auth:
insecure: true`),
},
},
},
Expand Down
8 changes: 2 additions & 6 deletions schema/testdata/config/valid-with-comment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@ plugins:
protocols:
grpc:
request:
# TODO: fix order issue
# proto:
# imports:
# - proto
auth:
insecure: true
proto:
imports:
- proto
auth:
insecure: true
input:
excludes:
- .ytt.yaml$
Expand Down
4 changes: 2 additions & 2 deletions schema/testdata/config/valid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ plugins:
protocols:
grpc:
request:
auth:
insecure: true
proto:
imports:
- proto
auth:
insecure: true
input:
excludes:
- .ytt.yaml$
Expand Down
2 changes: 1 addition & 1 deletion schema/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (m OrderedMap[K, V]) ToSlice() []OrderedMapItem[K, V] {
// UnmarshalYAML implements yaml.BytesUnmarshaler interface.
func (m *OrderedMap[K, V]) UnmarshalYAML(b []byte) error {
var s yaml.MapSlice
if err := yaml.Unmarshal(b, &s); err != nil {
if err := yaml.UnmarshalWithOptions(b, &s, yaml.UseOrderedMap()); err != nil {
return err
}
if len(s) == 0 {
Expand Down

0 comments on commit daba67b

Please sign in to comment.