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 YAML struct tags to all types #41

Open
saheljalal opened this issue Jan 22, 2022 · 2 comments
Open

Add YAML struct tags to all types #41

saheljalal opened this issue Jan 22, 2022 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@saheljalal
Copy link
Collaborator

Forgot to add YAML struct tags so the default marshaling will just turn CamelCase fields into lowercase like camelcase.

This isn't nice so let's fix it to have the common convention of camel case keys.

@saheljalal saheljalal added enhancement New feature or request good first issue Good for newcomers labels Jan 22, 2022
@RishiKumarRay
Copy link

Can yo give any example of adding struct tag ?

@saheljalal
Copy link
Collaborator Author

@RishiKumarRay Sure, you can check the yaml package for more details here: https://github.com/go-yaml/yaml

The general idea for struct tags are to add them as part of the type definition like done here for both JSON and YAML:

type Foo struct {
	SomeVar int 			`json:"someVar" yaml:"someVar"`
	AnotherVar string	`json:"anotherVar" yaml:"anotherVar"`
}

This allows marshal and unmarshal to read/write the fields as specified. Otherwise they default and in this case become lowercase keys.

For this ticket, there is a small caveat that we need to make sure we migrate from the legacy format (during first read) and then can write the new manifest. This will handle the upgrade case.

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants