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

Add mapstructure tags to config structures for viper config read package support #69

Closed
emrekosen opened this issue Oct 23, 2023 · 5 comments · Fixed by #76
Closed

Add mapstructure tags to config structures for viper config read package support #69

emrekosen opened this issue Oct 23, 2023 · 5 comments · Fixed by #76
Assignees

Comments

@emrekosen
Copy link
Contributor

Is your feature request related to a problem? Please describe.
When using viper package to read config files, we can't parse config directly to struct provided by package which is config.Connector . It's because viper uses mapstructure tags and we have yaml tags. With yaml:",inline" tag dcp field in config.Connector, viper unable to read inlined config fields.

Describe the solution you'd like
If we add mapstructure tags to config struct it will be resolved.

@emrekosen
Copy link
Contributor Author

I can do this since it's 1 minute solution :)
Also we need this in go-dcp and other projects.

@Abdulsametileri
Copy link
Member

Thank you, I want to ask a question. If we did this, what would be their benefits?

@emrekosen
Copy link
Contributor Author

Right now we can't read configs with viper package by just parsing viper data to config.Connector struct. If anybody wants to use viper it's not possible. In our team we use viper for dynamic configuration also and it will provide that.

Our current logic is parsing config file to another struct and map it to config.Connector.

I don't know if i explained well. I can provide more detail.

@mhmtszr
Copy link
Member

mhmtszr commented Oct 23, 2023

@emrekosen I understand your concerns you are right. If we remove the inline tag and add mapstructure, will it work the same? We need to test it. If you find an available time I would be happy to review your pull request.

@emrekosen
Copy link
Contributor Author

@mhmtszr No we don't need to remove inline tag, we can use both yaml and mapstructure. With a tag like yaml:",inline" mapstructure:",squash" we can support both inline yaml and inline mapstrucure. I will implement and create pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants