-
Notifications
You must be signed in to change notification settings - Fork 57
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
Function to convert Go struct back to config.Value
#935
Conversation
config.Value
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.
Hm, I'm curious. If we can convert a go struct into config.Value, what would be the difference between this and Merge(ref, ConvertToConfigValue(src))
? It might actually be about the same?
// Dereference pointer if necessary | ||
for srcv.Kind() == reflect.Pointer { | ||
if srcv.IsNil() { | ||
return config.NilValue, nil |
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.
Should we return ref
here instead?
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.
No; if the Go structure has nilled a pointer that wasn't nil before, it means that chunk of configuration (or pointer to primitive value) is no longer valid and should not show up in the returned config.Value
.
Good point! It comes close but is not the same. Two differences come to mind:
|
Changes
This PR is the counterpart to #904. With this change, we are able to convert a
config.Value
into a Go struct, make modifications to the Go struct, and reflect those changes in a newconfig.Value
.This functionality allows us to incrementally introduce this configuration representation to existing bundle mutators. Bundle mutators expect a
*bundle.Bundle
argument and mutate its configuration directly. These mutations are not reflected in the correspondingconfig.Value
(once introduced), which means we cannot use theconfig.Value
as source of truth until we update all mutators. To address this, we can runconvert.ToTyped
andconvert.FromTyped
at the mutator boundary (frombundle.Apply
) and capture changes made to the Go struct. Then we can incrementally make mutators aware of theconfig.Value
configuration and have them mutate that structure directly.Tests
New unit tests pass.
Manual spot checks against the bundle configuration type.