Skip to content

Commit ec7f44e

Browse files
committed
fix: completely prevent editing resources other than mc
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>
1 parent 19a8ae9 commit ec7f44e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cmd/talosctl/cmd/talos/edit.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ or 'notepad' for Windows.`,
5454
var lastError string
5555

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

63+
if msg.Resource == nil {
6264
return nil
6365
}
6466

0 commit comments

Comments
 (0)