mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-09-13 21:20:47 +00:00
fix(after-install): run after-install hook after partitions are encrypted
This commit is contained in:
@@ -13,7 +13,6 @@ var AfterInstall = []Interface{
|
|||||||
&GrubOptions{}, // Set custom GRUB options
|
&GrubOptions{}, // Set custom GRUB options
|
||||||
&BundlePostInstall{},
|
&BundlePostInstall{},
|
||||||
&CustomMounts{},
|
&CustomMounts{},
|
||||||
&Kcrypt{},
|
|
||||||
&Lifecycle{}, // Handles poweroff/reboot by config options
|
&Lifecycle{}, // Handles poweroff/reboot by config options
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,10 +30,16 @@ var FirstBoot = []Interface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AfterUkiInstall sets which Hooks to run after uki runs the install action
|
// AfterUkiInstall sets which Hooks to run after uki runs the install action
|
||||||
var AfterUkiInstall = []Interface{
|
var AfterUkiInstall = []Interface{}
|
||||||
|
|
||||||
|
var UKIEncryptionHooks = []Interface{
|
||||||
&KcryptUKI{},
|
&KcryptUKI{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var EncryptionHooks = []Interface{
|
||||||
|
&Kcrypt{},
|
||||||
|
}
|
||||||
|
|
||||||
func Run(c config.Config, spec v1.Spec, hooks ...Interface) error {
|
func Run(c config.Config, spec v1.Spec, hooks ...Interface) error {
|
||||||
for _, h := range hooks {
|
for _, h := range hooks {
|
||||||
if err := h.Run(c, spec); err != nil {
|
if err := h.Run(c, spec); err != nil {
|
||||||
|
@@ -18,13 +18,14 @@ package action
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
hook "github.com/kairos-io/kairos-agent/v2/internal/agent/hooks"
|
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
|
||||||
events "github.com/kairos-io/kairos-sdk/bus"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
hook "github.com/kairos-io/kairos-agent/v2/internal/agent/hooks"
|
||||||
|
"github.com/kairos-io/kairos-agent/v2/pkg/config"
|
||||||
|
events "github.com/kairos-io/kairos-sdk/bus"
|
||||||
|
|
||||||
cnst "github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
cnst "github.com/kairos-io/kairos-agent/v2/pkg/constants"
|
||||||
"github.com/kairos-io/kairos-agent/v2/pkg/elemental"
|
"github.com/kairos-io/kairos-agent/v2/pkg/elemental"
|
||||||
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
v1 "github.com/kairos-io/kairos-agent/v2/pkg/types/v1"
|
||||||
@@ -252,6 +253,11 @@ func (i InstallAction) Run() (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = hook.Run(*i.cfg, i.spec, hook.EncryptionHooks...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err = i.installHook(cnst.AfterInstallHook, false)
|
err = i.installHook(cnst.AfterInstallHook, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@@ -144,6 +144,11 @@ func (i *InstallAction) Run() (err error) {
|
|||||||
return fmt.Errorf("removing artifact set with role %s: %w", UnassignedArtifactRole, err)
|
return fmt.Errorf("removing artifact set with role %s: %w", UnassignedArtifactRole, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = hook.Run(*i.cfg, i.spec, hook.UKIEncryptionHooks...)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// after install hook happens after install (this is for compatibility with normal install, so users can reuse their configs)
|
// after install hook happens after install (this is for compatibility with normal install, so users can reuse their configs)
|
||||||
err = Hook(i.cfg, constants.AfterInstallHook)
|
err = Hook(i.cfg, constants.AfterInstallHook)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user