workload: introduce abstraction to encapsulate image workloads

The workload encapsulates what the user wants to run on top of the image. Everything
else we do abstracts away the OS, the hardware, the environment, and what is left is what
matters: the workload.

For now only the `Custom` payload is implemented which requires the user to name the
packages they want installed, the repositories to pull them from and what systemd
services to enable.

A few other stub workloads are added to show the idea, but these are not used.

The ideal is for the workload to have only the minimal number of configuration options.
This commit is contained in:
Tom Gundersen 2022-07-06 11:26:51 +01:00
parent 39c3d6ec35
commit 7a534d4d1e
8 changed files with 159 additions and 52 deletions

View file

@ -0,0 +1,7 @@
package workload
// TODO: replace the Anaconda pipeline by the OS pipeline with the
// anaconda workload.
type Anaconda struct {
BaseWorkload
}

View file

@ -0,0 +1,22 @@
package workload
type Custom struct {
BaseWorkload
Packages []string
Services []string
DisabledServices []string
}
func (p *Custom) GetPackages() []string {
return p.Packages
}
func (p *Custom) GetServices() []string {
return p.Services
}
// TODO: Does this belong here? What kind of workload requires
// services to be disabled?
func (p *Custom) GetDisabledServices() []string {
return p.DisabledServices
}

6
internal/workload/sap.go Normal file
View file

@ -0,0 +1,6 @@
package workload
// TODO!
type SAP struct {
BaseWorkload
}

View file

@ -0,0 +1,7 @@
package workload
// TODO: replace the CommitServerTree pipeline by the OS pipeline with the
// StaticWebserver workload.
type StaticWebserver struct {
BaseWorkload
}

View file

@ -0,0 +1,30 @@
package workload
import "github.com/osbuild/osbuild-composer/internal/rpmmd"
type Workload interface {
GetPackages() []string
GetRepos() []rpmmd.RepoConfig
GetServices() []string
GetDisabledServices() []string
}
type BaseWorkload struct {
Repos []rpmmd.RepoConfig
}
func (p BaseWorkload) GetPackages() []string {
return []string{}
}
func (p BaseWorkload) GetRepos() []rpmmd.RepoConfig {
return p.Repos
}
func (p BaseWorkload) GetServices() []string {
return []string{}
}
func (p BaseWorkload) GetDisabledServices() []string {
return []string{}
}