-
Notifications
You must be signed in to change notification settings - Fork 44
/
ostree_archive.go
67 lines (54 loc) · 1.89 KB
/
ostree_archive.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package image
import (
"math/rand"
"github.com/osbuild/images/internal/environment"
"github.com/osbuild/images/internal/workload"
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/ostree"
"github.com/osbuild/images/pkg/platform"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/images/pkg/runner"
)
type OSTreeArchive struct {
Base
Platform platform.Platform
OSCustomizations manifest.OSCustomizations
Environment environment.Environment
Workload workload.Workload
// OSTreeParent specifies the source for an optional parent commit for the
// new commit being built.
OSTreeParent *ostree.SourceSpec
// OSTreeRef is the ref of the commit that will be built.
OSTreeRef string
OSVersion string
Filename string
InstallWeakDeps bool
}
func NewOSTreeArchive(ref string) *OSTreeArchive {
return &OSTreeArchive{
Base: NewBase("ostree-archive"),
OSTreeRef: ref,
InstallWeakDeps: true,
}
}
func (img *OSTreeArchive) InstantiateManifest(m *manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
buildPipeline := manifest.NewBuild(m, runner, repos)
buildPipeline.Checkpoint()
osPipeline := manifest.NewOS(m, buildPipeline, img.Platform, repos)
osPipeline.OSCustomizations = img.OSCustomizations
osPipeline.Environment = img.Environment
osPipeline.Workload = img.Workload
osPipeline.OSTreeParent = img.OSTreeParent
osPipeline.OSTreeRef = img.OSTreeRef
osPipeline.InstallWeakDeps = img.InstallWeakDeps
ostreeCommitPipeline := manifest.NewOSTreeCommit(buildPipeline, osPipeline, img.OSTreeRef)
ostreeCommitPipeline.OSVersion = img.OSVersion
tarPipeline := manifest.NewTar(buildPipeline, ostreeCommitPipeline, "commit-archive")
tarPipeline.SetFilename(img.Filename)
artifact := tarPipeline.Export()
return artifact, nil
}