Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor some elemental package methods to be used as stand alone functions #1883

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/action/build-disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (b *BuildDiskAction) BuildDiskRun() (err error) { //nolint:gocyclo
activeRoot := recRoot

// Create recovery root
recInfo, err = e.DumpSource(recRoot, b.spec.Recovery.Source)
recInfo, err = elemental.DumpSource(b.cfg.Config, recRoot, b.spec.Recovery.Source)
if err != nil {
b.cfg.Logger.Errorf("failed loading recovery image source tree: %s", err.Error())
return err
Expand All @@ -165,7 +165,7 @@ func (b *BuildDiskAction) BuildDiskRun() (err error) { //nolint:gocyclo
if !b.spec.Active.Source.IsEmpty() {
// Create active root
activeRoot = filepath.Join(workdir, filepath.Base(b.spec.Active.File)+rootSuffix)
activeInfo, err = e.DumpSource(activeRoot, b.spec.Active.Source)
activeInfo, err = elemental.DumpSource(b.cfg.Config, activeRoot, b.spec.Active.Source)
if err != nil {
b.cfg.Logger.Errorf("failed loading active image source tree: %s", err.Error())
return err
Expand All @@ -174,7 +174,7 @@ func (b *BuildDiskAction) BuildDiskRun() (err error) { //nolint:gocyclo
}

// Copy cloud-init if any
err = e.CopyCloudConfig(b.roots[constants.OEMPartName], b.spec.CloudInit)
err = elemental.CopyCloudConfig(b.cfg.Config, b.roots[constants.OEMPartName], b.spec.CloudInit)
if err != nil {
return elementalError.NewFromError(err, elementalError.CopyFile)
}
Expand Down Expand Up @@ -378,7 +378,7 @@ func (b *BuildDiskAction) CreatePartitionImages(e *elemental.Elemental) ([]*v1.I

b.cfg.Logger.Infof("Creating EFI partition image")
img = b.spec.Partitions.EFI.ToImage()
err = e.CreateFileSystemImage(img)
err = elemental.CreateFileSystemImage(b.cfg.Config, img, "", false)
if err != nil {
b.cfg.Logger.Errorf("failed creating EFI image: %s", err.Error())
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions pkg/action/build-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ func (b BuildISOAction) createEFI(root string, img string) error {
align := int64(4 * 1024 * 1024)
efiSizeMB := (efiSize/align*align + align) / (1024 * 1024)

err = b.e.CreateFileSystemImage(&v1.Image{
err = elemental.CreateFileSystemImage(b.cfg.Config, &v1.Image{
File: img,
Size: uint(efiSizeMB),
FS: constants.EfiFs,
Label: constants.EfiLabel,
})
}, "", false)
if err != nil {
return err
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func (b BuildISOAction) burnISO(root, efiImg string) error {

func (b BuildISOAction) applySources(target string, sources ...*v1.ImageSource) error {
for _, src := range sources {
_, err := b.e.DumpSource(target, src)
_, err := elemental.DumpSource(b.cfg.Config, target, src)
if err != nil {
return elementalError.NewFromError(err, elementalError.DumpSource)
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ func (i InstallAction) Run() (err error) {

// Set installation sources from a downloaded ISO
if i.spec.Iso != "" {
isoCleaner, err := e.UpdateSourceFormISO(i.spec.Iso, &i.spec.Active)
isoSrc, isoCleaner, err := elemental.SourceFormISO(i.cfg.Config, i.spec.Iso)
cleanup.Push(isoCleaner)
if err != nil {
return elementalError.NewFromError(err, elementalError.Unknown)
}
i.spec.Active.Source = isoSrc
}

// Partition and format device if needed
Expand Down Expand Up @@ -190,7 +191,7 @@ func (i InstallAction) Run() (err error) {
cleanup.Push(func() error { return treeCleaner() })

// Copy cloud-init if any
err = e.CopyCloudConfig(i.spec.Partitions.GetConfigStorage(), i.spec.CloudInit)
err = elemental.CopyCloudConfig(i.cfg.Config, i.spec.Partitions.GetConfigStorage(), i.spec.CloudInit)
if err != nil {
return elementalError.NewFromError(err, elementalError.CopyFile)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/action/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (r ResetAction) Run() (err error) {
cleanup.Push(func() error { return treeCleaner() })

// Copy cloud-init if any
err = e.CopyCloudConfig(r.spec.Partitions.GetConfigStorage(), r.spec.CloudInit)
err = elemental.CopyCloudConfig(r.cfg.Config, r.spec.Partitions.GetConfigStorage(), r.spec.CloudInit)
if err != nil {
return elementalError.NewFromError(err, elementalError.CopyFile)
}
Expand Down
Loading