From dcf8409e6961d225cda77aa70dd24050762f2ccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20L=C3=B6nnegren?= Date: Thu, 14 Dec 2023 15:18:35 +0100 Subject: [PATCH] Add disable-boot-entry flag to reset command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Lönnegren --- .obs/chartfile/crds/templates/crds.yaml | 2 ++ api/v1beta1/types.go | 2 ++ cmd/register/main_test.go | 24 ++++++++++--------- ...mental.cattle.io_machineregistrations.yaml | 2 ++ pkg/elementalcli/elementalcli.go | 1 + 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.obs/chartfile/crds/templates/crds.yaml b/.obs/chartfile/crds/templates/crds.yaml index dd5e56c1f..089910797 100644 --- a/.obs/chartfile/crds/templates/crds.yaml +++ b/.obs/chartfile/crds/templates/crds.yaml @@ -743,6 +743,8 @@ spec: type: array debug: type: boolean + disable-boot-entry: + type: boolean enabled: type: boolean poweroff: diff --git a/api/v1beta1/types.go b/api/v1beta1/types.go index c1df0985c..115f7a970 100644 --- a/api/v1beta1/types.go +++ b/api/v1beta1/types.go @@ -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 { diff --git a/cmd/register/main_test.go b/cmd/register/main_test.go index f19f6439e..00c838579 100644 --- a/cmd/register/main_test.go +++ b/cmd/register/main_test.go @@ -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) { @@ -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, }, }, } diff --git a/config/crd/bases/elemental.cattle.io_machineregistrations.yaml b/config/crd/bases/elemental.cattle.io_machineregistrations.yaml index 75c0f1787..809093f5e 100644 --- a/config/crd/bases/elemental.cattle.io_machineregistrations.yaml +++ b/config/crd/bases/elemental.cattle.io_machineregistrations.yaml @@ -127,6 +127,8 @@ spec: type: array debug: type: boolean + disable-boot-entry: + type: boolean enabled: type: boolean poweroff: diff --git a/pkg/elementalcli/elementalcli.go b/pkg/elementalcli/elementalcli.go index 61814ae8e..683fc86c5 100644 --- a/pkg/elementalcli/elementalcli.go +++ b/pkg/elementalcli/elementalcli.go @@ -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)))