mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-09-18 08:12:10 +00:00
Extract sdk into its own lib
This had some side effects: - Have to add some utils from the kairos/machine modules, which IMHO should not be there, they should be here if the are generic enough - Dropping the sdk dir, just have the modules in the root dir Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
30
system/options.go
Normal file
30
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