disk: generate fstab stage options for osbuild v2
Same function as v1 but generates v2 struct for v2 pipelines
This commit is contained in:
parent
fd4a8387f7
commit
23de460a66
1 changed files with 21 additions and 0 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"sort"
|
||||
|
||||
osbuild "github.com/osbuild/osbuild-composer/internal/osbuild1"
|
||||
"github.com/osbuild/osbuild-composer/internal/osbuild2"
|
||||
)
|
||||
|
||||
type PartitionTable struct {
|
||||
|
|
@ -82,6 +83,26 @@ func (pt PartitionTable) FSTabStageOptions() *osbuild.FSTabStageOptions {
|
|||
return &options
|
||||
}
|
||||
|
||||
// Generates org.osbuild.fstab stage options from this partition table.
|
||||
func (pt PartitionTable) FSTabStageOptionsV2() *osbuild2.FSTabStageOptions {
|
||||
var options osbuild2.FSTabStageOptions
|
||||
for _, p := range pt.Partitions {
|
||||
fs := p.Filesystem
|
||||
if fs == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
options.AddFilesystem(fs.UUID, fs.Type, fs.Mountpoint, fs.FSTabOptions, fs.FSTabFreq, fs.FSTabPassNo)
|
||||
}
|
||||
|
||||
// sort the entries by PassNo to maintain backward compatibility
|
||||
sort.Slice(options.FileSystems, func(i, j int) bool {
|
||||
return options.FileSystems[i].PassNo < options.FileSystems[j].PassNo
|
||||
})
|
||||
|
||||
return &options
|
||||
}
|
||||
|
||||
// Returns the root partition (the partition whose filesystem has / as
|
||||
// a mountpoint) of the partition table. Nil is returned if there's no such
|
||||
// partition.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue