Files
kured/pkg/reboot/command.go
Jean-Philippe Evrard f34864758e Cleanup rebooter interface
Without this, the interface and the code to reboot is
a bit more complex than it should be.

We do not need setters and getters, as we are just
instanciating a single instance of a rebooter interface.

We create it based on user input, then pass the object
around. This should cleanup the code.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2024-10-18 00:53:38 +02:00

23 lines
641 B
Go

package reboot
import (
"github.com/kubereboot/kured/pkg/util"
log "github.com/sirupsen/logrus"
)
// CommandRebooter holds context-information for a command reboot.
type CommandRebooter struct {
NodeID string
RebootCommand []string
}
// NewCommandReboot creates a new command-rebooter which needs full privileges on the host.
// Reboot triggers the command-reboot.
func (c CommandRebooter) Reboot() {
log.Infof("Running command: %s for node: %s", c.RebootCommand, c.NodeID)
if err := util.NewCommand(c.RebootCommand[0], c.RebootCommand[1:]...).Run(); err != nil {
log.Fatalf("Error invoking reboot command: %v", err)
}
}