-
Notifications
You must be signed in to change notification settings - Fork 66
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
Replace JSON parser with YAML parser for *-configs #468
Conversation
// JSONFileRaw is the raw JSON file read as bytes used for future parsing | ||
JSONFileRaw []byte | ||
// The YAMLFileName is file name of the instance YAML file | ||
YAMLFileName string |
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 is a breaking change and there is code in multiple projects that is already written using JSONFileName
. You should mark the current field as deprecated using // Deprecated:
comment and when creating this object you have the new field like ConfigFileName
instead.
codegen/module.go
Outdated
// JSONClassConfig maps onto a json configuration for a class type | ||
type JSONClassConfig struct { | ||
// YAMLClassConfig maps onto a YAML configuration for a class type | ||
type YAMLClassConfig struct { |
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 is technically a breaking change but I don't see anyone using it so I'm fine. If you can try to make it unexported instead of exported.
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.
YAMLClassConfig -> yamlClassConfig
codegen/module.go
Outdated
// Name is the class instance name used to identify the module as a | ||
// dependency. The combination of the class Name and this instance name | ||
// is unique. | ||
Name string `json:"name"` | ||
Name string `yaml:"name"` |
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.
Rather than replacing these annotations you should write yaml:"name" json:"name"
so that existing code that decodes into these structs can do so.
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.
json annotation added for all exposed structs
codegen/post_gen_hooks.go
Outdated
return errors.Wrapf( | ||
err, | ||
"error parsing client-config.json for client %q", | ||
"error parsing client-config.yaml for client %q", |
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.
nit: Since it could be either client-config.json
or client-config.yaml
you should use the import path here rather than hard coding it.
@@ -698,76 +698,76 @@ func (system *ModuleSystem) readInstance( | |||
instanceDirectory string, | |||
) (*ModuleInstance, error) { | |||
|
|||
jsonFileName := className + configSuffix | |||
yamlFileName := className + configSuffix |
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.
I think we should be looking for both foo-config.yaml
and foo-config.json
, preferring the .yaml
file if it exists, otherwise falling back to .json
for backwards compatibility.
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.
"configSuffix" is still "json". In the future diff, we will create a helper function to get the correct fileName for both json and yaml.
codegen/template.go
Outdated
@@ -60,7 +60,7 @@ var defaultFuncMap = tmpl.FuncMap{ | |||
"dec": decrement, | |||
"basePath": filepath.Base, | |||
"pascal": PascalCase, | |||
"jsonMarshal": jsonMarshal, | |||
"yamlMarshal": yamlMarshal, |
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.
nit: from what I could tell this function is unused in the template.
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.
function removed
0ca58f7
to
ea89ee4
Compare
codegen/gateway.go
Outdated
f, | ||
) | ||
} | ||
} | ||
|
||
clientSpec := &ClientSpec{ | ||
JSONFile: instance.JSONFileName, |
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.
There is existing code that relies on JSONFile
property. Can you keep the existing property and add YAMLFile
as a new property?
ea89ee4
to
77ac5c3
Compare
Dependencies: dependencies, | ||
ResolvedDependencies: map[string][]*ModuleInstance{}, | ||
RecursiveDependencies: map[string][]*ModuleInstance{}, | ||
DependencyOrder: []string{}, | ||
JSONFileName: jsonFileName, |
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.
Keep JSONFileRaw
JSONFileRaw []byte | ||
// The JSONFileName is file name of the instance JSON file | ||
JSONFileName string // Deprecated | ||
// The YAMLFileName is file name of the instance YAML file |
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.
Missing JSONFileRaw
codegen/post_gen_hooks.go
Outdated
@@ -40,22 +40,22 @@ const ( | |||
|
|||
// helper struct to pull out the fixture config | |||
type moduleConfig struct { | |||
Config *config `json:"config"` | |||
Config *config `yaml:"config"` |
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.
Missing json
tags
77ac5c3
to
b067e04
Compare
No description provided.