Skip to content

Commit

Permalink
fix: completely prevent editing resources other than mc
Browse files Browse the repository at this point in the history
The previous check only applied to `talosctl edit <type>`, but failed to
check `talosctl edit <type> <id>`.

Editing didn't work anyways, but this prevents unhelpful error messages.

Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
  • Loading branch information
smira committed Sep 15, 2021
1 parent 19a8ae9 commit ec7f44e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cmd/talosctl/cmd/talos/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ or 'notepad' for Windows.`,
var lastError string

editFn := func(parentCtx context.Context, msg client.ResourceResponse) error {
if msg.Resource == nil {
if msg.Definition != nil {
if msg.Definition.Metadata().ID() != strings.ToLower(config.MachineConfigType) {
return fmt.Errorf("only the machineconfig resource can be edited")
}
}

if msg.Resource == nil {
return nil
}

Expand Down

0 comments on commit ec7f44e

Please sign in to comment.