Skip to content

Commit

Permalink
Add disable-boot-entry flag to reset command
Browse files Browse the repository at this point in the history
Signed-off-by: Fredrik Lönnegren <[email protected]>
  • Loading branch information
frelon committed Dec 14, 2023
1 parent 4f00fe4 commit dcf8409
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .obs/chartfile/crds/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,8 @@ spec:
type: array
debug:
type: boolean
disable-boot-entry:
type: boolean
enabled:
type: boolean
poweroff:
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ type Reset struct {
// +optional
// +kubebuilder:default:=true
Reboot bool `json:"reboot,omitempty" yaml:"reboot,omitempty" mapstructure:"reboot"`
// +optional
DisableBootEntry bool `json:"disable-boot-entry,omitempty" yaml:"disable-boot-entry,omitempty"`
}

type Registration struct {
Expand Down
24 changes: 13 additions & 11 deletions cmd/register/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
elementalv1 "github.com/rancher/elemental-operator/api/v1beta1"
imocks "github.com/rancher/elemental-operator/pkg/install/mocks"
"github.com/rancher/elemental-operator/pkg/register"
rmocks "github.com/rancher/elemental-operator/pkg/register/mocks"
"github.com/spf13/cobra"
"github.com/twpayne/go-vfs"
"github.com/twpayne/go-vfs/vfst"
"go.uber.org/mock/gomock"
"gopkg.in/yaml.v3"

elementalv1 "github.com/rancher/elemental-operator/api/v1beta1"
imocks "github.com/rancher/elemental-operator/pkg/install/mocks"
"github.com/rancher/elemental-operator/pkg/register"
rmocks "github.com/rancher/elemental-operator/pkg/register/mocks"
)

func TestRegister(t *testing.T) {
Expand Down Expand Up @@ -93,13 +94,14 @@ var (
ConfigDir: "a test config dir",
},
Reset: elementalv1.Reset{
Enabled: true,
ResetPersistent: false,
ResetOEM: false,
ConfigURLs: []string{"foo", "bar"},
SystemURI: "a system uri",
PowerOff: true,
Reboot: true,
Enabled: true,
ResetPersistent: false,
ResetOEM: false,
ConfigURLs: []string{"foo", "bar"},
SystemURI: "a system uri",
PowerOff: true,
Reboot: true,
DisableBootEntry: true,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ spec:
type: array
debug:
type: boolean
disable-boot-entry:
type: boolean
enabled:
type: boolean
poweroff:
Expand Down
1 change: 1 addition & 0 deletions pkg/elementalcli/elementalcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func mapToResetEnv(conf elementalv1.Reset) []string {
variables = append(variables, formatEV("ELEMENTAL_RESET_SYSTEM", conf.SystemURI))
variables = append(variables, formatEV("ELEMENTAL_RESET_PERSISTENT", strconv.FormatBool(conf.ResetOEM)))
variables = append(variables, formatEV("ELEMENTAL_RESET_OEM", strconv.FormatBool(conf.ResetPersistent)))
variables = append(variables, formatEV("ELEMENTAL_RESET_DISABLE_BOOT_ENTRY", strconv.FormatBool(conf.DisableBootEntry)))
// See GetRunKeyEnvMap() in https://github.com/rancher/elemental-toolkit/blob/main/pkg/constants/constants.go
variables = append(variables, formatEV("ELEMENTAL_POWEROFF", strconv.FormatBool(conf.PowerOff)))
variables = append(variables, formatEV("ELEMENTAL_REBOOT", strconv.FormatBool(conf.Reboot)))
Expand Down

0 comments on commit dcf8409

Please sign in to comment.