-
Notifications
You must be signed in to change notification settings - Fork 339
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
DeepCachingType -- "NEVER" is now default #1844
Conversation
lib/go-tc/enum.go
Outdated
@@ -191,7 +191,7 @@ type DeepCachingType string | |||
const ( | |||
DeepCachingTypeAlways = DeepCachingType("ALWAYS") | |||
DeepCachingTypeNever = DeepCachingType("NEVER") | |||
DeepCachingTypeInvalid = DeepCachingType("") | |||
DeepCachingTypeInvalid = DeepCachingType("INVALID") |
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.
The default value of the enum should match the default value of the type, i.e. ""
. So per
case "":
+ // default when omitted
+ return DeepCachingTypeNever
below, DeepCachingTypeNever = DeepCachingType("NEVER")
should be
DeepCachingTypeNever = DeepCachingType("")
This will prevent errors if someone default-initializes a DeepCachingType
, e.g. t := DeepCachingType{}
or t := DeepCachingType("")
expecting it to be the default for the enum.
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.
good point.. I'll change that..
Refer to this link for build results (access rights to CI server needed): |
Is this ever serialised to JSON, e.g. for the Client/Server? Might need That will make everything but |
Refer to this link for build results (access rights to CI server needed): |
adding tests to verify JSON conversions |
@rob05c helpful suggestions.. thanks.. anything more? |
fyi -- would love to see this get into 2.2 so no one starts relying on current behavior |
Looks good! Sorry about the delay, I didn't think about JSON at first. Again, there is no perfect solution, but IMO this is the best option, it gives us a correct default that serializes and stringifies correctly, and works if someone default-constructs either the enum or things containing it, A As the RM, I'll make sure this gets in 2.2. |
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.
Haven't tested running TO yet, but the code looks good.
Refer to this link for build results (access rights to CI server needed): |
looks good to me 👍 |
@rob05c Gonna leave this one up to you to merge for 2.2 |
When creating a new deliveryservice, the new DeepCachingType entry should have a reasonable default that's not invalid.
@rawlinp this is what I was suggesting...