2022-10-03 00:16:01 +02:00
|
|
|
package hook
|
|
|
|
|
|
|
|
import (
|
2023-03-15 15:45:00 +01:00
|
|
|
"github.com/kairos-io/kairos-sdk/bundles"
|
2023-03-18 10:27:18 +01:00
|
|
|
"github.com/kairos-io/kairos-sdk/machine"
|
2023-03-30 14:18:53 +03:00
|
|
|
config "github.com/kairos-io/kairos/v2/pkg/config"
|
2022-10-03 00:16:01 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type BundleOption struct{}
|
|
|
|
|
|
|
|
func (b BundleOption) Run(c config.Config) error {
|
|
|
|
|
|
|
|
machine.Mount("COS_PERSISTENT", "/usr/local") //nolint:errcheck
|
|
|
|
defer func() {
|
2022-10-23 20:22:32 +02:00
|
|
|
machine.Umount("/usr/local") //nolint:errcheck
|
2022-10-03 00:16:01 +02:00
|
|
|
}()
|
|
|
|
|
|
|
|
machine.Mount("COS_OEM", "/oem") //nolint:errcheck
|
|
|
|
defer func() {
|
2022-10-23 20:22:32 +02:00
|
|
|
machine.Umount("/oem") //nolint:errcheck
|
2022-10-03 00:16:01 +02:00
|
|
|
}()
|
|
|
|
|
|
|
|
opts := c.Install.Bundles.Options()
|
|
|
|
err := bundles.RunBundles(opts...)
|
|
|
|
if c.FailOnBundleErrors && err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2022-10-24 08:34:49 +02:00
|
|
|
|
|
|
|
type BundlePostInstall struct{}
|
|
|
|
|
|
|
|
func (b BundlePostInstall) Run(c config.Config) error {
|
|
|
|
opts := c.Bundles.Options()
|
|
|
|
err := bundles.RunBundles(opts...)
|
|
|
|
if c.FailOnBundleErrors && err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|