Skip to content

Commit 3561378

Browse files
authored
Merge pull request #1833 from afbjorklund/limactl-start
Prompt the user to also start the created instance
2 parents 8aa90db + f3e8aad commit 3561378

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

cmd/apptainer.lima

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ set -eu
66
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
77
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://apptainer\` to create a new instance" >&2
88
exit 1
9+
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
10+
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
11+
exit 1
912
fi
1013
export LIMA_INSTANCE
1114
if [ -n "$APPTAINER_BINDPATH" ]; then

cmd/docker.lima

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ set -eu
66
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
77
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://docker\` to create a new instance" >&2
88
exit 1
9+
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
10+
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
11+
exit 1
912
fi
1013
DOCKER=$(command -v "$DOCKER" || true)
1114
if [ -n "$DOCKER" ]; then

cmd/kubectl.lima

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,27 @@ set -eu
44
: "${KUBECTL:=kubectl}"
55

66
if [ -z "$LIMA_INSTANCE" ]; then
7-
if [ "$(limactl ls -f '{{.Status}}' k3s 2>/dev/null)" = "Running" ]; then
7+
if [ "$(limactl ls -q k3s 2>/dev/null)" = "k3s" ]; then
88
LIMA_INSTANCE=k3s
9-
elif [ "$(limactl ls -f '{{.Status}}' k8s 2>/dev/null)" = "Running" ]; then
9+
elif [ "$(limactl ls -q k8s 2>/dev/null)" = "k8s" ]; then
1010
LIMA_INSTANCE=k8s
1111
else
12-
echo "No k3s or k8s running instances found. Either create one with" >&2
12+
echo "No k3s or k8s existing instances found. Either create one with" >&2
1313
echo "limactl create --name=k3s template://k3s" >&2
1414
echo "limactl create --name=k8s template://k8s" >&2
1515
echo "or set LIMA_INSTANCE to the name of your Kubernetes instance" >&2
1616
exit 1
1717
fi
18+
if [ "$(limactl ls -f '{{.Status}}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
19+
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
20+
exit 1
21+
fi
1822
elif [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
1923
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE\` to create a new instance" >&2
2024
exit 1
25+
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
26+
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
27+
exit 1
2128
fi
2229
KUBECTL=$(command -v "$KUBECTL" || true)
2330
if [ -n "$KUBECTL" ]; then

cmd/podman.lima

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ set -eu
66
if [ "$(limactl ls -q "$LIMA_INSTANCE" 2>/dev/null)" != "$LIMA_INSTANCE" ]; then
77
echo "instance \"$LIMA_INSTANCE\" does not exist, run \`limactl create --name=$LIMA_INSTANCE template://podman\` to create a new instance" >&2
88
exit 1
9+
elif [ "$(limactl ls -f '{{ .Status }}' "$LIMA_INSTANCE" 2>/dev/null)" != "Running" ]; then
10+
echo "instance \"$LIMA_INSTANCE\" is not running, run \`limactl start $LIMA_INSTANCE\` to start the existing instance" >&2
11+
exit 1
912
fi
1013
PODMAN=$(command -v "$PODMAN" || true)
1114
if [ -n "$PODMAN" ]; then

0 commit comments

Comments
 (0)