Skip to content

Commit 4e7a3e7

Browse files
authored
Merge pull request #647 from vprashar2929/chore-helm-val
chore: update script to validate helm
2 parents bcec911 + 21d9511 commit 4e7a3e7

File tree

2 files changed

+23
-26
lines changed

2 files changed

+23
-26
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ helm-sync-crds: ## Sync CRDs from config/crd/bases to Helm chart
336336
@echo "✅ CRDs synced to Helm chart"
337337

338338
.PHONY: helm-validate
339-
helm-validate: kustomize helm yq ## Validate Helm chart (syntax, templates, CRD sync, resources)
339+
helm-validate: ## Validate Helm chart (syntax, templates, CRD sync, resources)
340340
@echo "Validating Helm chart against kustomize..."
341341
./hack/helm/validate.sh
342342

hack/helm/validate.sh

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,22 @@
1515

1616
set -euo pipefail
1717

18-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19-
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
20-
HELM_CHART_DIR="$PROJECT_ROOT/manifests/helm/kepler-operator"
21-
CRD_SOURCE_DIR="$PROJECT_ROOT/config/crd/bases"
22-
CRD_DEST_DIR="$HELM_CHART_DIR/crds"
18+
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
19+
declare -r PROJECT_ROOT
20+
declare -r TMP_DIR="$PROJECT_ROOT/tmp"
21+
declare -r BIN_DIR="$TMP_DIR/bin"
22+
23+
declare -r HELM_CHART_DIR="$PROJECT_ROOT/manifests/helm/kepler-operator"
24+
declare -r CRD_SOURCE_DIR="$PROJECT_ROOT/config/crd/bases"
25+
declare -r CRD_DEST_DIR="$HELM_CHART_DIR/crds"
2326

2427
# Image versions for validation
25-
OPERATOR_IMAGE="${OPERATOR_IMAGE:-quay.io/sustainable_computing_io/kepler-operator:0.21.0}"
26-
KEPLER_IMAGE="${KEPLER_IMAGE:-quay.io/sustainable_computing_io/kepler:latest}"
27-
KUBE_RBAC_PROXY_IMAGE="${KUBE_RBAC_PROXY_IMAGE:-quay.io/brancz/kube-rbac-proxy:v0.18.1}"
28+
declare OPERATOR_IMAGE="${OPERATOR_IMAGE:-quay.io/sustainable_computing_io/kepler-operator:0.21.0}"
29+
declare KEPLER_IMAGE="${KEPLER_IMAGE:-quay.io/sustainable_computing_io/kepler:latest}"
30+
declare KUBE_RBAC_PROXY_IMAGE="${KUBE_RBAC_PROXY_IMAGE:-quay.io/brancz/kube-rbac-proxy:v0.18.1}"
2831

2932
# shellcheck source=hack/utils.bash
30-
source "$SCRIPT_DIR/../utils.bash"
31-
32-
# Validate that required tools are available
33-
check_tools() {
34-
local bin_dir="$PROJECT_ROOT/tmp/bin"
35-
local tools=("helm" "kustomize" "yq")
36-
for tool in "${tools[@]}"; do
37-
if [[ ! -x "$bin_dir/$tool" ]]; then
38-
fail "$tool is not installed. Please run 'make $tool' to install it."
39-
return 1
40-
fi
41-
done
42-
}
43-
44-
# Use project-local tools
45-
export PATH="$PROJECT_ROOT/tmp/bin:$PATH"
33+
source "$PROJECT_ROOT/hack/utils.bash"
4634

4735
# Render Helm templates with standard test values
4836
render_helm_template() {
@@ -81,6 +69,11 @@ validate_helm_template() {
8169
return 0
8270
}
8371

72+
ensure_all_tools() {
73+
info "Ensuring tools are installed"
74+
"$PROJECT_ROOT/hack/tools.sh" helm
75+
}
76+
8477
# Validate CRD sync status
8578
validate_crd_sync() {
8679
info "Validating CRD sync status..."
@@ -146,7 +139,11 @@ validate_resources() {
146139
main() {
147140
info "Starting Helm chart validation..."
148141

149-
check_tools
142+
cd "$PROJECT_ROOT"
143+
export PATH="$BIN_DIR:$PATH"
144+
mkdir -p "${TMP_DIR}"
145+
ensure_all_tools
146+
150147
validate_helm_syntax
151148
validate_helm_template
152149
validate_crd_sync

0 commit comments

Comments
 (0)