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 support to config for setting and writing blank values #143

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

samcoe
Copy link
Contributor

@samcoe samcoe commented Oct 25, 2023

This PR updates the implementation of config.Set to set null yaml values instead of blank strings when passed a blank string as a value argument. We are not relying on the previous behavior anywhere and this allows us to create config keys even if they do not have any nested keys yet. We already work around this limitation in auth login and we can finally remove that code. Additionally this is necessary for the work being done in this branch which is not quiet ready for a PR yet.

@samcoe samcoe self-assigned this Oct 25, 2023
@samcoe samcoe marked this pull request as ready for review October 26, 2023 10:23
Comment on lines +124 to +128
val := yamlmap.StringValue(value)
if value == "" {
val = yamlmap.NullValue()
}
m.SetEntry(keys[len(keys)-1], val)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially, I assumed we'd have the ability to set the config to null values, not that all empty strings will be null values.

I don't know a definitive way this will be a problem assuming this is YAML and should hopefully work 🤞

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is YAML so they are more or less equivalent, which is why I went this direction instead of introducing a new function like SetNull. It felt mostly like implementation detail that the user shouldn't be concerned with. The user still receives an empty string using Get if they Set an empty string which felt like the only contract that we need to maintain here.

@samcoe samcoe merged commit debe718 into trunk Oct 27, 2023
@samcoe samcoe deleted the config-null-values branch October 27, 2023 08:02
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 this pull request may close these issues.

2 participants