cirruslabs / tart

macOS and Linux VMs on Apple Silicon to use in CI and other automations
https://tart.run
Other
3.8k stars 111 forks source link

Request: Throw error when cloning VM if target already exists #822

Closed ncs29 closed 4 months ago

ncs29 commented 4 months ago

Currently, when cloning a VM, if the target VM already exists, it is overwritten right away without any warnings or notice.

The request is as follows:

This will ensure VMs are not deleted accidentally due to incorrect/typo commands.

Thanks!

edigaryev commented 4 months ago

The ubiquitous cp(1) command doesn't ask for the confirmation either.

This behavior has been pretty useful when re-running Tart in a pipeline like this multiple times:

tart clone ghcr.io/cirruslabs/macos-sonoma-base:latest macos && tart run macos

After fiddling with the VM you press Ctrl+C and re-run the pipeline, effortlessly getting a fresh VM each time without the need to tart delete.

ncs29 commented 4 months ago

Got it @edigaryev , I understand your point regarding ease of use with CI pipelines.

In that case, does it make sense to implement the reverse i.e. have a flag (eg: --no-overwrite or -n) that throws an error if target VM already exists (similar to cp -n flag)? IMHO, it would be nice to provide an option to clone VMs "safely", without having to manually check using tart list/tart get commands.

Thanks!

edigaryev commented 4 months ago

Would you mind explaining your use-case a bit more? Are you invoking the tart from some kind of script, or manually?

I wonder if it's possible to solve this without introducing any additional command-line arguments at all 🤔

ncs29 commented 4 months ago

I wonder if it's possible to solve this without introducing any additional command-line arguments at all 🤔

On second thought, I suppose it is possible, I was able to solve my problem by having a wrapper script to set up my build VM which checks if the target VM exists and then safely clone VM. Please feel free to close this issue. Thanks!