users: convenience functions for converting from BP
The types currently map directly, so it's simple to convert from one to the other.
This commit is contained in:
parent
86d9611f98
commit
820d3d0277
1 changed files with 22 additions and 0 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package users
|
||||
|
||||
import "github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
||||
type User struct {
|
||||
Name string
|
||||
Description *string
|
||||
|
|
@ -16,3 +18,23 @@ type Group struct {
|
|||
Name string
|
||||
GID *int
|
||||
}
|
||||
|
||||
func UsersFromBP(userCustomizations []blueprint.UserCustomization) []User {
|
||||
users := make([]User, len(userCustomizations))
|
||||
for idx := range userCustomizations {
|
||||
// currently, they have the same structure, so we convert directly
|
||||
// this will fail to compile as soon as one of the two changes
|
||||
users[idx] = User(userCustomizations[idx])
|
||||
}
|
||||
return users
|
||||
}
|
||||
|
||||
func GroupsFromBP(groupCustomizations []blueprint.GroupCustomization) []Group {
|
||||
groups := make([]Group, len(groupCustomizations))
|
||||
for idx := range groupCustomizations {
|
||||
// currently, they have the same structure, so we convert directly
|
||||
// this will fail to compile as soon as one of the two changes
|
||||
groups[idx] = Group(groupCustomizations[idx])
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue