feat: add --on-reboot flag to talosctl edit/patch machineConfig

This allows to apply config even if sequencer is locked to recover from
confguration mistakes.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
Andrey Smirnov 2021-03-03 18:42:05 +03:00 committed by talos-bot
parent 49a23bbde8
commit 60b7f79fd8
3 changed files with 8 additions and 0 deletions

View File

@ -27,6 +27,7 @@ import (
var editCmdFlags struct {
namespace string
immediate bool
onReboot bool
}
// editCmd represents the edit command.
@ -132,6 +133,7 @@ or 'notepad' for Windows.`,
_, err = c.ApplyConfiguration(parentCtx, &machine.ApplyConfigurationRequest{
Data: edited,
Immediate: editCmdFlags.immediate,
OnReboot: editCmdFlags.onReboot,
})
if err != nil {
lastError = err.Error()
@ -160,5 +162,6 @@ or 'notepad' for Windows.`,
func init() {
editCmd.Flags().StringVar(&editCmdFlags.namespace, "namespace", "", "resource namespace (default is to use default namespace per resource)")
editCmd.Flags().BoolVar(&editCmdFlags.immediate, "immediate", false, "apply the change immediately (without a reboot)")
editCmd.Flags().BoolVar(&editCmdFlags.onReboot, "on-reboot", false, "apply the change on next reboot")
addCommand(editCmd)
}

View File

@ -29,6 +29,7 @@ var patchCmdFlags struct {
patch string
patchFile string
immediate bool
onReboot bool
}
// patchCmd represents the edit command.
@ -87,6 +88,7 @@ var patchCmd = &cobra.Command{
_, err = c.ApplyConfiguration(ctx, &machine.ApplyConfigurationRequest{
Data: patched,
Immediate: patchCmdFlags.immediate,
OnReboot: patchCmdFlags.onReboot,
})
if bytes.Equal(
@ -120,5 +122,6 @@ func init() {
patchCmd.Flags().StringVar(&patchCmdFlags.patchFile, "patch-file", "", "a file containing a patch to be applied to the resource.")
patchCmd.Flags().StringVarP(&patchCmdFlags.patch, "patch", "p", "", "the patch to be applied to the resource file.")
patchCmd.Flags().BoolVar(&patchCmdFlags.immediate, "immediate", false, "apply the change immediately (without a reboot)")
patchCmd.Flags().BoolVar(&patchCmdFlags.onReboot, "on-reboot", false, "apply the change on next reboot")
addCommand(patchCmd)
}

View File

@ -723,6 +723,7 @@ talosctl edit <type> [<id>] [flags]
-h, --help help for edit
--immediate apply the change immediately (without a reboot)
--namespace string resource namespace (default is to use default namespace per resource)
--on-reboot apply the change on next reboot
```
### Options inherited from parent commands
@ -1479,6 +1480,7 @@ talosctl patch <type> [<id>] [flags]
-h, --help help for patch
--immediate apply the change immediately (without a reboot)
--namespace string resource namespace (default is to use default namespace per resource)
--on-reboot apply the change on next reboot
-p, --patch string the patch to be applied to the resource file.
--patch-file string a file containing a patch to be applied to the resource.
```