diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index 2141569ec..d5435308a 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -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 { diff --git a/internal/distro/rhel86/stage_options.go b/internal/distro/rhel86/stage_options.go index 26ef7b855..73d6c824f 100644 --- a/internal/distro/rhel86/stage_options.go +++ b/internal/distro/rhel86/stage_options.go @@ -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, diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index de11936a9..e78f44440 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -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 { diff --git a/internal/distro/rhel90/stage_options.go b/internal/distro/rhel90/stage_options.go index 06dd57030..640d9de49 100644 --- a/internal/distro/rhel90/stage_options.go +++ b/internal/distro/rhel90/stage_options.go @@ -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, diff --git a/internal/osbuild2/groups_stage.go b/internal/osbuild2/groups_stage.go index d003954ba..ecd859e87 100644 --- a/internal/osbuild2/groups_stage.go +++ b/internal/osbuild2/groups_stage.go @@ -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 +} diff --git a/test/data/manifests/centos_8-aarch64-qcow2_customize-boot.json b/test/data/manifests/centos_8-aarch64-qcow2_customize-boot.json index 9a3c79fe3..f7856c5fe 100644 --- a/test/data/manifests/centos_8-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/centos_8-aarch64-qcow2_customize-boot.json @@ -1208,11 +1208,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_8-ppc64le-qcow2_customize-boot.json b/test/data/manifests/centos_8-ppc64le-qcow2_customize-boot.json index e24eca422..a58eb2518 100644 --- a/test/data/manifests/centos_8-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/centos_8-ppc64le-qcow2_customize-boot.json @@ -1311,11 +1311,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_8-x86_64-qcow2_customize-boot.json b/test/data/manifests/centos_8-x86_64-qcow2_customize-boot.json index d31901c13..d0d3f671b 100644 --- a/test/data/manifests/centos_8-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/centos_8-x86_64-qcow2_customize-boot.json @@ -1221,11 +1221,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_9-aarch64-qcow2_customize-boot.json b/test/data/manifests/centos_9-aarch64-qcow2_customize-boot.json index 00ebccf47..ed91e41bb 100644 --- a/test/data/manifests/centos_9-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/centos_9-aarch64-qcow2_customize-boot.json @@ -1125,11 +1125,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_9-ppc64le-qcow2_customize-boot.json b/test/data/manifests/centos_9-ppc64le-qcow2_customize-boot.json index 2be0f2c98..379dc9a82 100644 --- a/test/data/manifests/centos_9-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/centos_9-ppc64le-qcow2_customize-boot.json @@ -1194,11 +1194,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_9-s390x-qcow2_customize-boot.json b/test/data/manifests/centos_9-s390x-qcow2_customize-boot.json index e61bb6250..e73f8a249 100644 --- a/test/data/manifests/centos_9-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/centos_9-s390x-qcow2_customize-boot.json @@ -1263,11 +1263,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/centos_9-x86_64-qcow2_customize-boot.json b/test/data/manifests/centos_9-x86_64-qcow2_customize-boot.json index 470bb384b..6c0ba368d 100644 --- a/test/data/manifests/centos_9-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/centos_9-x86_64-qcow2_customize-boot.json @@ -1167,11 +1167,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_86-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_86-aarch64-qcow2_customize-boot.json index 62ccd89d6..4e4e5d539 100644 --- a/test/data/manifests/rhel_86-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_86-aarch64-qcow2_customize-boot.json @@ -1250,11 +1250,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_86-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_86-ppc64le-qcow2_customize-boot.json index a0e1861ca..08043f206 100644 --- a/test/data/manifests/rhel_86-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_86-ppc64le-qcow2_customize-boot.json @@ -1353,11 +1353,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_86-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_86-s390x-qcow2_customize-boot.json index f3b70ff86..6cfbbbf4d 100644 --- a/test/data/manifests/rhel_86-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_86-s390x-qcow2_customize-boot.json @@ -1370,11 +1370,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_86-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_86-x86_64-qcow2_customize-boot.json index d702b597c..447958a19 100644 --- a/test/data/manifests/rhel_86-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_86-x86_64-qcow2_customize-boot.json @@ -1266,11 +1266,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_90-aarch64-qcow2_customize-boot.json index d78aa9738..49946084e 100644 --- a/test/data/manifests/rhel_90-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90-aarch64-qcow2_customize-boot.json @@ -1162,11 +1162,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_90-ppc64le-qcow2_customize-boot.json index e19f4c44a..8445a6980 100644 --- a/test/data/manifests/rhel_90-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90-ppc64le-qcow2_customize-boot.json @@ -1234,11 +1234,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_90-s390x-qcow2_customize-boot.json index 99f81bd0e..a0423124a 100644 --- a/test/data/manifests/rhel_90-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90-s390x-qcow2_customize-boot.json @@ -1301,11 +1301,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_90-x86_64-qcow2_customize-boot.json index abf9e2bf3..4280e08f3 100644 --- a/test/data/manifests/rhel_90-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90-x86_64-qcow2_customize-boot.json @@ -1199,11 +1199,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } }