obsuild2: deduplicate *kickstartStageOptions()
Use single NewKickstartStageOptions() and replace image-type-specific implementations from each distro.
This commit is contained in:
parent
2eef6e6e2d
commit
cb186df208
5 changed files with 65 additions and 46 deletions
|
|
@ -212,7 +212,10 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio
|
|||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel")
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
payloadStages := ostreePayloadStages(options, ostreeRepoPath)
|
||||
kickstartOptions := ostreeKickstartStageOptions(makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, "", customizations.GetUsers(), customizations.GetGroups(), makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge"))
|
||||
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, kickstartOptions, payloadStages))
|
||||
|
|
@ -247,7 +250,10 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati
|
|||
|
||||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)}
|
||||
kickstartOptions := tarKickstartStageOptions(makeISORootPath(tarPath))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), nil, nil, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
archName := t.arch.name
|
||||
d := t.arch.distro
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "BaseOS"))
|
||||
|
|
|
|||
|
|
@ -189,27 +189,6 @@ func dracutStageOptions(kernelVer, arch string, additionalModules []string) *osb
|
|||
}
|
||||
}
|
||||
|
||||
func tarKickstartStageOptions(tarURL string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
LiveIMG: &osbuild.LiveIMG{
|
||||
URL: tarURL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolabel string) *osbuild.BootISOMonoStageOptions {
|
||||
comprOptions := new(osbuild.FSCompressionOptions)
|
||||
if bcj := osbuild.BCJOption(arch); bcj != "" {
|
||||
|
|
|
|||
|
|
@ -204,7 +204,10 @@ func edgeInstallerPipelines(t *imageType, customizations *blueprint.Customizatio
|
|||
kernelVer := rpmmd.GetVerStrFromPackageSpecListPanic(installerPackages, "kernel")
|
||||
ostreeRepoPath := "/ostree/repo"
|
||||
payloadStages := ostreePayloadStages(options, ostreeRepoPath)
|
||||
kickstartOptions := ostreeKickstartStageOptions(makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, "", customizations.GetUsers(), customizations.GetGroups(), makeISORootPath(ostreeRepoPath), options.OSTree.Ref)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge"))
|
||||
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
||||
pipelines = append(pipelines, *bootISOTreePipeline(kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, kickstartOptions, payloadStages))
|
||||
|
|
@ -239,7 +242,10 @@ func imageInstallerPipelines(t *imageType, customizations *blueprint.Customizati
|
|||
|
||||
tarPath := "/liveimg.tar"
|
||||
tarPayloadStages := []*osbuild.Stage{tarStage("os", tarPath)}
|
||||
kickstartOptions := tarKickstartStageOptions(makeISORootPath(tarPath))
|
||||
kickstartOptions, err := osbuild.NewKickstartStageOptions(kspath, makeISORootPath(tarPath), nil, nil, "", "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
archName := t.arch.name
|
||||
d := t.arch.distro
|
||||
pipelines = append(pipelines, *anacondaTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "BaseOS"))
|
||||
|
|
|
|||
|
|
@ -189,27 +189,6 @@ func dracutStageOptions(kernelVer, arch string, additionalModules []string) *osb
|
|||
}
|
||||
}
|
||||
|
||||
func tarKickstartStageOptions(tarURL string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
LiveIMG: &osbuild.LiveIMG{
|
||||
URL: tarURL,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func ostreeKickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.KickstartStageOptions {
|
||||
return &osbuild.KickstartStageOptions{
|
||||
Path: kspath,
|
||||
OSTree: &osbuild.OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func bootISOMonoStageOptions(kernelVer, arch, vendor, product, osVersion, isolabel string) *osbuild.BootISOMonoStageOptions {
|
||||
comprOptions := new(osbuild.FSCompressionOptions)
|
||||
if bcj := osbuild.BCJOption(arch); bcj != "" {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
package osbuild2
|
||||
|
||||
import (
|
||||
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
||||
)
|
||||
|
||||
type KickstartStageOptions struct {
|
||||
// Where to place the kickstart file
|
||||
Path string `json:"path"`
|
||||
|
|
@ -33,3 +37,48 @@ func NewKickstartStage(options *KickstartStageOptions) *Stage {
|
|||
Options: options,
|
||||
}
|
||||
}
|
||||
|
||||
func NewKickstartStageOptions(
|
||||
path string,
|
||||
imageURL string,
|
||||
userCustomizations []blueprint.UserCustomization,
|
||||
groupCustomizations []blueprint.GroupCustomization,
|
||||
ostreeURL string,
|
||||
ostreeRef string) (*KickstartStageOptions, error) {
|
||||
|
||||
var users map[string]UsersStageOptionsUser
|
||||
if usersOptions, err := NewUsersStageOptions(userCustomizations, false); err != nil {
|
||||
return nil, err
|
||||
} else if usersOptions != nil {
|
||||
users = usersOptions.Users
|
||||
}
|
||||
|
||||
var groups map[string]GroupsStageOptionsGroup
|
||||
if groupsOptions := NewGroupsStageOptions(groupCustomizations); groupsOptions != nil {
|
||||
groups = groupsOptions.Groups
|
||||
}
|
||||
|
||||
var ostreeOptions *OSTreeOptions
|
||||
if ostreeURL != "" {
|
||||
ostreeOptions = &OSTreeOptions{
|
||||
OSName: "rhel",
|
||||
URL: ostreeURL,
|
||||
Ref: ostreeRef,
|
||||
GPG: false,
|
||||
}
|
||||
}
|
||||
|
||||
var liveImg *LiveIMG
|
||||
if imageURL != "" {
|
||||
liveImg = &LiveIMG{
|
||||
URL: imageURL,
|
||||
}
|
||||
}
|
||||
return &KickstartStageOptions{
|
||||
Path: path,
|
||||
OSTree: ostreeOptions,
|
||||
LiveIMG: liveImg,
|
||||
Users: users,
|
||||
Groups: groups,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue