debian-forge-composer/internal/blueprint/blueprint.go
Lars Karlitski b33ed9e5d2 blueprint: move pipeline generation into its own package
Introduce the `distro` package, which contains an interface for OS
implementations. Its main purpose is to convert a blueprint to a
distro-specific pipeline.

Also introduce the `distro/fedora30` package. It is the first
implementation of the distro interface. Most of its code has been copied
with minimal modifications from the blueprint package.

The `blueprint` package is now back to serving a single purpose:
representing a weldr blueprint. It does not depend on the `pipeline`
package anymore.

Change osbuild-composer and osbuild-pipeline to use the new API,
hard-coding "fedora-30". This looks a bit weird now, but is the same
behavior as before.

All test cases now also take an "distro" key in the "compose" object.
2019-11-07 17:13:20 +01:00

51 lines
1.4 KiB
Go

// Package blueprint contains primitives for representing weldr blueprints
package blueprint
// An InvalidOutputFormatError is returned when a requested output format is
// not supported. The requested format is included as the error message.
type InvalidOutputFormatError struct {
message string
}
func (e *InvalidOutputFormatError) Error() string {
return e.message
}
// A Blueprint is a high-level description of an image.
type Blueprint struct {
Name string `json:"name"`
Description string `json:"description"`
Version string `json:"version,omitempty"`
Packages []Package `json:"packages"`
Modules []Package `json:"modules"`
Groups []Group `json:"groups"`
Customizations *Customizations `json:"customizations,omitempty"`
}
// A Package specifies an RPM package.
type Package struct {
Name string `json:"name"`
Version string `json:"version,omitempty"`
}
// A group specifies an package group.
type Group struct {
Name string `json:"name"`
}
func (b *Blueprint) GetKernelCustomization() *KernelCustomization {
if b.Customizations == nil {
return nil
}
return b.Customizations.Kernel
}
func (p Package) ToNameVersion() string {
// Omit version to prevent all packages with prefix of name to be installed
if p.Version == "*" {
return p.Name
}
return p.Name + "-" + p.Version
}