2022-09-08 13:39:26 +00:00
|
|
|
package hook
|
|
|
|
|
|
|
|
import (
|
2023-07-10 12:39:48 +00:00
|
|
|
config "github.com/kairos-io/kairos-agent/v2/pkg/config"
|
2023-07-24 10:28:59 +00:00
|
|
|
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
2022-09-08 13:39:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Interface interface {
|
2023-07-24 10:28:59 +00:00
|
|
|
Run(c config.Config, spec v1.Spec) error
|
2022-09-08 13:39:26 +00:00
|
|
|
}
|
|
|
|
|
2023-01-25 12:38:56 +00:00
|
|
|
var AfterInstall = []Interface{
|
2022-09-08 13:39:26 +00:00
|
|
|
&GrubOptions{}, // Set custom GRUB options
|
2023-09-15 13:40:27 +00:00
|
|
|
&BundlePostInstall{},
|
2023-02-03 10:04:02 +00:00
|
|
|
&CustomMounts{},
|
2024-03-07 14:11:51 +00:00
|
|
|
&CopyLogs{},
|
2022-10-02 22:16:01 +00:00
|
|
|
&Lifecycle{}, // Handles poweroff/reboot by config options
|
2022-09-08 13:39:26 +00:00
|
|
|
}
|
|
|
|
|
2023-07-24 10:28:59 +00:00
|
|
|
var AfterReset = []Interface{
|
2024-04-11 09:35:31 +00:00
|
|
|
&CopyLogs{},
|
2023-07-24 10:28:59 +00:00
|
|
|
&Lifecycle{},
|
|
|
|
}
|
|
|
|
|
|
|
|
var AfterUpgrade = []Interface{
|
|
|
|
&Lifecycle{},
|
|
|
|
}
|
2023-01-25 12:38:56 +00:00
|
|
|
|
2022-10-24 06:34:49 +00:00
|
|
|
var FirstBoot = []Interface{
|
2023-09-15 13:40:27 +00:00
|
|
|
&BundleFirstBoot{},
|
2022-10-24 06:34:49 +00:00
|
|
|
&GrubPostInstallOptions{},
|
|
|
|
}
|
|
|
|
|
2023-10-03 09:15:17 +00:00
|
|
|
// AfterUkiInstall sets which Hooks to run after uki runs the install action
|
2024-04-23 12:37:21 +00:00
|
|
|
var AfterUkiInstall = []Interface{
|
|
|
|
&Lifecycle{},
|
|
|
|
}
|
2024-02-27 16:25:20 +00:00
|
|
|
|
|
|
|
var UKIEncryptionHooks = []Interface{
|
2023-12-12 20:51:55 +00:00
|
|
|
&KcryptUKI{},
|
|
|
|
}
|
2023-10-03 09:15:17 +00:00
|
|
|
|
2024-02-27 16:25:20 +00:00
|
|
|
var EncryptionHooks = []Interface{
|
|
|
|
&Kcrypt{},
|
|
|
|
}
|
|
|
|
|
2023-07-24 10:28:59 +00:00
|
|
|
func Run(c config.Config, spec v1.Spec, hooks ...Interface) error {
|
2022-09-08 13:39:26 +00:00
|
|
|
for _, h := range hooks {
|
2023-07-24 10:28:59 +00:00
|
|
|
if err := h.Run(c, spec); err != nil {
|
2022-09-08 13:39:26 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|