Skip to content

Commit fd85b13

Browse files
authored
Merge pull request #42 from replicatedhq/dx/wg-easy
feat(wg-easy): add list cluster and Verify kubeconfig for taskfile
2 parents 82eac92 + 50d9e5d commit fd85b13

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

applications/wg-easy/Taskfile.yaml

+37-6
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ tasks:
5656
vars:
5757
TIMEOUT: "{{.TIMEOUT}}"
5858

59+
list-cluster:
60+
desc: List the cluster
61+
silent: false
62+
cmds:
63+
- |
64+
CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
65+
EXPIRES=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .expires_at')
66+
echo "{{.CLUSTER_NAME}} Cluster ID: ($CLUSTER_ID) Expires: ($EXPIRES)"
67+
5968
test:
6069
desc: Run a basic test suite
6170
silent: false
@@ -65,6 +74,25 @@ tasks:
6574
- sleep 5
6675
- echo "Tests completed!"
6776

77+
78+
verify-kubeconfig:
79+
desc: Verify kubeconfig
80+
silent: false
81+
run: once
82+
cmds:
83+
- |
84+
if [ -f {{.KUBECONFIG_FILE}} ]; then
85+
echo "Getting Cluster ID From Replicated Cluster list"
86+
CLUSTER_ID=$(replicated cluster ls --output json | jq -r '.[] | select(.name == "{{.CLUSTER_NAME}}") | .id')
87+
echo "Getting Cluster ID From Kubeconfig"
88+
CLUSTER_ID_KUBECONFIG=$(grep "current-context:" {{.KUBECONFIG_FILE}} | cut -d'-' -f3)
89+
if [ "$CLUSTER_ID" != "$CLUSTER_ID_KUBECONFIG" ]; then
90+
echo "{{.CLUSTER_NAME}} Cluster ID between Replicated ($CLUSTER_ID) and Kubeconfig ($CLUSTER_ID_KUBECONFIG) mismatch"
91+
echo "Removing old kubeconfig file"
92+
rm -f {{.KUBECONFIG_FILE}}
93+
fi
94+
fi
95+
6896
setup-kubeconfig:
6997
desc: Get kubeconfig and prepare cluster for application deployment
7098
silent: false
@@ -84,7 +112,8 @@ tasks:
84112
true
85113
fi
86114
deps:
87-
- cluster-create
115+
- create-cluster
116+
- verify-kubeconfig
88117

89118
dependencies-update:
90119
desc: Update Helm dependencies for all charts
@@ -240,21 +269,23 @@ tasks:
240269
done
241270
242271
- echo "Release files prepared in ./release/ directory"
243-
272+
deps:
273+
- update-version
274+
275+
244276
release-create:
245277
desc: Create and promote a release using the Replicated CLI
246278
silent: false
247279
vars:
248280
CHANNEL: '{{.CHANNEL | default "Unstable"}}'
249281
RELEASE_NOTES: '{{.RELEASE_NOTES | default "Release created via task release-create"}}'
250282
cmds:
251-
- echo "Creating and promoting release for {{.APP_NAME}} to channel {{.CHANNEL}}..."
283+
- echo "Creating and promoting release for $APP_NAME to channel $CHANNEL..."
252284
- |
253285
# Create and promote the release in one step
254286
echo "Creating release from files in ./release directory..."
255-
replicated release create --app {{.APP_NAME}} --yaml-dir ./release --release-notes "{{.RELEASE_NOTES}}" --promote {{.CHANNEL}}
256-
257-
echo "Release created and promoted to channel {{.CHANNEL}}"
287+
replicated release create --app $APP_NAME --yaml-dir ./release --release-notes "$RELEASE_NOTES" --promote $CHANNEL --version $VERSION
288+
echo "Release version $VERSION created and promoted to channel $CHANNEL"
258289
deps:
259290
- release-prepare
260291

applications/wg-easy/docs/task-reference.md

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ These tasks help manage the development and testing environments.
3434
|------|-------------|------------------------|
3535
| `cluster-create` | Creates a test Kubernetes cluster using Replicated's Compatibility Matrix | Stage 4: Single Chart Install |
3636
| `setup-kubeconfig` | Retrieves and sets up the kubeconfig for the test cluster | Stage 4: Single Chart Install |
37+
| `delete-cluster` | Deletes the test cluster and cleans up resources | Stage 4-5: Cleanup |
38+
| `create-gcp-vm` | Creates a GCP VM instance for embedded cluster testing | Stage 7: Embedded Testing |
39+
| `delete-gcp-vm` | Deletes the GCP VM instance after testing | Stage 7: Cleanup |
40+
| `setup-embedded-cluster` | Sets up a Replicated embedded cluster on the GCP VM | Stage 7: Embedded Testing |
41+
| `list-cluster` | List the test cluster with the cluster id, name, and expiration date | Stage 4: Single Chart Install |
42+
| `verify-kubeconfig` | Verifies the kubeconfig for the test cluster and removes the cluster if it is expired | Stage 4: Single Chart Install |
3743
| `cluster-delete` | Deletes the test cluster and cleans up resources | Stage 4-5: Cleanup |
3844
| `gcp-vm-create` | Creates a GCP VM instance for embedded cluster testing | Stage 7: Embedded Testing |
3945
| `gcp-vm-delete` | Deletes the GCP VM instance after testing | Stage 7: Cleanup |

0 commit comments

Comments
 (0)