manifest: add Checkpoint()/GetCheckpoints()

If Checkpoint() is called on a pipeline, it is marked for
checkpointing. Calling GetCheckpoints() returns the names of all
its pipelines that are marked for checkpointing as a slice of
strings. This can be passed to osbuild by the caller, in which case
the trees produced by each of these pipelines will be checkpointed
to speed up future builds.

Before this can be used in production we need a mechanism for
automatically cleaning up the cache.
This commit is contained in:
Tom Gundersen 2022-07-12 18:22:10 +01:00 committed by Christian Kellner
parent a8f48822e8
commit 9b77e67576
2 changed files with 24 additions and 3 deletions

View file

@ -88,3 +88,13 @@ func (m Manifest) Serialize(packageSets map[string][]rpmmd.PackageSpec) (distro.
},
)
}
func (m Manifest) GetCheckpoints() []string {
checkpoints := []string{}
for _, p := range m.pipelines {
if p.getCheckpoint() {
checkpoints = append(checkpoints, p.Name())
}
}
return checkpoints
}

View file

@ -14,6 +14,8 @@ import (
type Pipeline interface {
Name() string
Checkpoint()
getCheckpoint() bool
getBuildPackages() []string
getPackageSetChain() []rpmmd.PackageSet
serializeStart([]rpmmd.PackageSpec)
@ -27,9 +29,10 @@ type Pipeline interface {
// A Base represents the core functionality shared between each of the pipeline
// implementations, and the Base struct must be embedded in each of them.
type Base struct {
manifest *Manifest
name string
build *Build
manifest *Manifest
name string
build *Build
checkpoint bool
}
// Name returns the name of the pipeline. The name must be unique for a given manifest.
@ -39,6 +42,14 @@ func (p Base) Name() string {
return p.name
}
func (p *Base) Checkpoint() {
p.checkpoint = true
}
func (p Base) getCheckpoint() bool {
return p.checkpoint
}
func (p Base) GetManifest() *Manifest {
return p.manifest
}