Skip to content

Commit 3f65934

Browse files
committed
add a "clean" task
1 parent b9b5a91 commit 3f65934

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

applications/wg-easy/Taskfile.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,50 @@ tasks:
447447
# Confirm archiving
448448
echo "Customer '$CUSTOMER_NAME' (ID: {{.CUSTOMER_ID}}) successfully archived"
449449
450+
clean:
451+
desc: Remove temporary Helm directories, chart dependencies, and release folder
452+
silent: false
453+
cmds:
454+
- echo "Cleaning temporary directories and dependencies..."
455+
- |
456+
# Remove the release directory
457+
if [ -d "./release" ]; then
458+
echo "Removing release directory..."
459+
rm -rf ./release
460+
fi
461+
462+
# Find and remove tmpcharts-* directories
463+
echo "Removing temporary chart directories..."
464+
find . -type d -name "tmpcharts-*" -print
465+
find . -type d -name "tmpcharts-*" -exec rm -rf {} \; 2>/dev/null || true
466+
467+
# Find charts directories that only contain .tgz files (dependencies)
468+
echo "Removing chart dependency directories..."
469+
for charts_dir in $(find . -type d -name "charts"); do
470+
# Skip if the charts directory is in ./charts/ (which is our template charts directory)
471+
if [[ "$charts_dir" == "./charts" || "$charts_dir" == "./charts/"* ]]; then
472+
continue
473+
fi
474+
475+
# Check if the directory only contains .tgz files
476+
NON_TGZ_FILES=$(find "$charts_dir" -type f -not -name "*.tgz" | wc -l | tr -d ' ')
477+
TOTAL_FILES=$(find "$charts_dir" -type f | wc -l | tr -d ' ')
478+
479+
if [ "$TOTAL_FILES" -gt 0 ] && [ "$NON_TGZ_FILES" -eq 0 ]; then
480+
# Check if the directory contains any subdirectories
481+
SUBDIRS=$(find "$charts_dir" -mindepth 1 -type d | wc -l | tr -d ' ')
482+
483+
if [ "$SUBDIRS" -eq 0 ]; then
484+
echo "Removing entire chart dependency directory: $charts_dir"
485+
rm -rf "$charts_dir"
486+
else
487+
echo "Removing chart dependencies in $charts_dir (keeping subdirectories)"
488+
rm -f "$charts_dir"/*.tgz
489+
fi
490+
fi
491+
done
492+
- echo "Cleaning complete!"
493+
450494
full-test-cycle:
451495
desc: Create cluster, get kubeconfig, expose ports, update dependencies, deploy charts, test, and delete
452496
silent: false

0 commit comments

Comments
 (0)