mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-23 18:43:01 +00:00
sparkles: enhancements (#263)
* 🎨 Do not need to prefix '.' on queries * ✨ Add recovery to stateapi * ✨ Add cloudconfig SDK * ✨ Unify post-install/firstboot hooks This also adds capabilities to add grub option at first boot rather than after installation as for bundles. * 🤖 Optimize tests to wait for state to change
This commit is contained in:
parent
5893294c54
commit
0af13f655f
@ -8,10 +8,10 @@ import (
|
|||||||
|
|
||||||
events "github.com/kairos-io/kairos/sdk/bus"
|
events "github.com/kairos-io/kairos/sdk/bus"
|
||||||
|
|
||||||
|
hook "github.com/kairos-io/kairos/internal/agent/hooks"
|
||||||
"github.com/kairos-io/kairos/internal/bus"
|
"github.com/kairos-io/kairos/internal/bus"
|
||||||
config "github.com/kairos-io/kairos/pkg/config"
|
config "github.com/kairos-io/kairos/pkg/config"
|
||||||
machine "github.com/kairos-io/kairos/pkg/machine"
|
machine "github.com/kairos-io/kairos/pkg/machine"
|
||||||
bundles "github.com/kairos-io/kairos/sdk/bundles"
|
|
||||||
"github.com/nxadm/tail"
|
"github.com/nxadm/tail"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,16 +60,15 @@ func Run(opts ...Option) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if !machine.SentinelExist("bundles") {
|
if !machine.SentinelExist("firstboot") {
|
||||||
opts := c.Bundles.Options()
|
|
||||||
err := bundles.RunBundles(opts...)
|
if err := hook.Run(*c, hook.FirstBoot...); err != nil {
|
||||||
if c.FailOnBundleErrors && err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-load providers
|
// Re-load providers
|
||||||
bus.Reload()
|
bus.Reload()
|
||||||
err = machine.CreateSentinel("bundles")
|
err = machine.CreateSentinel("firstboot")
|
||||||
if c.FailOnBundleErrors && err != nil {
|
if c.FailOnBundleErrors && err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -28,3 +28,14 @@ func (b BundleOption) Run(c config.Config) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
@ -16,3 +16,13 @@ func (b GrubOptions) Run(c config.Config) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GrubPostInstallOptions struct{}
|
||||||
|
|
||||||
|
func (b GrubPostInstallOptions) Run(c config.Config) error {
|
||||||
|
err := system.Apply(system.SetGRUBOptions(c.GrubOptions))
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -16,6 +16,11 @@ var All = []Interface{
|
|||||||
&Lifecycle{}, // Handles poweroff/reboot by config options
|
&Lifecycle{}, // Handles poweroff/reboot by config options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var FirstBoot = []Interface{
|
||||||
|
&BundlePostInstall{},
|
||||||
|
&GrubPostInstallOptions{},
|
||||||
|
}
|
||||||
|
|
||||||
func Run(c config.Config, hooks ...Interface) error {
|
func Run(c config.Config, hooks ...Interface) error {
|
||||||
for _, h := range hooks {
|
for _, h := range hooks {
|
||||||
if err := h.Run(c); err != nil {
|
if err := h.Run(c); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user