Move ostreePullStageInputs() from distros to osbuild2

Move the `ostreePullStageInputs()` function duplicated in all
distro definitions to the `osbuild2` package as
`NewOstreePullStageInputs()`.

Delete `stage_inputs.go` from all distro definitions.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
This commit is contained in:
Tomas Hozza 2022-02-16 12:24:51 +01:00 committed by Ondřej Budai
parent d946199441
commit 657b7a5833
10 changed files with 24 additions and 88 deletions

View file

@ -392,7 +392,7 @@ func (t *imageTypeS2) containerTreePipeline(repos []rpmmd.RepoConfig, packages [
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: "/var/www/html/repo"},
t.ostreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
))
return p
}
@ -428,7 +428,7 @@ func (t *imageTypeS2) anacondaTreePipeline(repos []rpmmd.RepoConfig, packages []
p.AddStage(osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
t.ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
p.AddStage(osbuild.NewBuildstampStage(t.buildStampStageOptions()))
p.AddStage(osbuild.NewLocaleStage(&osbuild.LocaleStageOptions{Language: "en_US.UTF-8"}))
@ -488,17 +488,6 @@ func (t *imageTypeS2) bootISOPipeline() *osbuild.Pipeline {
return p
}
func (t *imageTypeS2) ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
pullStageInput := new(osbuild.OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
}
func (t *imageTypeS2) rpmStageOptions(repos []rpmmd.RepoConfig) *osbuild.RPMStageOptions {
var gpgKeys []string
for _, repo := range repos {

View file

@ -853,7 +853,7 @@ func containerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpe
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath},
ostreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
))
// make nginx log directory world writeable, otherwise nginx can't start in
@ -892,7 +892,7 @@ func ostreePayloadStages(options distro.ImageOptions, ostreeRepoPath string) []*
stages = append(stages, osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
stages = append(stages, osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
return stages
@ -1095,7 +1095,7 @@ func ostreeDeployPipeline(
p.AddStage(osbuild.OSTreeInitFsStage())
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
p.AddStage(osbuild.NewOSTreeOsInitStage(
&osbuild.OSTreeOsInitStageOptions{

View file

@ -1,16 +0,0 @@
package rhel85
import (
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
)
func ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
pullStageInput := new(osbuild.OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
}

View file

@ -587,7 +587,7 @@ func containerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpe
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath},
ostreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
))
// make nginx log directory world writeable, otherwise nginx can't start in
@ -626,7 +626,7 @@ func ostreePayloadStages(options distro.ImageOptions, ostreeRepoPath string) []*
stages = append(stages, osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
stages = append(stages, osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
return stages
@ -794,7 +794,7 @@ func ostreeDeployPipeline(
p.AddStage(osbuild.OSTreeInitFsStage())
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath, Remote: remote},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
p.AddStage(osbuild.NewOSTreeOsInitStage(
&osbuild.OSTreeOsInitStageOptions{

View file

@ -1,16 +0,0 @@
package rhel86
import (
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
)
func ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
pullStageInput := new(osbuild.OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
}

View file

@ -574,7 +574,7 @@ func containerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpe
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath},
ostreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
))
// make nginx log and lib directories world writeable, otherwise nginx can't start in
@ -614,7 +614,7 @@ func ostreePayloadStages(options distro.ImageOptions, ostreeRepoPath string) []*
stages = append(stages, osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
stages = append(stages, osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
return stages
@ -791,7 +791,7 @@ func ostreeDeployPipeline(
p.AddStage(osbuild.OSTreeInitFsStage())
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: repoPath, Remote: remote},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
p.AddStage(osbuild.NewOSTreeOsInitStage(
&osbuild.OSTreeOsInitStageOptions{

View file

@ -1,16 +0,0 @@
package rhel90
import (
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
)
func ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
pullStageInput := new(osbuild.OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
}

View file

@ -925,7 +925,7 @@ func containerTreePipeline(repos []rpmmd.RepoConfig, packages []rpmmd.PackageSpe
p.AddStage(osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: "/var/www/html/repo"},
ostreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.pipeline", "name:ostree-commit", options.OSTree.Ref),
))
return p
}
@ -958,7 +958,7 @@ func ostreePayloadStages(options distro.ImageOptions, ostreeRepoPath string) []*
stages = append(stages, osbuild.NewOSTreeInitStage(&osbuild.OSTreeInitStageOptions{Path: ostreeRepoPath}))
stages = append(stages, osbuild.NewOSTreePullStage(
&osbuild.OSTreePullStageOptions{Repo: ostreeRepoPath},
ostreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
osbuild.NewOstreePullStageInputs("org.osbuild.source", options.OSTree.Parent, options.OSTree.Ref),
))
return stages

View file

@ -1,16 +0,0 @@
package rhel90beta
import (
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild2"
)
func ostreePullStageInputs(origin, source, commitRef string) *osbuild.OSTreePullStageInputs {
pullStageInput := new(osbuild.OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]osbuild.OSTreePullStageReference)
inputRefs[source] = osbuild.OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &osbuild.OSTreePullStageInputs{Commits: pullStageInput}
}

View file

@ -39,3 +39,14 @@ func NewOSTreePullStage(options *OSTreePullStageOptions, inputs *OSTreePullStage
Options: options,
}
}
func NewOstreePullStageInputs(origin, source, commitRef string) *OSTreePullStageInputs {
pullStageInput := new(OSTreePullStageInput)
pullStageInput.Type = "org.osbuild.ostree"
pullStageInput.Origin = origin
inputRefs := make(map[string]OSTreePullStageReference)
inputRefs[source] = OSTreePullStageReference{Ref: commitRef}
pullStageInput.References = inputRefs
return &OSTreePullStageInputs{Commits: pullStageInput}
}