Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: telepresence connect #19

Merged
merged 1 commit into from
Nov 7, 2023
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
2 changes: 1 addition & 1 deletion src/telepresence-install/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "telepresence-install",
"name": "Telepresence Install",
"version": "1.0.4",
"version": "2.0.0",
"description": "Install Telepresence to devcontainer",
"options": {
"version": {
Expand Down
24 changes: 10 additions & 14 deletions src/telepresence-install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ cat >/usr/local/bin/connect-telepresence \
set -e

# arguments that are:
# --domain (required)
# --project (defaults to "seed-209211" if not set)
# --cluster (defaults to "klang-seed-game-dev-game" if not set)
# --project (defaults to "klang-seed-game-dev" if not set)

# parse arguments
while [[ \$# -gt 0 ]]
do
key="\$1"
case \$key in
--domain)
DOMAIN="\$2"
--cluster)
CLUSTER="\$2"
shift
shift
;;
Expand All @@ -52,19 +52,15 @@ cat >/usr/local/bin/connect-telepresence \
done

# check arguments
if [ -z "\$DOMAIN" ]; then
echo "Missing argument: --domain"
exit 1
if [ -z "\$CLUSTER" ]; then
CLUSTER="klang-seed-game-dev-game"
fi

# set defaults
if [ -z "\$PROJECT" ]; then
PROJECT="seed-209211"
PROJECT="klang-seed-game-dev"
fi

# replace "." in domain with "-"
DOMAIN_DASHED=\$(echo "\$DOMAIN" | sed 's/\./-/g')

# auth gcloud first, requires some user input
echo "Authenticating gcloud..."
echo "You will be asked to authenticate with your Google account twice."
Expand All @@ -80,15 +76,15 @@ cat >/usr/local/bin/connect-telepresence \
fi

echo "Finding the zone of the cluster..."
ZONE=\$(gcloud container clusters list --format json --project \$PROJECT | jq -r ".[] | select(.name == \"\$DOMAIN_DASHED\") | .zone")
ZONE=\$(gcloud container clusters list --format json --project \$PROJECT | jq -r ".[] | select(.name == \"\$CLUSTER\") | .zone")
if [ -z "\$ZONE" ]; then
echo "Could not find the zone of the cluster. Please check if the cluster exists."
exit 1
fi

echo "Found zone for \$DOMAIN_DASHED: \$ZONE"
echo "Found zone for \$CLUSTER: \$ZONE"

gcloud container clusters get-credentials \$DOMAIN_DASHED --zone \$ZONE --project \$PROJECT --internal-ip
gcloud container clusters get-credentials \$CLUSTER --zone \$ZONE --project \$PROJECT --internal-ip

# test if we get a response from the cluster
echo "Testing if we can connect to the cluster..."
Expand Down