mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-01 13:17:09 +00:00
Bring UKI to a working state (#97)
- Mount the needed base mounts (/proc /dev /sys /tmp) - Use our own console for yip (required to add the PATH under uki) - Order the DAG in a proper way (was out of order and not working) Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
48
internal/utils/cloudinit_console.go
Normal file
48
internal/utils/cloudinit_console.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
// ImmucoreConsole is the console for yip. As we have to hijack the Run method to be able to run under UKI
|
||||
// To add the paths, we need to create our own console.
|
||||
type ImmucoreConsole struct {
|
||||
}
|
||||
|
||||
func (s ImmucoreConsole) Run(cmd string, opts ...func(cmd *exec.Cmd)) (string, error) {
|
||||
c := PrepareCommandWithPath(cmd)
|
||||
for _, o := range opts {
|
||||
o(c)
|
||||
}
|
||||
out, err := c.CombinedOutput()
|
||||
if err != nil {
|
||||
return string(out), fmt.Errorf("failed to run %s: %v", cmd, err)
|
||||
}
|
||||
|
||||
return string(out), err
|
||||
}
|
||||
|
||||
func (s ImmucoreConsole) Start(cmd *exec.Cmd, opts ...func(cmd *exec.Cmd)) error {
|
||||
for _, o := range opts {
|
||||
o(cmd)
|
||||
}
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (s ImmucoreConsole) RunTemplate(st []string, template string) error {
|
||||
var errs error
|
||||
|
||||
for _, svc := range st {
|
||||
out, err := s.Run(fmt.Sprintf(template, svc))
|
||||
if err != nil {
|
||||
Log.Err(err).Msg("Run template")
|
||||
Log.Debug().Str("output", out).Msg("Run template")
|
||||
errs = multierror.Append(errs, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
return errs
|
||||
}
|
Reference in New Issue
Block a user