-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvalidate.sh
More file actions
executable file
·38 lines (31 loc) · 1.05 KB
/
validate.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Get the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Change to the script's directory
cd "$SCRIPT_DIR" || exit 1
echo "Testing Helm chart template rendering..."
RELEASE_NAME="test-$(date +%s)"
TEMP_DIR=$(mktemp -d)
echo "Writing templates to TEMP_DIR: $TEMP_DIR"
# Render the templates to a file
helm template "$RELEASE_NAME" "$SCRIPT_DIR/braintrust" \
--set global.namespace="$RELEASE_NAME" \
> "$TEMP_DIR/rendered.yaml"
echo "Creating namespace..."
kubectl create namespace "$RELEASE_NAME" --save-config
# shellcheck disable=SC2317
cleanup() {
if [ -n "$RELEASE_NAME" ]; then
echo "Cleaning up namespace..."
kubectl delete namespace "$RELEASE_NAME"
fi
}
trap cleanup EXIT
echo "Validating rendered templates..."
if kubectl apply --dry-run=server -f "$TEMP_DIR/rendered.yaml"; then
echo "✅ Chart templates rendered successfully and are valid Kubernetes resources"
exit 0
else
echo "❌ Chart template validation failed"
exit 1
fi