kairos-agent/internal/agent/hooks/kcrypt.go

35 lines
604 B
Go
Raw Normal View History

package hook
import (
"fmt"
"time"
2023-03-18 09:27:18 +00:00
"github.com/kairos-io/kairos-sdk/utils"
2023-05-08 07:43:47 +00:00
"github.com/kairos-io/kairos/v2/pkg/config"
)
type Kcrypt struct{}
func (k Kcrypt) Run(c config.Config) error {
if len(c.Install.Encrypt) == 0 {
return nil
}
for _, p := range c.Install.Encrypt {
out, err := utils.SH(fmt.Sprintf("kcrypt encrypt %s", p))
if err != nil {
fmt.Printf("could not encrypt partition: %s\n", out+err.Error())
if c.FailOnBundleErrors {
return err
}
// Give time to show the error
time.Sleep(10 * time.Second)
return nil // do not error out
}
}
return nil
}