Skip to content

Commit e9cd462

Browse files
committed
Enhance cluster creation task in Taskfile.yaml to check for existing clusters and output detailed information if found. This improves user feedback during the cluster setup process.
1 parent 8644e19 commit e9cd462

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

applications/wg-easy/Taskfile.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,18 @@ tasks:
5858
TIMEOUT: '{{if eq .EMBEDDED "true"}}420{{else}}300{{end}}'
5959
TTL: '{{.TTL | default "4h"}}'
6060
status:
61-
- replicated cluster ls --output json | jq -e '.[] | select(.name == "{{.CLUSTER_NAME}}")' > /dev/null
61+
- |
62+
# Check if cluster exists and output info if it does
63+
CLUSTER_INFO=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}")')
64+
if [ -n "$CLUSTER_INFO" ]; then
65+
echo "Found existing cluster {{.CLUSTER_NAME}}:"
66+
echo "$CLUSTER_INFO" | jq -r '" ID: " + .id + "\n Status: " + .status + "\n Distribution: " + .distribution + "\n Created: " + .created_at + "\n Expires: " + .expires_at'
67+
exit 0
68+
fi
69+
exit 1
6270
cmds:
6371
- |
72+
echo "Creating new cluster {{.CLUSTER_NAME}}..."
6473
if [ "{{.EMBEDDED}}" = "true" ]; then
6574
echo "Creating embedded cluster {{.CLUSTER_NAME}} with license ID {{.LICENSE_ID}}..."
6675
replicated cluster create --distribution embedded-cluster --name {{.CLUSTER_NAME}} --license-id {{.LICENSE_ID}} --ttl {{.TTL}}

0 commit comments

Comments
 (0)