Rework reboot/shutdown to use the hooks (#96)

This commit is contained in:
Itxaka
2023-07-24 12:28:59 +02:00
committed by GitHub
parent 4e5d116307
commit 956f86f99c
22 changed files with 101 additions and 467 deletions

View File

@@ -1,18 +1,22 @@
package hook
import (
"github.com/kairos-io/kairos-sdk/utils"
"github.com/kairos-io/kairos-agent/v2/pkg/config"
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
"github.com/kairos-io/kairos-sdk/utils"
"time"
)
type Lifecycle struct{}
func (s Lifecycle) Run(c config.Config) error {
if c.Install.Reboot {
func (s Lifecycle) Run(c config.Config, spec v1.Spec) error {
if spec.ShouldReboot() {
time.Sleep(5)
utils.Reboot()
}
if c.Install.Poweroff {
if spec.ShouldShutdown() {
time.Sleep(5)
utils.PowerOFF()
}
return nil