distro: expose default OSTreeRef()
Rather than setting this automagically, expose it to the caller. For now the only caller we have simply passes it back in, so this is a noop. In follow-up commits this will be used to resolve the parent commit. This is tested by verifying that the generated manifests do not change. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
3c74ea584e
commit
6cb47862df
9 changed files with 55 additions and 20 deletions
|
|
@ -65,6 +65,9 @@ type ImageType interface {
|
|||
// Retrns the MIME-type for the image type.
|
||||
MIMEType() string
|
||||
|
||||
// Returns the default OSTree ref for the image type.
|
||||
OSTreeRef() string
|
||||
|
||||
// Returns the proper image size for a given output format. If the input size
|
||||
// is 0 the default value for the format will be returned.
|
||||
Size(size uint64) uint64
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, distr
|
|||
got, err := imageType.Manifest(tt.ComposeRequest.Blueprint.Customizations,
|
||||
distro.ImageOptions{
|
||||
Size: imageType.Size(0),
|
||||
OSTree: distro.OSTreeImageOptions{
|
||||
Ref: imageType.OSTreeRef(),
|
||||
},
|
||||
},
|
||||
repos,
|
||||
tt.RpmMD.Packages,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
|
||||
const name = "fedora-32"
|
||||
const modulePlatformID = "platform:f32"
|
||||
const ostreeRef = "fedora/32/%s/iot"
|
||||
|
||||
type distribution struct {
|
||||
arches map[string]architecture
|
||||
|
|
@ -146,6 +147,13 @@ func (t *imageType) MIMEType() string {
|
|||
return t.mimeType
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
if t.rpmOstree {
|
||||
return fmt.Sprintf(ostreeRef, t.arch.name)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
|
|
@ -513,13 +521,9 @@ func qemuAssembler(format string, filename string, uefi bool, imageOptions distr
|
|||
}
|
||||
|
||||
func ostreeCommitAssembler(options distro.ImageOptions, arch distro.Arch) *osbuild.Assembler {
|
||||
ref := options.OSTree.Ref
|
||||
if ref == "" {
|
||||
ref = fmt.Sprintf("fedora/32/%s/iot", arch.Name())
|
||||
}
|
||||
return osbuild.NewOSTreeCommitAssembler(
|
||||
&osbuild.OSTreeCommitAssemblerOptions{
|
||||
Ref: ref,
|
||||
Ref: options.OSTree.Ref,
|
||||
Parent: options.OSTree.Parent,
|
||||
Tar: osbuild.OSTreeCommitAssemblerTarOptions{
|
||||
Filename: "commit.tar",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
|
||||
const name = "fedora-33"
|
||||
const modulePlatformID = "platform:f33"
|
||||
const ostreeRef = "fedora/33/%s/iot"
|
||||
|
||||
type distribution struct {
|
||||
arches map[string]architecture
|
||||
|
|
@ -146,6 +147,13 @@ func (t *imageType) MIMEType() string {
|
|||
return t.mimeType
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
if t.rpmOstree {
|
||||
return fmt.Sprintf(ostreeRef, t.arch.name)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
|
|
@ -525,13 +533,9 @@ func qemuAssembler(format string, filename string, uefi bool, imageOptions distr
|
|||
}
|
||||
|
||||
func ostreeCommitAssembler(options distro.ImageOptions, arch distro.Arch) *osbuild.Assembler {
|
||||
ref := options.OSTree.Ref
|
||||
if ref == "" {
|
||||
ref = fmt.Sprintf("fedora/33/%s/iot", arch.Name())
|
||||
}
|
||||
return osbuild.NewOSTreeCommitAssembler(
|
||||
&osbuild.OSTreeCommitAssemblerOptions{
|
||||
Ref: ref,
|
||||
Ref: options.OSTree.Ref,
|
||||
Parent: options.OSTree.Parent,
|
||||
Tar: osbuild.OSTreeCommitAssemblerTarOptions{
|
||||
Filename: "commit.tar",
|
||||
|
|
|
|||
|
|
@ -79,6 +79,10 @@ func (t *imageType) MIMEType() string {
|
|||
return "application/x-test"
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
return size
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
|
||||
const name = "rhel-8"
|
||||
const modulePlatformID = "platform:el8"
|
||||
const ostreeRef = "rhel/8/%s/edge"
|
||||
|
||||
type distribution struct {
|
||||
arches map[string]architecture
|
||||
|
|
@ -148,6 +149,13 @@ func (t *imageType) MIMEType() string {
|
|||
return t.mimeType
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
if t.rpmOstree {
|
||||
return fmt.Sprintf(ostreeRef, t.arch.name)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
|
|
@ -611,13 +619,9 @@ func tarAssembler(filename, compression string) *osbuild.Assembler {
|
|||
}
|
||||
|
||||
func ostreeCommitAssembler(options distro.ImageOptions, arch distro.Arch) *osbuild.Assembler {
|
||||
ref := options.OSTree.Ref
|
||||
if ref == "" {
|
||||
ref = fmt.Sprintf("rhel/8/%s/edge", arch.Name())
|
||||
}
|
||||
return osbuild.NewOSTreeCommitAssembler(
|
||||
&osbuild.OSTreeCommitAssemblerOptions{
|
||||
Ref: ref,
|
||||
Ref: options.OSTree.Ref,
|
||||
Parent: options.OSTree.Parent,
|
||||
Tar: osbuild.OSTreeCommitAssemblerTarOptions{
|
||||
Filename: "commit.tar",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import (
|
|||
const name = "rhel-84"
|
||||
const centosName = "centos-8"
|
||||
const modulePlatformID = "platform:el8"
|
||||
const ostreeRef = "rhel/8/%s/edge"
|
||||
|
||||
type distribution struct {
|
||||
arches map[string]architecture
|
||||
|
|
@ -161,6 +162,13 @@ func (t *imageType) MIMEType() string {
|
|||
return t.mimeType
|
||||
}
|
||||
|
||||
func (t *imageType) OSTreeRef() string {
|
||||
if t.rpmOstree {
|
||||
return fmt.Sprintf(ostreeRef, t.arch.name)
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *imageType) Size(size uint64) uint64 {
|
||||
const MegaByte = 1024 * 1024
|
||||
// Microsoft Azure requires vhd images to be rounded up to the nearest MB
|
||||
|
|
@ -722,13 +730,9 @@ func tarAssembler(filename, compression string) *osbuild.Assembler {
|
|||
}
|
||||
|
||||
func ostreeCommitAssembler(options distro.ImageOptions, arch distro.Arch) *osbuild.Assembler {
|
||||
ref := options.OSTree.Ref
|
||||
if ref == "" {
|
||||
ref = fmt.Sprintf("rhel/8/%s/edge", arch.Name())
|
||||
}
|
||||
return osbuild.NewOSTreeCommitAssembler(
|
||||
&osbuild.OSTreeCommitAssemblerOptions{
|
||||
Ref: ref,
|
||||
Ref: options.OSTree.Ref,
|
||||
Parent: options.OSTree.Parent,
|
||||
Tar: osbuild.OSTreeCommitAssemblerTarOptions{
|
||||
Filename: "commit.tar",
|
||||
|
|
|
|||
|
|
@ -63,6 +63,10 @@ func (t *TestImageType) MIMEType() string {
|
|||
return "application/x-test"
|
||||
}
|
||||
|
||||
func (t *TestImageType) OSTreeRef() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (t *TestImageType) Size(size uint64) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1856,6 +1856,11 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
|||
return
|
||||
}
|
||||
|
||||
// set default ostree ref, if one not provided
|
||||
if cr.OSTree.Ref == "" {
|
||||
cr.OSTree.Ref = imageType.OSTreeRef()
|
||||
}
|
||||
|
||||
if !verifyStringsWithRegex(writer, []string{cr.BlueprintName}, ValidBlueprintName) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue