mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-25 04:24:19 +00:00
sparkles: state api sdk (#262)
* ✨ Add state api This is related to https://github.com/kairos-io/kairos/issues/34. Starts to unify the API to retrieve the state in the sdk to have a common place to query system status information. * 🤖 Add test * Update go.mod * ⚙️ Fine-tune detection of partitions * 🤖 Add more fine-grained tests * 🎨 Add /dev/ to partition name * 🤖 Fixup tests * ⚙️ Remount accessors * ✨ Add state partition to cloud-init paths * 📝 Upper case Kairos in motd * 🎨 Add mounts sdk * 🎨 Set grub options via SDK * 🎨 Make it more idiomatic
This commit is contained in:
committed by
Itxaka
parent
5c4e29f3d3
commit
5893294c54
@@ -12,12 +12,12 @@ func (b BundleOption) Run(c config.Config) error {
|
||||
|
||||
machine.Mount("COS_PERSISTENT", "/usr/local") //nolint:errcheck
|
||||
defer func() {
|
||||
machine.Umount("/usr/local")
|
||||
machine.Umount("/usr/local") //nolint:errcheck
|
||||
}()
|
||||
|
||||
machine.Mount("COS_OEM", "/oem") //nolint:errcheck
|
||||
defer func() {
|
||||
machine.Umount("/oem")
|
||||
machine.Umount("/oem") //nolint:errcheck
|
||||
}()
|
||||
|
||||
opts := c.Install.Bundles.Options()
|
||||
|
@@ -4,25 +4,15 @@ import (
|
||||
"fmt"
|
||||
|
||||
config "github.com/kairos-io/kairos/pkg/config"
|
||||
"github.com/kairos-io/kairos/pkg/machine"
|
||||
"github.com/kairos-io/kairos/pkg/utils"
|
||||
"github.com/kairos-io/kairos/sdk/system"
|
||||
)
|
||||
|
||||
type GrubOptions struct{}
|
||||
|
||||
func (b GrubOptions) Run(c config.Config) error {
|
||||
|
||||
machine.Mount("COS_OEM", "/tmp/oem") //nolint:errcheck
|
||||
defer func() {
|
||||
machine.Umount("/tmp/oem")
|
||||
}()
|
||||
for k, v := range c.Install.GrubOptions {
|
||||
out, err := utils.SH(fmt.Sprintf(`grub2-editenv /tmp/oem/grubenv set "%s=%s"`, k, v))
|
||||
if err != nil {
|
||||
fmt.Printf("could not set boot option: %s\n", out+err.Error())
|
||||
return nil // do not error out
|
||||
}
|
||||
err := system.Apply(system.SetGRUBOptions(c.Install.GrubOptions))
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ func (k Kcrypt) Run(c config.Config) error {
|
||||
|
||||
machine.Mount("COS_OEM", "/oem") //nolint:errcheck
|
||||
defer func() {
|
||||
machine.Umount("/oem")
|
||||
machine.Umount("/oem") //nolint:errcheck
|
||||
}()
|
||||
|
||||
_ = os.MkdirAll("/oem/system/discovery", 0650)
|
||||
|
Reference in New Issue
Block a user