diff --git a/internal/distro/rhel8/distro.go b/internal/distro/rhel8/distro.go index 4f6279993..f6ea55a95 100644 --- a/internal/distro/rhel8/distro.go +++ b/internal/distro/rhel8/distro.go @@ -383,7 +383,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp } if groups := c.GetGroups(); len(groups) > 0 { - p.AddStage(osbuild.NewGroupsStage(t.groupStageOptions(groups))) + p.AddStage(osbuild.NewGroupsStage(osbuild.NewGroupsStageOptions(groups))) } if userOptions, err := osbuild.NewUsersStageOptions(c.GetUsers()); err != nil { @@ -480,23 +480,6 @@ func (t *imageType) rpmStageOptions(arch architecture, repos []rpmmd.RepoConfig, } } -func (t *imageType) 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 (t *imageType) firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions { options := osbuild.FirewallStageOptions{ Ports: firewall.Ports, diff --git a/internal/distro/rhel84/distro.go b/internal/distro/rhel84/distro.go index 6ea6b53e3..6312e33e0 100644 --- a/internal/distro/rhel84/distro.go +++ b/internal/distro/rhel84/distro.go @@ -455,7 +455,7 @@ func (t *imageType) pipeline(c *blueprint.Customizations, options distro.ImageOp } if groups := c.GetGroups(); len(groups) > 0 { - p.AddStage(osbuild.NewGroupsStage(t.groupStageOptions(groups))) + p.AddStage(osbuild.NewGroupsStage(osbuild.NewGroupsStageOptions(groups))) } if userOptions, err := osbuild.NewUsersStageOptions(c.GetUsers()); err != nil { @@ -564,23 +564,6 @@ func (t *imageType) rpmStageOptions(arch architecture, repos []rpmmd.RepoConfig, } } -func (t *imageType) 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 (t *imageType) firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions { options := osbuild.FirewallStageOptions{ Ports: firewall.Ports, diff --git a/internal/distro/rhel84/distro_v2.go b/internal/distro/rhel84/distro_v2.go index 0ea0f711e..7692ca51a 100644 --- a/internal/distro/rhel84/distro_v2.go +++ b/internal/distro/rhel84/distro_v2.go @@ -317,7 +317,7 @@ func (t *imageTypeS2) ostreeTreePipeline(repos []rpmmd.RepoConfig, packages []rp } if groups := c.GetGroups(); len(groups) > 0 { - p.AddStage(osbuild.NewGroupsStage(t.groupStageOptions(groups))) + p.AddStage(osbuild.NewGroupsStage(osbuild.NewGroupsStageOptions(groups))) } if userOptions, err := osbuild.NewUsersStageOptions(c.GetUsers(), false); err != nil { @@ -553,23 +553,6 @@ func (t *imageTypeS2) usersFirstBootOptions(usersStageOptions *osbuild.UsersStag return options } -func (t *imageTypeS2) 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 (t *imageTypeS2) firewallStageOptions(firewall *blueprint.FirewallCustomization) *osbuild.FirewallStageOptions { options := osbuild.FirewallStageOptions{ Ports: firewall.Ports, diff --git a/internal/distro/rhel85/pipelines.go b/internal/distro/rhel85/pipelines.go index ac2967b49..997703249 100644 --- a/internal/distro/rhel85/pipelines.go +++ b/internal/distro/rhel85/pipelines.go @@ -239,7 +239,7 @@ func ec2BaseTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, } 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 { @@ -660,7 +660,7 @@ func osPipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, bpPackag } 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 { @@ -744,7 +744,7 @@ func ostreeTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, } 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/rhel85/stage_options.go b/internal/distro/rhel85/stage_options.go index 631a0fefd..204f3904f 100644 --- a/internal/distro/rhel85/stage_options.go +++ b/internal/distro/rhel85/stage_options.go @@ -52,23 +52,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, @@ -205,7 +188,6 @@ func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.Kickstart }, } } - func bootISOMonoStageOptions(kernelVer string, arch string) *osbuild.BootISOMonoStageOptions { comprOptions := new(osbuild.FSCompressionOptions) if bcj := osbuild.BCJOption(arch); bcj != "" { diff --git a/internal/distro/rhel90beta/pipelines.go b/internal/distro/rhel90beta/pipelines.go index b3433a97f..f8ee7429c 100644 --- a/internal/distro/rhel90beta/pipelines.go +++ b/internal/distro/rhel90beta/pipelines.go @@ -227,7 +227,7 @@ func ec2BaseTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, } 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 { @@ -744,7 +744,7 @@ func osPipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, bpPackag } 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 { @@ -823,7 +823,7 @@ func ostreeTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpec, } 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/rhel90beta/stage_options.go b/internal/distro/rhel90beta/stage_options.go index 2d3748340..6bd3b8c45 100644 --- a/internal/distro/rhel90beta/stage_options.go +++ b/internal/distro/rhel90beta/stage_options.go @@ -49,23 +49,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/osbuild1/groups_stage.go b/internal/osbuild1/groups_stage.go index 3575a73a1..e7dfe2606 100644 --- a/internal/osbuild1/groups_stage.go +++ b/internal/osbuild1/groups_stage.go @@ -1,5 +1,7 @@ package osbuild1 +import "github.com/osbuild/osbuild-composer/internal/blueprint" + type GroupsStageOptions struct { Groups map[string]GroupsStageOptionsGroup `json:"groups"` } @@ -7,7 +9,7 @@ type GroupsStageOptions struct { func (GroupsStageOptions) isStageOptions() {} type GroupsStageOptionsGroup struct { - Name string `json:"name"` + Name string `json:"name,omitempty"` GID *int `json:"gid,omitempty"` } @@ -17,3 +19,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/rhel_8-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_8-aarch64-qcow2_customize-boot.json index afd09293a..58ce6b734 100644 --- a/test/data/manifests/rhel_8-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_8-aarch64-qcow2_customize-boot.json @@ -3560,11 +3560,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_8-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_8-ppc64le-qcow2_customize-boot.json index aced277ce..35112922b 100644 --- a/test/data/manifests/rhel_8-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_8-ppc64le-qcow2_customize-boot.json @@ -3839,11 +3839,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_8-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_8-s390x-qcow2_customize-boot.json index a89e4b96b..dd27683a0 100644 --- a/test/data/manifests/rhel_8-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_8-s390x-qcow2_customize-boot.json @@ -3760,11 +3760,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_8-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_8-x86_64-qcow2_customize-boot.json index 791cebaf4..b3264226b 100644 --- a/test/data/manifests/rhel_8-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_8-x86_64-qcow2_customize-boot.json @@ -3542,11 +3542,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_84-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_84-aarch64-qcow2_customize-boot.json index 3bee85289..587f7db0b 100644 --- a/test/data/manifests/rhel_84-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_84-aarch64-qcow2_customize-boot.json @@ -3569,11 +3569,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_84-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_84-ppc64le-qcow2_customize-boot.json index 6b53eba9b..6e5155b0d 100644 --- a/test/data/manifests/rhel_84-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_84-ppc64le-qcow2_customize-boot.json @@ -3848,11 +3848,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_84-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_84-s390x-qcow2_customize-boot.json index 92bce03b4..83309159e 100644 --- a/test/data/manifests/rhel_84-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_84-s390x-qcow2_customize-boot.json @@ -3786,11 +3786,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_84-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_84-x86_64-qcow2_customize-boot.json index 6f3dd7c95..41f862368 100644 --- a/test/data/manifests/rhel_84-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_84-x86_64-qcow2_customize-boot.json @@ -3609,11 +3609,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_85-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_85-aarch64-qcow2_customize-boot.json index 52963d326..776e40cb4 100644 --- a/test/data/manifests/rhel_85-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_85-aarch64-qcow2_customize-boot.json @@ -917,11 +917,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_85-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_85-ppc64le-qcow2_customize-boot.json index f6420a42b..d8b539561 100644 --- a/test/data/manifests/rhel_85-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_85-ppc64le-qcow2_customize-boot.json @@ -970,11 +970,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_85-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_85-s390x-qcow2_customize-boot.json index 5d45b76ce..31fc9daad 100644 --- a/test/data/manifests/rhel_85-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_85-s390x-qcow2_customize-boot.json @@ -1010,11 +1010,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_85-x86_64-image_installer_with_users-boot.json b/test/data/manifests/rhel_85-x86_64-image_installer_with_users-boot.json index dac486c35..3c26c85ac 100644 --- a/test/data/manifests/rhel_85-x86_64-image_installer_with_users-boot.json +++ b/test/data/manifests/rhel_85-x86_64-image_installer_with_users-boot.json @@ -920,11 +920,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_85-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_85-x86_64-qcow2_customize-boot.json index 6016507aa..216c31959 100644 --- a/test/data/manifests/rhel_85-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_85-x86_64-qcow2_customize-boot.json @@ -930,11 +930,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90_beta-aarch64-qcow2_customize-boot.json b/test/data/manifests/rhel_90_beta-aarch64-qcow2_customize-boot.json index a97c801b7..ffbf63d6a 100644 --- a/test/data/manifests/rhel_90_beta-aarch64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90_beta-aarch64-qcow2_customize-boot.json @@ -843,11 +843,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90_beta-ppc64le-qcow2_customize-boot.json b/test/data/manifests/rhel_90_beta-ppc64le-qcow2_customize-boot.json index 74891e6eb..c2d222868 100644 --- a/test/data/manifests/rhel_90_beta-ppc64le-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90_beta-ppc64le-qcow2_customize-boot.json @@ -906,11 +906,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90_beta-s390x-qcow2_customize-boot.json b/test/data/manifests/rhel_90_beta-s390x-qcow2_customize-boot.json index 8ef087144..4da0d9edb 100644 --- a/test/data/manifests/rhel_90_beta-s390x-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90_beta-s390x-qcow2_customize-boot.json @@ -993,11 +993,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90_beta-x86_64-image_installer_with_users-boot.json b/test/data/manifests/rhel_90_beta-x86_64-image_installer_with_users-boot.json index 3e15ceef0..cccfd0165 100644 --- a/test/data/manifests/rhel_90_beta-x86_64-image_installer_with_users-boot.json +++ b/test/data/manifests/rhel_90_beta-x86_64-image_installer_with_users-boot.json @@ -880,11 +880,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } } diff --git a/test/data/manifests/rhel_90_beta-x86_64-qcow2_customize-boot.json b/test/data/manifests/rhel_90_beta-x86_64-qcow2_customize-boot.json index 101423930..4586c8c18 100644 --- a/test/data/manifests/rhel_90_beta-x86_64-qcow2_customize-boot.json +++ b/test/data/manifests/rhel_90_beta-x86_64-qcow2_customize-boot.json @@ -874,11 +874,9 @@ "options": { "groups": { "group1": { - "name": "group1", "gid": 1030 }, "group2": { - "name": "group2", "gid": 1050 } }