From 07d524e484dbcb32fa27e6eeb67037e76223e5eb Mon Sep 17 00:00:00 2001 From: Ettore Di Giacinto Date: Sun, 23 Oct 2022 20:22:32 +0200 Subject: [PATCH] sparkles: state api sdk (#262) * :sparkles: 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. * :robot: Add test * Update go.mod * :gear: Fine-tune detection of partitions * :robot: Add more fine-grained tests * :art: Add /dev/ to partition name * :robot: Fixup tests * :gear: Remount accessors * :sparkles: Add state partition to cloud-init paths * :memo: Upper case Kairos in motd * :art: Add mounts sdk * :art: Set grub options via SDK * :art: Make it more idiomatic --- pkg/machine/partitions.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/machine/partitions.go b/pkg/machine/partitions.go index b75d0ad..558cd6a 100644 --- a/pkg/machine/partitions.go +++ b/pkg/machine/partitions.go @@ -8,8 +8,20 @@ import ( "github.com/kairos-io/kairos/pkg/utils" ) -func Umount(path string) { - utils.SH(fmt.Sprintf("umount %s", path)) //nolint:errcheck +func Umount(path string) error { + out, err := utils.SH(fmt.Sprintf("umount %s", path)) + if err != nil { + return fmt.Errorf("failed umounting: %s: %w", out, err) + } + return nil +} + +func Remount(opt, path string) error { + out, err := utils.SH(fmt.Sprintf("mount -o %s,remount %s", opt, path)) + if err != nil { + return fmt.Errorf("failed umounting: %s: %w", out, err) + } + return nil } func Mount(label, mountpoint string) error {