-
Notifications
You must be signed in to change notification settings - Fork 11
Add validation for group customization: Check for duplicate names and GIDs #43
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
Conversation
We're going to make some changes to the group customization handling, so let's first move the two (related) customizations to their own file to keep things tidy. Move the related tests as well for the same reason.
Add some extra test cases for the simple test before we add validation.
Add a validator for the group customizations. Create a type for []GroupCustomization so we can add the Validate() method. Run the validator when GetGroups() is called. This changes the signature of the method, which is a breaking API change and will need adjustments when the library is updated in images.
Add validation error test cases to TestGetGroups().
|
This is a follow up from osbuild/images#2146 (comment) |
thozza
left a comment
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.
LGTM, thanks!
| SSHKey []SSHKeyCustomization `json:"sshkey,omitempty" toml:"sshkey,omitempty"` | ||
| User []UserCustomization `json:"user,omitempty" toml:"user,omitempty"` | ||
| Group []GroupCustomization `json:"group,omitempty" toml:"group,omitempty"` | ||
| Group GroupsCustomization `json:"group,omitempty" toml:"group,omitempty"` |
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.
Wait what, are you breaking the user-space here?
| return users | ||
| } | ||
|
|
||
| type GroupsCustomization []GroupCustomization |
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 you do not, okay.
Add a
Validate()method for group customizations and call the validator whenGetGroups()is called. The validator checks for duplicate names and/or GIDs and returns an error for each duplicate value.This changes the signature of the method, which is a breaking API change and will need adjustments when the library is updated in images.