mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-09-09 19:19:30 +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
5aeed0ddd2
commit
696e87bbee
30
sdk/system/options.go
Normal file
30
sdk/system/options.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
type Changeset []func() error
|
||||
|
||||
func (c *Changeset) Add(f func() error) {
|
||||
*c = append(*c, f)
|
||||
}
|
||||
|
||||
type Option func(c *Changeset) error
|
||||
|
||||
func Apply(opts ...Option) error {
|
||||
|
||||
c := &Changeset{}
|
||||
for _, o := range opts {
|
||||
if err := o(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var err error
|
||||
for _, f := range *c {
|
||||
err = multierror.Append(f())
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
Reference in New Issue
Block a user