osbuild2: deduplicate groupStageOptions()
Use single NewGroupsStageOptions() from osbuild2 instead of implementing in each distro. The new function does not set the Group.Name field anymore. The field does not exist in the osbuild schema and was silently ignored. The field in the stage has been marked 'omitempty' and the relevant manifests have been updated.
This commit is contained in:
parent
ca8b371142
commit
2eef6e6e2d
20 changed files with 21 additions and 67 deletions
|
|
@ -412,7 +412,7 @@ func osPipeline(t *imageType,
|
|||
}
|
||||
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(groupStageOptions(groups)))
|
||||
p.AddStage(osbuild.NewGroupsStage(osbuild.NewGroupsStageOptions(groups)))
|
||||
}
|
||||
|
||||
if userOptions, err := osbuild.NewUsersStageOptions(c.GetUsers(), false); err != nil {
|
||||
|
|
|
|||
|
|
@ -81,23 +81,6 @@ func usersFirstBootOptions(usersStageOptions *osbuild.UsersStageOptions) *osbuil
|
|||
return options
|
||||
}
|
||||
|
||||
func groupStageOptions(groups []blueprint.GroupCustomization) *osbuild.GroupsStageOptions {
|
||||
options := osbuild.GroupsStageOptions{
|
||||
Groups: map[string]osbuild.GroupsStageOptionsGroup{},
|
||||
}
|
||||
|
||||
for _, group := range groups {
|
||||
groupData := osbuild.GroupsStageOptionsGroup{
|
||||
Name: group.Name,
|
||||
}
|
||||
groupData.GID = group.GID
|
||||
|
||||
options.Groups[group.Name] = groupData
|
||||
}
|
||||
|
||||
return &options
|
||||
}
|
||||
|
||||
func firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions {
|
||||
options := osbuild.FirewallStageOptions{
|
||||
Ports: firewall.Ports,
|
||||
|
|
|
|||
|
|
@ -404,7 +404,7 @@ func osPipeline(t *imageType,
|
|||
}
|
||||
|
||||
if groups := c.GetGroups(); len(groups) > 0 {
|
||||
p.AddStage(osbuild.NewGroupsStage(groupStageOptions(groups)))
|
||||
p.AddStage(osbuild.NewGroupsStage(osbuild.NewGroupsStageOptions(groups)))
|
||||
}
|
||||
|
||||
if userOptions, err := osbuild.NewUsersStageOptions(c.GetUsers(), false); err != nil {
|
||||
|
|
|
|||
|
|
@ -81,23 +81,6 @@ func usersFirstBootOptions(usersStageOptions *osbuild.UsersStageOptions) *osbuil
|
|||
return options
|
||||
}
|
||||
|
||||
func groupStageOptions(groups []blueprint.GroupCustomization) *osbuild.GroupsStageOptions {
|
||||
options := osbuild.GroupsStageOptions{
|
||||
Groups: map[string]osbuild.GroupsStageOptionsGroup{},
|
||||
}
|
||||
|
||||
for _, group := range groups {
|
||||
groupData := osbuild.GroupsStageOptionsGroup{
|
||||
Name: group.Name,
|
||||
}
|
||||
groupData.GID = group.GID
|
||||
|
||||
options.Groups[group.Name] = groupData
|
||||
}
|
||||
|
||||
return &options
|
||||
}
|
||||
|
||||
func firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions {
|
||||
options := osbuild.FirewallStageOptions{
|
||||
Ports: firewall.Ports,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package osbuild2
|
||||
|
||||
import "github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
|
||||
type GroupsStageOptions struct {
|
||||
Groups map[string]GroupsStageOptionsGroup `json:"groups"`
|
||||
}
|
||||
|
|
@ -7,7 +9,9 @@ type GroupsStageOptions struct {
|
|||
func (GroupsStageOptions) isStageOptions() {}
|
||||
|
||||
type GroupsStageOptionsGroup struct {
|
||||
Name string `json:"name"`
|
||||
// NOTE: the name field does not exist in the osbuild schema and should be
|
||||
// removed
|
||||
Name string `json:"name,omitempty"`
|
||||
GID *int `json:"gid,omitempty"`
|
||||
}
|
||||
|
||||
|
|
@ -17,3 +21,17 @@ func NewGroupsStage(options *GroupsStageOptions) *Stage {
|
|||
Options: options,
|
||||
}
|
||||
}
|
||||
|
||||
func NewGroupsStageOptions(groups []blueprint.GroupCustomization) *GroupsStageOptions {
|
||||
options := GroupsStageOptions{
|
||||
Groups: map[string]GroupsStageOptionsGroup{},
|
||||
}
|
||||
|
||||
for _, group := range groups {
|
||||
options.Groups[group.Name] = GroupsStageOptionsGroup{
|
||||
GID: group.GID,
|
||||
}
|
||||
}
|
||||
|
||||
return &options
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1208,11 +1208,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1311,11 +1311,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1221,11 +1221,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1125,11 +1125,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1194,11 +1194,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1263,11 +1263,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1167,11 +1167,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1250,11 +1250,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1353,11 +1353,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1370,11 +1370,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1266,11 +1266,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1162,11 +1162,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1234,11 +1234,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1301,11 +1301,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1199,11 +1199,9 @@
|
|||
"options": {
|
||||
"groups": {
|
||||
"group1": {
|
||||
"name": "group1",
|
||||
"gid": 1030
|
||||
},
|
||||
"group2": {
|
||||
"name": "group2",
|
||||
"gid": 1050
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue