package uboot import ( "context" "fmt" "os" "example.com/monok8s/pkg/node" ) func ConfigureABBoot(ctx context.Context, nctx *node.NodeContext) error { exePath, err := os.Executable() if err != nil { return fmt.Errorf("get current executable path: %w", err) } writer := NewFWEnvWriter(HostFWEnvCfgPath, exePath) // TODO: configurable from cluster.env return writer.EnsureBootEnv(ctx, BootEnvConfig{ BootSource: "usb", BootPart: "A", }) } // This is called by the agent controller/osupgrade/handler.go func ConfigureNextBoot(ctx context.Context, fwEnvCfgPath string) error { exePath, err := os.Executable() if err != nil { return fmt.Errorf("get current executable path: %w", err) } writer := NewFWEnvWriter(fwEnvCfgPath, exePath) currBootPart, err := writer.GetEnv(ctx, "boot_part") if err != nil { return fmt.Errorf("get boot_part: %w", err) } next := "A" if currBootPart == "A" { next = "B" } currBootSource, err := writer.GetEnv(ctx, "boot_source") if err != nil { return fmt.Errorf("get boot_source: %w", err) } return writer.EnsureBootEnv(ctx, BootEnvConfig{ BootSource: currBootSource, BootPart: next, }) }