Drop isrecovery from state struct

Only needed in one place, can be made into a function

Signed-off-by: Itxaka <itxaka@spectrocloud.com>
This commit is contained in:
Itxaka 2023-02-09 08:54:16 +01:00
parent 8cd3520311
commit cf69cffa4b
2 changed files with 6 additions and 6 deletions

View File

@ -58,7 +58,6 @@ Sends a generic event payload with the configuration found in the scanned direct
MountRoot: true, MountRoot: true,
TargetLabel: utils.BootStateToLabel(), TargetLabel: utils.BootStateToLabel(),
TargetImage: img[0], TargetImage: img[0],
IsRecovery: utils.IsRecovery(),
} }
err = s.Register(g) err = s.Register(g)

View File

@ -35,7 +35,6 @@ type State struct {
MountRoot bool // e.g. if true, it tries to find the image to loopback mount MountRoot bool // e.g. if true, it tries to find the image to loopback mount
fstabs []*fstab.Mount fstabs []*fstab.Mount
IsRecovery bool // if its recovery it needs different stuff
} }
const ( const (
@ -179,7 +178,9 @@ func readEnv(file string) (map[string]string, error) {
if err != nil { if err != nil {
return envMap, err return envMap, err
} }
defer f.Close() defer func(f *os.File) {
_ = f.Close()
}(f)
envMap, err = godotenv.Parse(f) envMap, err = godotenv.Parse(f)
if err != nil { if err != nil {
@ -234,7 +235,7 @@ func (s *State) Register(g *herd.Graph) error {
stateName := runtime.State.Name stateName := runtime.State.Name
stateFs := runtime.State.Type stateFs := runtime.State.Type
// Recovery is a different partition // Recovery is a different partition
if s.IsRecovery { if internalUtils.IsRecovery() {
stateName = runtime.Recovery.Name stateName = runtime.Recovery.Name
stateFs = runtime.Recovery.Type stateFs = runtime.Recovery.Type
} }
@ -282,7 +283,7 @@ func (s *State) Register(g *herd.Graph) error {
// This is building the mountRoot dependendency if it was enabled // This is building the mountRoot dependendency if it was enabled
mountRootCondition := herd.ConditionalOption(func() bool { return s.MountRoot }, herd.WithDeps(opMountRoot)) mountRootCondition := herd.ConditionalOption(func() bool { return s.MountRoot }, herd.WithDeps(opMountRoot))
// TODO: this needs to be run after sysroot so we can link to /sysroot/system/oem and after /oem mounted // this needs to be run after sysroot, so we can link to /sysroot/system/oem and after /oem mounted
err = g.Add(opRootfsHook, mountRootCondition, herd.WithDeps(opMountRoot, opMountOEM), herd.WithCallback(s.RunStageOp("rootfs"))) err = g.Add(opRootfsHook, mountRootCondition, herd.WithDeps(opMountRoot, opMountOEM), herd.WithCallback(s.RunStageOp("rootfs")))
if err != nil { if err != nil {
s.Logger.Err(err).Msg("running rootfs stage") s.Logger.Err(err).Msg("running rootfs stage")