Skip to content
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

fix(convert): Support YAML anchors in plugin options #2733

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/config/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func gen(n *yaml.Node) (interface{}, error) {

}

case yaml.AliasNode:
return gen(n.Alias)

default:
return nil, fmt.Errorf("unknown yaml value: %s (%s)", n.Value, n.Tag)

Expand Down
47 changes: 47 additions & 0 deletions internal/config/convert/convert_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package convert

import (
"testing"

"gopkg.in/yaml.v3"
)

const anchor = `
sql:
- schema: query.sql
queries: query.sql
engine: postgresql
codegen:
- out: gateway/src/gateway/services/organization
plugin: py
options: &base-options
query_parameter_limit: 1
package: gateway
output_models_file_name: null
emit_module: true
emit_generators: false
emit_async: true

- schema: query.sql
queries: query.sql
engine: postgresql
codegen:
- out: gateway/src/gateway/services/project
plugin: py
options: *base-options
`

type config struct {
SQL yaml.Node `yaml:"sql"`
}

func TestAlias(t *testing.T) {
var a config
err := yaml.Unmarshal([]byte(anchor), &a)
if err != nil {
t.Fatal(err)
}
if _, err := gen(&a.SQL); err != nil {
t.Fatal(err)
}
}
Loading