Skip to content

Commit

Permalink
Do not check limactl list exit code
Browse files Browse the repository at this point in the history
Starting from lima v0.22.0 (I guess) `limactl ls <vm>` returns 1, when
the <vm> doesn't exist. That breaks many plans because list and status
tasks fails instead of returning empty result.

This commit removes the `limactl list` return code check. Maybe later
we can improve it.

Fixes #31
  • Loading branch information
jay7x committed Jun 2, 2024
1 parent 26500cd commit fbf00e6
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,15 @@ def version

def list(vm_names = [])
lima_cmd = [@limactl, 'list', '--json'] + vm_names
stdout_str, stderr_str, status = Open3.capture3(*lima_cmd)
unless status.success?
raise LimaError, "`#{lima_cmd.join(' ')}` failed with status #{status.exitstatus}: #{stderr_str}"
end
stdout_str, _stderr_str, _status = Open3.capture3(*lima_cmd)

stdout_str.split("\n").map { |vm| JSON.parse(vm) }
end

# A bit faster `list` variant to check the VM status
def status(vm_name)
lima_cmd = [@limactl, 'list', '--format', '{{ .Status }}', vm_name]
stdout_str, stderr_str, status = Open3.capture3(*lima_cmd)
unless status.success?
raise LimaError, "`#{lima_cmd.join(' ')}` failed with status #{status.exitstatus}: #{stderr_str}"
end
stdout_str, _stderr_str, _status = Open3.capture3(*lima_cmd)

stdout_str.chomp
end
Expand Down

0 comments on commit fbf00e6

Please sign in to comment.