mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-04-27 19:15:23 +00:00
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>
31 lines
422 B
Go
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
|
|
}
|