@@ -6,7 +6,13 @@ includes:
6
6
7
7
vars :
8
8
# Application configuration
9
- APP_SLUG : ' {{.REPLICATED_APP | default "wg-easy"}}'
9
+ APP_NAME : ' {{.REPLICATED_APP | default "wg-easy"}}'
10
+ APP_SLUG : ' {{.REPLICATED_APP_SLUG | default "wg-easy-cre"}}'
11
+
12
+ # Release configuration
13
+ RELEASE_CHANNELd : ' {{.RELEASE_CHANNEL | default "Unstable"}}'
14
+ RELEASE_VERSION : ' {{.RELEASE_VERSION | default "0.0.1"}}'
15
+ RELEASE_NOTES : ' {{.RELEASE_NOTES | default "Release created via task release-create"}}'
10
16
11
17
# Cluster configuration
12
18
CLUSTER_NAME : ' {{.CLUSTER_NAME | default "test-cluster"}}'
@@ -137,8 +143,8 @@ tasks:
137
143
done
138
144
- echo "All dependencies updated!"
139
145
140
- ports-expose :
141
- desc : Expose configured ports and capture exposed URLs
146
+ cluster- ports-expose :
147
+ desc : Expose configured ports for a cluster and capture exposed URLs
142
148
silent : false
143
149
run : once
144
150
status :
@@ -166,8 +172,8 @@ tasks:
166
172
deps :
167
173
- cluster-create
168
174
169
- helm-deploy :
170
- desc : Deploy all charts using helmfile
175
+ helm-install :
176
+ desc : Install all charts using helmfile
171
177
silent : false
172
178
cmds :
173
179
- echo "Installing all charts via helmfile"
@@ -185,10 +191,10 @@ tasks:
185
191
# Deploy with helmfile
186
192
echo "Using $ENV_VARS"
187
193
eval "KUBECONFIG={{.KUBECONFIG_FILE}} $ENV_VARS helmfile sync --wait"
188
- - echo "All charts deployed !"
194
+ - echo "All charts installed !"
189
195
deps :
190
196
- setup-kubeconfig
191
- - ports-expose
197
+ - cluster- ports-expose
192
198
193
199
cluster-delete :
194
200
desc : Delete all test clusters with matching name and clean up kubeconfig
@@ -300,6 +306,53 @@ tasks:
300
306
deps :
301
307
- release-prepare
302
308
309
+ customer-create :
310
+ desc : Create a new customer or get existing customer with matching name and return their ID
311
+ silent : false
312
+ run : once
313
+ vars :
314
+ CUSTOMER_NAME : ' {{.CUSTOMER_NAME | default "test-customer"}}'
315
+ CUSTOMER_EMAIL : ' {{.CUSTOMER_EMAIL | default "test@example.com"}}'
316
+ CHANNEL : ' {{.CHANNEL | default "Unstable"}}'
317
+ LICENSE_TYPE : ' {{.LICENSE_TYPE | default "dev"}}'
318
+ EXPIRES_IN : ' {{.EXPIRES_IN | default ""}}'
319
+ requires :
320
+ vars : [APP_SLUG]
321
+ cmds :
322
+ - |
323
+ # First check if customer already exists
324
+ echo "Looking for existing customer {{.CUSTOMER_NAME}} for app {{.APP_SLUG}}..."
325
+ EXISTING_CUSTOMER=$(replicated customer ls --app {{.APP_SLUG}} --output json | jq -r '.[] | select(.name=="{{.CUSTOMER_NAME}}") | .id' | head -1)
326
+
327
+ if [ -n "$EXISTING_CUSTOMER" ]; then
328
+ echo "Found existing customer {{.CUSTOMER_NAME}} with ID: $EXISTING_CUSTOMER"
329
+ echo "$EXISTING_CUSTOMER"
330
+ exit 0
331
+ fi
332
+
333
+ # No existing customer found, create a new one
334
+ echo "Creating new customer {{.CUSTOMER_NAME}} for app {{.APP_SLUG}}..."
335
+
336
+ # Build the command with optional expiration
337
+ CMD="replicated customer create \
338
+ --app {{.APP_SLUG}} \
339
+ --name {{.CUSTOMER_NAME}} \
340
+ --email {{.CUSTOMER_EMAIL}} \
341
+ --channel {{.CHANNEL}} \
342
+ --type {{.LICENSE_TYPE}} \
343
+ --output json"
344
+
345
+ # Add expiration if specified
346
+ if [ -n "{{.EXPIRES_IN}}" ]; then
347
+ CMD="$CMD --expires-in {{.EXPIRES_IN}}"
348
+ fi
349
+
350
+ # Create the customer and capture the output
351
+ CUSTOMER_JSON=$($CMD)
352
+
353
+ # Extract and output just the customer ID
354
+ echo "$CUSTOMER_JSON" | jq -r '.id'
355
+
303
356
gcp-vm-create :
304
357
desc : Create a simple GCP VM instance
305
358
silent : false
@@ -357,14 +410,51 @@ tasks:
357
410
GCP_ZONE : ' {{.GCP_ZONE}}'
358
411
VM_NAME : ' {{.VM_NAME}}'
359
412
413
+ customer-ls :
414
+ desc : List customers for the application
415
+ silent : false
416
+ vars :
417
+ OUTPUT_FORMAT : ' {{.OUTPUT_FORMAT | default "table"}}'
418
+ requires :
419
+ vars : [APP_SLUG]
420
+ cmds :
421
+ - echo "Listing customers for app {{.APP_SLUG}}..."
422
+ - replicated customer ls --app {{.APP_SLUG}} --output {{.OUTPUT_FORMAT}}
423
+
424
+ customer-delete :
425
+ desc : Archive a customer by ID
426
+ silent : false
427
+ vars :
428
+ CUSTOMER_ID : ' {{.CUSTOMER_ID}}'
429
+ requires :
430
+ vars : [APP_SLUG, CUSTOMER_ID]
431
+ cmds :
432
+ - echo "Archiving customer with ID {{.CUSTOMER_ID}} from app {{.APP_SLUG}}..."
433
+ - |
434
+ # Verify customer exists before attempting to archive
435
+ CUSTOMER_EXISTS=$(replicated customer ls --app {{.APP_SLUG}} --output json | jq -r '.[] | select(.id=="{{.CUSTOMER_ID}}") | .id')
436
+ if [ -z "$CUSTOMER_EXISTS" ]; then
437
+ echo "Error: Customer with ID {{.CUSTOMER_ID}} not found for app {{.APP_SLUG}}"
438
+ exit 1
439
+ fi
440
+
441
+ # Get customer name for confirmation message
442
+ CUSTOMER_NAME=$(replicated customer ls --app {{.APP_SLUG}} --output json | jq -r '.[] | select(.id=="{{.CUSTOMER_ID}}") | .name')
443
+
444
+ # Archive the customer
445
+ replicated customer archive {{.CUSTOMER_ID}} --app {{.APP_SLUG}}
446
+
447
+ # Confirm archiving
448
+ echo "Customer '$CUSTOMER_NAME' (ID: {{.CUSTOMER_ID}}) successfully archived"
449
+
360
450
full-test-cycle :
361
451
desc : Create cluster, get kubeconfig, expose ports, update dependencies, deploy charts, test, and delete
362
452
silent : false
363
453
cmds :
364
454
- task : cluster-create
365
455
- task : setup-kubeconfig
366
- - task : ports-expose
456
+ - task : cluster- ports-expose
367
457
- task : dependencies-update
368
- - task : helm-deploy
458
+ - task : helm-install
369
459
- task : test
370
460
- task : cluster-delete
0 commit comments