Skip to content

Commit

Permalink
Add user ID a query
Browse files Browse the repository at this point in the history
Tool: gitpod/catfood.gitpod.cloud
  • Loading branch information
mustard-mh committed Jan 24, 2025
1 parent 95e8259 commit 81338c2
Showing 5 changed files with 72 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/ide/jetbrains/launcher/main.go
Original file line number Diff line number Diff line change
@@ -415,7 +415,7 @@ func resolveToolboxLink(wsInfo *supervisor.WorkspaceInfoResponse) (string, error
Scheme: "jetbrains",
Host: "gateway",
Path: "io.gitpod.toolbox.gateway/open-in-toolbox",
RawQuery: fmt.Sprintf("host=%s&workspaceId=%s&debugWorkspace=%t", gitpodUrl.Hostname(), wsInfo.WorkspaceId, debugWorkspace),
RawQuery: fmt.Sprintf("userId=%shost=%s&workspaceId=%s&debugWorkspace=%t", wsInfo.OwnerId, gitpodUrl.Hostname(), wsInfo.WorkspaceId, debugWorkspace),
}
return link.String(), nil
}
15 changes: 13 additions & 2 deletions components/ide/jetbrains/toolbox/README.md
Original file line number Diff line number Diff line change
@@ -6,8 +6,19 @@ Provides a way to connect to Gitpod Classic workspaces within the JetBrains Tool

- Start an environment on [Gitpod Flex](https://app.gitpod.io) with current repository
- Connect to the environment via **JetBrains Gateway** (because we want to restart Toolbox) SSH feature (user: gitpod_devcontainer)
- [optional] Copy ./flex-sync.sh locally and chmod +x, the script is written for macOS, please adjust it if you're using other OS
- Exec `./flex-sync.sh <env_host>`
- [optional] Copy ./sync-flex.sh locally and chmod +x, the script is written for macOS, please adjust it if you're using other OS
- Exec `./sync-flex.sh <env_host>`
- Exec gradle task `./gradlew buildPluginFlex`, it will deploy plugin changes and restart Toolbox automatically.

## How to Develoop with Gitpod Classic

- [optional] Set your SSH Keys up https://catfood.gitpod.cloud/user/keys
- Open a workspace on Gitpod Classic with current repository
- Update default Java version to Java 21: `sdk install java 21.0.3.fx-zulu`
- [optional] Connect to the environment via **JetBrains Gateway** (if you want to keep the editor opening when deploy Toolbox Plugin)
- [optional] Copy ./sync-classic.sh locally and chmod +x, update the script base on your Gitpod host
- Exec `./sync-classic.sh <workspace_id>`
- Exec gradle task `./gradlew buildPluginFlex`, it will deploy plugin changes and restart Toolbox automatically.

## How to Develop locally

51 changes: 51 additions & 0 deletions components/ide/jetbrains/toolbox/sync-classic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
# shellcheck disable=all
#
# Sync the local Toolbox plugins folder from the build results of Gitpod Flex (`build/flex/*`) automatically
# so that you could build with a remote environment

if [ $# -eq 0 ]; then
echo "Usage: $0 <workspace_id>"
echo "Example: $0 gitpodio-gitpod-5ndiqumln3b"
exit 1
fi

GITPOD_HOST="gitpod.io"
WORKSPACE_ID="$1"
REMOTE_HOST="$WORKSPACE_ID.ssh.ws.$GITPOD_HOST"
PLUGIN_ID="io.gitpod.toolbox.gateway"
LOCAL_DIR="$HOME/Library/Caches/JetBrains/Toolbox/plugins/$PLUGIN_ID"
REMOTE_DIR="/workspace/gitpod/components/ide/jetbrains/toolbox/build/flex/$PLUGIN_ID"
DEVCONTAINER_HOST="$WORKSPACE_ID@$REMOTE_HOST"

echo "Preparing..."

ssh $DEVCONTAINER_HOST "sudo apt-get update && sudo apt-get install -y rsync inotify-tools" > /dev/null

function sync_and_restart() {
rsync -avz --delete "$DEVCONTAINER_HOST:$REMOTE_DIR/" "$LOCAL_DIR/"
cat << 'EOF'
===============================
# access toolbox.log:
echo debugClean > $HOME/Library/Logs/JetBrains/Toolbox/toolbox.log
code $HOME/Library/Logs/JetBrains/Toolbox/toolbox.log
# restart Toolbox:
pkill -f 'JetBrains Toolbox' || true && open /Applications/JetBrains\ Toolbox.app
EOF
}

echo "Initing..."

sync_and_restart

echo "Watching for changes in $DEVCONTAINER_HOST:$REMOTE_DIR"

ssh $DEVCONTAINER_HOST "inotifywait -m -r -e modify,create,delete,move $REMOTE_DIR" | \
while read path action file; do
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Change detected: $action $file"
# Make sure remote is build
sleep 3
sync_and_restart
done
Original file line number Diff line number Diff line change
@@ -10,9 +10,10 @@ if [ $# -eq 0 ]; then
exit 1
fi

PLUGIN_ID="io.gitpod.toolbox.gateway"
REMOTE_HOST="$1"
LOCAL_DIR="$HOME/Library/Caches/JetBrains/Toolbox/plugins"
REMOTE_DIR="/workspace/gitpod/components/ide/jetbrains/toolbox/build/flex"
LOCAL_DIR="$HOME/Library/Caches/JetBrains/Toolbox/plugins/$PLUGIN_ID"
REMOTE_DIR="/workspace/gitpod/components/ide/jetbrains/toolbox/build/flex/$PLUGIN_ID"
DEVCONTAINER_HOST="gitpod_devcontainer@$REMOTE_HOST"

echo "Preparing..."

0 comments on commit 81338c2

Please sign in to comment.