-
Notifications
You must be signed in to change notification settings - Fork 65
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
Boolean properties are not being overridden #545
Comments
I just ran a test that successfully overrode the boolean property
|
This problem surfaces when trying to override a Affected properties are: Commands
Components
@kadel @amisevsk, do you know if |
DWO would probably be impacted but it's a transparent change to the end-user so I'm fine with doing necessary updates when we bump our dependency. |
odo will be in the same situation as DWO. When odo updates to this it will require a few changes, but it will be all straight forward. |
I pulled the PR back from review after discussions with the team about enforcing default values since this is not done in the api or library packages. This means we will be forcing consumers to perform nil checks to set the default values according to spec. I reached out to @kadel to discuss the impact to ODO and he suggested that we implement a Getter method to return the default values instead. I think this is a good approach, but there is a limitation where we can't make the boolean field private because we also rely on JSON marshalling which only handles exported fields hence, we can't effectively prevent consumers from using these fields directly when the Getter method is available. While this is not ideal, we can write up something in the API description saying the preferred way to access these values is via the Getter methods. I'm not sure if Setter methods would be useful but if we are planning to tell consumers to refrain from using boolean fields directly, then we should probably add these as well. @amisevsk , @sleshchenko , @davidfestal as owners of this repo and api consumers, any thoughts on this approach? |
I think a getter method is the wrong approach, as we almost never see this sort of thing in Go. From a k8s API perspective, there are already multiple places where dealing with pointers to base types are used -- it's just the tedium that comes with how serialization is implemented in Go. I can understand however that it's more of a problem for odo, etc., where the k8s api doesn't fill defaults during processing. Would dropping |
@amisevsk, Effective Go explains that getters can be used when necessary, but we should be looking to implement them for private fields. I did look into removing |
The K8s implementation for setting default values is to use |
I need to make corresponding changes to the library |
/kind bug
Which area this bug is related to?
/area api
What versions of software are you using?
N/A
Bug Summary
Describe the bug:
I have a main devfile that contains parent overrides but some properties (
isDefault
,hotReloadCapable
) under theexec
command do not get overridden. Similar observation for theparallel
property under thecomposite
command. I wonder if there's an issue with merging boolean propertiesTo Reproduce:
Main devfile:
Test_Parent1.yaml.zip
Parent devfile:
Parent1.yaml.zip
Expected behavior
properties should be overridden to false
Any logs, error output, screenshots etc? Provide the devfile that sees this bug, if applicable.
Here is the result of the flattenedParent in debug mode:
Additional context
Any workaround?
Suggestion on how to fix the bug
The text was updated successfully, but these errors were encountered: