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