mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
This relaxes the branch name restriction from 20 characters to 45. This is achieved by constructing the preview name based on the first 10 characters of the branch name and then the first 10 characters of the hashed value of the branch name. All places that (to my knowledge) rely on the preview name has been updated. Fixes https://github.com/gitpod-io/ops/issues/1252
33 lines
766 B
Bash
Executable File
33 lines
766 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
source ./dev/preview/util/preview-name-from-branch.sh
|
|
|
|
VM_NAME="$(preview-name-from-branch)"
|
|
NAMESPACE="preview-${VM_NAME}"
|
|
|
|
while getopts n:p: flag
|
|
do
|
|
case "${flag}" in
|
|
n) NAMESPACE="${OPTARG}";;
|
|
p) PORT="${OPTARG}";;
|
|
*) ;;
|
|
esac
|
|
done
|
|
|
|
pkill -f "kubectl --context=harvester (.*)${PORT}:2200"
|
|
kubectl \
|
|
--context=harvester \
|
|
--kubeconfig=/home/gitpod/.kube/config \
|
|
-n "${NAMESPACE}" port-forward service/proxy "${PORT}:2200" > /dev/null 2>&1 &
|
|
|
|
# Wait for the port to be read
|
|
while true; do
|
|
sleep 1
|
|
if [[ "$(netcat -z localhost 8022)" -eq 0 ]]; then
|
|
break
|
|
fi
|
|
done
|
|
|
|
# Use netcat as SSH expects ProxyCommand to read and write using stdin/stdout
|
|
netcat -X connect localhost "${PORT}"
|