-
Notifications
You must be signed in to change notification settings - Fork 669
Add edit command #572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add edit command #572
Conversation
Signed-off-by: ye.sijun <[email protected]>
I think the edit command should restart the instance automatically if it is already running (but don't restart when the editing was aborted). Leaving the instance running with the old config is confusing, as the You could add |
Automatic restart may surprise users, so I prefer —restart to be false by default |
I fail to see the surprise: you edit the config to change the instance; why would you not expect the instance to reflect the modified settings? To me it is the opposite: When I change the config, e.g. to increase the amount of memory to the instance, I expect those changes to be active when I "save" them. Think of it as a crude "preferences" or "settings" dialog. It is highly unusual to change settings and not have them take effect when you close that dialog. Some dialogs may have an "Apply" button, so changes don't take effect immediately. But once the dialog is closed, the desired and actual state are reconciled. 😄 How does it make sense to have a running instance that doesn't match its configuration data? |
Also think about the confusion if you don't apply the changes on save, and then forget that you have edited the config: if you edit the instance again a week later, the config file no longer reflects the state of the instance at all, and now you wonder how it all got into this state. If you want to have a modified config file separate from the running instance, you should make a copy, and edit the copy while it is in stopped state. (I know we don't have a copy/clone command yet). |
I agree with @jandubois . Or can we only allow editing of stopped instances? |
Not all users expect automatic restart because they might be running some apps with unsaved data. Also, some properties could be updated without restarting (in future).
This also SGTM |
IMO there should be a promt about restart. E.g., |
I assume you want to ask a question here after the editor has been closed, and not ask if the user actually wants to edit the file. I would agree with this if we discard the changes when the user decides not to restart the VM, e.g. $ limactl edit alpine
Waiting for editor...
--- current configuration
+++ new configuration
@@ -9,6 +9,7 @@ images:
mounts:
- location: "~"
+ writable: true
- location: "/tmp/lima"
writable: true
? Instance "alpine" configuration has been changed [Use arrows to move, type to filter]
> Apply changes and restart instance
Edit to make more changes
Discard changes and exit If the instance is already stopped, then the first option would simply be `Save changes". I would still disagree with letting the user keep changes in the file for a running instance without applying them: you either apply or discard. |
I think |
Signed-off-by: ye.sijun <[email protected]>
@jandubois I added a patch that only allows editing of non-running instances, what do you think? |
I think this is fine. It addresses my concern that the Given that But I understand that this is outside the scope of your current PR, so will file this as an enhancement request (suggestion, really), so maybe somebody may implement it at a later time. Still waiting to hear what others think. |
@@ -40,12 +43,16 @@ func editAction(cmd *cobra.Command, args []string) error { | |||
return err | |||
} | |||
|
|||
if inst.Status == store.StatusRunning { | |||
return errors.New("Cannot edit a running instance") | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should take a lock, but can be another PR
https://github.com/lima-vm/lima/blob/v0.8.1/pkg/lockutil/lockutil.go
@jandubois LGTY? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM.
Philosophically it feels weird to me that we don't allow editing of a running instance by stopping it first, but we do ask to start the stopped instance after editing it. But we can debate and change it some other time.
Hello everyone, I have a problem with running a command
|
You can read the old README, if you want: https://github.com/lima-vm/lima/tree/v0.8.1 |
I implemented the same in the GUI, to disable the "Edit" button for running instances. Didn't put up a dialog for starting it, since the "Start" button is right there for clicking... |
Signed-off-by: ye.sijun [email protected]
Fixes: #190