Skip to content

Commit

Permalink
feat: add --on-reboot flag to talosctl edit/patch machineConfig
Browse files Browse the repository at this point in the history
This allows to apply config even if sequencer is locked to recover from
confguration mistakes.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Mar 3, 2021
1 parent 49a23bb commit 60b7f79
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/talosctl/cmd/talos/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
var editCmdFlags struct {
namespace string
immediate bool
onReboot bool
}

// editCmd represents the edit command.
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
}
3 changes: 3 additions & 0 deletions cmd/talosctl/cmd/talos/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var patchCmdFlags struct {
patch string
patchFile string
immediate bool
onReboot bool
}

// patchCmd represents the edit command.
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
}
2 changes: 2 additions & 0 deletions website/content/docs/v0.9/Reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
```
Expand Down

0 comments on commit 60b7f79

Please sign in to comment.