-
Notifications
You must be signed in to change notification settings - Fork 62
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
FR-5402 - ubuntu-image classic always passes --vcs=auto
to germinate even when told not to
#146
Conversation
Codecov Report
@@ Coverage Diff @@
## main #146 +/- ##
==========================================
+ Coverage 87.32% 89.72% +2.40%
==========================================
Files 11 11
Lines 2437 2589 +152
==========================================
+ Hits 2128 2323 +195
+ Misses 289 244 -45
- Partials 20 22 +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.
Sadly, I know you already did work for this fix here, but I will have to indeed object to the renaming of vcs
to no-vcs
. One thing is what you mentioned in the LP bug already: backwards compatibility. I wouldn't want us to fix something by changing the schema per-se. Second, the schema so far doesn't really have any 'negative keys', aka. this would be the first inverse field in the yaml file. And I don't think it's very intuitive in this case.
It is indeed a troublesome feature of the boolean in this case, and I think it's a shame that the schema handling does not really handle fields being unassigned in some special way (like via a separate flag somewhere). Potentially this problem can appear for any boolean value, and I don't think we should build out schema against limitations of the language/framework we're using.
I know you mentioned a pointer approach, which I guess could be doable - we could design it in such a way to use it in any other future booleans if the need appears. I was personally even thinking of using a string here, but that seems a bit worse? Anyway, could you take a look at it so that we don't have to change the schema? Thank you!
…om overriding false value.
2c7625c
to
f1be00d
Compare
Fixed it using pointers to booleans. I also updated the definition of |
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 looks good. And I like the additional improvements to the testing story. This feels good for merging.
As for KeepEnabled
- this is a bug/missing-feature if it's not used. I thought we did handle it properly. Might be that it got missed due to deadlines. Basically it means whether the enabled PPA should be kept enabled on the built system after package installation. Let me create a card for it.
case reflect.Slice: | ||
defaultValues := strings.Split(defaultValue, ",") | ||
field.Set(reflect.ValueOf(defaultValues)) | ||
case reflect.Bool: |
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'm thinking if maybe at this point we shouldn't just drop this part. Maybe it's better to remind us that it's not really 'safe' to use default values for pure booleans. Sure, there are cases where this would work, but it's unreliable IMO. So maybe I'd propose to remove this line and let us error out when trying to set a default. We should probably use pointers-to-booleans for every boolean with a default 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.
I agree that is unreliable. I will error out when trying to set a default on a bool. I will also add a specific test case on the image definition to make sure we never add a bool with a default. Without this test we risk letting it pass and users will face an error they cannot do anything about.
A []*S4 | ||
} | ||
|
||
func TestSetDefaults(t *testing.T) { |
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.
Nice!
@@ -97,7 +97,7 @@ type PPA struct { | |||
PPAName string `yaml:"name" json:"PPAName" jsonschema:"pattern=^[a-zA-Z0-9_.+-]+/[a-zA-Z0-9_.+-]+$"` | |||
Auth string `yaml:"auth" json:"Auth,omitempty" jsonschema:"pattern=^[a-zA-Z0-9_.+-]+:[a-zA-Z0-9]+$"` | |||
Fingerprint string `yaml:"fingerprint" json:"Fingerprint,omitempty"` | |||
KeepEnabled bool `yaml:"keep-enabled" json:"KeepEnabled" default:"true"` | |||
KeepEnabled *bool `yaml:"keep-enabled" json:"KeepEnabled" default:"true"` |
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.
As for this, I'll mention more about it in my main review comment, but I missed that it's not used! I was sure we used it already!
Ok, before merging, could you maybe remove the boolean handling though? |
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.
Excellent!
hm, linting failed, but that doesn't seem to be a real issue? |
aa24b6f
to
6f8e4be
Compare
Yeah, just a minor linting error about import order. This is fixed. |
Fixing https://bugs.launchpad.net/ubuntu-image/+bug/2021411