-
Notifications
You must be signed in to change notification settings - Fork 29
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
staticTargeting: add flag to switch default to true #577
Conversation
@@ -44,7 +44,7 @@ type DisruptionSpec struct { | |||
DryRun bool `json:"dryRun,omitempty"` // enable dry-run mode | |||
OnInit bool `json:"onInit,omitempty"` // enable disruption on init | |||
Unsafemode *UnsafemodeSpec `json:"unsafeMode,omitempty"` // unsafemode spec used to turn off safemode safety nets | |||
StaticTargeting bool `json:"staticTargeting,omitempty"` // enable dynamic targeting and cluster observation | |||
StaticTargeting *bool `json:"staticTargeting,omitempty"` // disable dynamic targeting and cluster observation |
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.
Why did this have to become a pointer again? The default for a bool
is already false,
no?
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.
afaik go bool unmarshalling doesn't make a difference between false
and empty value -- if it's not a pointer.
Setting a default to true
would be overridden by a missing/defaulted field that would be interpreted as a false
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.
This PR aims to allow true
to be a possible default value based on the chart
This value, if set, needs to not be overridden by an empty one
edit: fixed the title, sorry about the confusion
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.
I see. There is another option, I think? At the cost of some wordier unmarshaling, we can avoid making this be a pointer everywhere.
If we make the type of StaticTargeting
not bool
, but a custom type: type StaticTargetingFlag bool
, we can add a custom Unmarshal for that type that uses the chart-defined default when empty.
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.
I tried a few things, hoping this would work; without a new dedicated struct type for the field -which would not really help- the UnmarshalJSON function is not called on an empty value 😞
I'm afraid the pointer is unavoidable there
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.
Is it..... too late to change this field to "Targeting" with the options of "dynamic,static,empty", where empty uses the default? Representing three states by using a pointer to a bool feels wrong
4aa861c
to
53ec941
Compare
What does this PR do?
Please briefly describe your changes as well as the motivation behind them:
Code Quality Checklist
Testing
unit
tests orend-to-end
tests.unit
tests orend-to-end
tests.staticTargetingDefault
field set to false, launch a disruption withstaticTargeting
unspecified, check out the description