Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scripts/install-k8s.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,10 @@ $envBlock
Log "Helm Output: $helmOutput"
if ($LASTEXITCODE -ne 0) { Err "Client installation failed. Helm output:`n$helmOutput`nCheck the log for details: $LOG_FILE" }

# Point kubeconfig's current context at the client namespace so kubectl + the
# tracebloc CLI default to it (no -n / --namespace needed). Best-effort.
kubectl config set-context --current --namespace $TB_NAMESPACE 2>$null | Out-Null

Ok "Connected to tracebloc"
Log "Values file: $valuesFile"
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/lib/install-client-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ EOF
cat "$helm_log" >> "${LOG_FILE:-/dev/null}" 2>/dev/null
rm -f "$helm_log"

# Point the kubeconfig's current context at the client namespace, so kubectl and
# the tracebloc CLI default to it with no -n / --namespace flag. Best-effort:
# a failure here must not abort an otherwise-successful install.
kubectl config set-context --current --namespace "$TB_NAMESPACE" >/dev/null 2>&1 || true

success "Connected to tracebloc"
log "Values file: $values_file"
}
13 changes: 13 additions & 0 deletions scripts/tests/install-client-helm.bats
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,19 @@ setup() {
mock_calls | grep -q "helm upgrade --install tracebloc"
}

@test "install_client_helm: points kubeconfig at the client namespace (so the CLI needs no -n)" {
HOST_DATA_DIR="$BATS_TEST_TMPDIR/data"; mkdir -p "$HOST_DATA_DIR"
_ensure_tracebloc_dirs() { :; }
_ensure_release_dirs() { :; }
_ensure_helm_runnable() { :; }
helm() { return 0; }
kubectl() { record "kubectl $*"; return 0; }
verify_credentials() { printf valid; }
run install_client_helm <<< $'myid\nmypw'
[ "$status" -eq 0 ]
mock_calls | grep -q "kubectl config set-context --current --namespace tracebloc"
}

@test "install_client_helm: re-prompts on invalid, then accepts valid" {
HOST_DATA_DIR="$BATS_TEST_TMPDIR/data"; mkdir -p "$HOST_DATA_DIR"
_ensure_tracebloc_dirs() { :; }
Expand Down
Loading