kairos-sdk/system/options.go
Itxaka 3163cfbac0 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>
2023-03-15 10:56:11 +01:00

31 lines
422 B
Go

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
}