blueprint: don't create group with the same as one of the users
This commit is contained in:
parent
dc359fca3a
commit
4b546f1bbf
1 changed files with 16 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ package blueprint
|
||||||
import (
|
import (
|
||||||
"github.com/osbuild/osbuild-composer/internal/crypt"
|
"github.com/osbuild/osbuild-composer/internal/crypt"
|
||||||
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
"github.com/osbuild/osbuild-composer/internal/pipeline"
|
||||||
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
@ -111,9 +112,13 @@ func (c *Customizations) customizeGroup(p *pipeline.Pipeline) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: lorax-composer doesn't create group with the same name as user if both specified
|
|
||||||
groups := make(map[string]pipeline.GroupsStageOptionsGroup)
|
groups := make(map[string]pipeline.GroupsStageOptionsGroup)
|
||||||
for _, group := range c.Group {
|
for _, group := range c.Group {
|
||||||
|
if userCustomizationsContainUsername(c.User, group.Name) {
|
||||||
|
log.Println("group with name ", group.Name, " was not created, because user with same name was defined!")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
groupData := pipeline.GroupsStageOptionsGroup{}
|
groupData := pipeline.GroupsStageOptionsGroup{}
|
||||||
if group.GID != nil {
|
if group.GID != nil {
|
||||||
gid := strconv.Itoa(*group.GID)
|
gid := strconv.Itoa(*group.GID)
|
||||||
|
|
@ -314,3 +319,13 @@ func findKeysForUser(sshKeyCustomizations []SSHKeyCustomization, user string) (k
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userCustomizationsContainUsername(userCustomizations []UserCustomization, name string) bool {
|
||||||
|
for _, usr := range userCustomizations {
|
||||||
|
if usr.Name == name {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue