Skip to content

JB gateway plugin #7362

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

Merged
merged 6 commits into from
Jan 27, 2022
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
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ tasks:
init: |
leeway exec --package components/supervisor-api/java:lib --package components/gitpod-protocol/java:lib -- ./gradlew build
leeway exec --package components/ide/jetbrains/backend-plugin:plugin -- ./gradlew buildPlugin
leeway exec --package components/ide/jetbrains/gateway-plugin:plugin -- ./gradlew buildPlugin
- name: TypeScript
before: scripts/branch-namespace.sh
init: yarn --network-timeout 100000 && yarn build
Expand Down
4 changes: 3 additions & 1 deletion .werft/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export async function build(context, version) {
const storage = buildConfig["storage"] || "";
const withIntegrationTests = "with-integration-tests" in buildConfig;
const publishToNpm = "publish-to-npm" in buildConfig || mainBuild;
const publishToJBMarketplace = "publish-to-jb-marketplace" in buildConfig || mainBuild;
const analytics = buildConfig["analytics"];
const localAppVersion = mainBuild || ("with-localapp-version" in buildConfig) ? version : "unknown";
const retag = ("with-retag" in buildConfig) ? "" : "--dont-retag";
Expand All @@ -171,6 +172,7 @@ export async function build(context, version) {
storage: storage,
withIntegrationTests,
publishToNpm,
publishToJBMarketplace,
analytics,
localAppVersion,
retag,
Expand Down Expand Up @@ -205,7 +207,7 @@ export async function build(context, version) {
if (withContrib || publishRelease) {
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} -Dversion=${version} -DimageRepoBase=${imageRepo} contrib:all`);
}
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DSEGMENT_IO_TOKEN=${process.env.SEGMENT_IO_TOKEN} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'}`);
exec(`leeway build --docker-build-options network=host --werft=true -c remote ${dontTest ? '--dont-test' : ''} ${retag} --coverage-output-path=${coverageOutput} -Dversion=${version} -DremoveSources=false -DimageRepoBase=${imageRepo} -DlocalAppVersion=${localAppVersion} -DSEGMENT_IO_TOKEN=${process.env.SEGMENT_IO_TOKEN} -DnpmPublishTrigger=${publishToNpm ? Date.now() : 'false'} -DjbMarketplacePublishTrigger=${publishToJBMarketplace ? Date.now() : 'false'}`);
if (publishRelease) {
try {
werft.phase("publish", "checking version semver compliance...");
Expand Down
5 changes: 5 additions & 0 deletions .werft/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ pod:
secretKeyRef:
name: npm-auth-token
key: npm-auth-token.json
- name: JB_MARKETPLACE_PUBLISH_TOKEN
valueFrom:
secretKeyRef:
name: jb-marketplace-publish-token
key: token
- name: SLACK_NOTIFICATION_PATH
valueFrom:
secretKeyRef:
Expand Down
5 changes: 5 additions & 0 deletions .werft/debug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ pod:
secretKeyRef:
name: npm-auth-token
key: npm-auth-token.json
- name: JB_MARKETPLACE_PUBLISH_TOKEN
valueFrom:
secretKeyRef:
name: jb_marketplace_publish_token
key: token
- name: SLACK_NOTIFICATION_PATH
valueFrom:
secretKeyRef:
Expand Down
2 changes: 2 additions & 0 deletions WORKSPACE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defaultArgs:
coreYarnLockBase: ../..
npmPublishTrigger: "false"
publishToNPM: true
jbMarketplacePublishTrigger: "false"
publishToJBMarketplace: true
localAppVersion: unknown
codeCommit: 40c9a1fb052740734bf465b98032f1a50404c042
intellijDownloadUrl: "https://download.jetbrains.com/idea/ideaIU-2021.3.1.tar.gz"
Expand Down
6 changes: 1 addition & 5 deletions chart/templates/server-ide-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,24 @@ options:
title: "IntelliJ IDEA"
type: "desktop"
logo: "https://ide.{{ $.Values.hostname }}/image/ide-logo/intellijIdeaLogo.svg"
notes: ["While in beta, when you open a workspace with IntelliJ IDEA you will need to use the password “gitpod”."]
image: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.intellij)) }}
goland:
orderKey: "05"
title: "GoLand"
type: "desktop"
logo: "https://ide.{{ $.Values.hostname }}/image/ide-logo/golandLogo.svg"
notes: ["While in beta, when you open a workspace with GoLand you will need to use the password “gitpod”."]
image: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.goland)) }}
pycharm:
orderKey: "06"
title: "PyCharm"
type: "desktop"
logo: "https://ide.{{ $.Values.hostname }}/image/ide-logo/pycharmLogo.svg"
notes: ["While in beta, when you open a workspace with PyCharm you will need to use the password “gitpod”."]
image: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.pycharm)) }}
phpstorm:
orderKey: "07"
title: "PhpStorm"
type: "desktop"
logo: "https://ide.{{ $.Values.hostname }}/image/ide-logo/phpstormLogo.svg"
notes: ["While in beta, when you open a workspace with PhpStorm you will need to use the password “gitpod”."]
image: {{ (include "gitpod.comp.imageFull" (dict "root" $ "gp" $gp "comp" $gp.components.workspace.desktopIdeImages.phpstorm)) }}

defaultIde: "code"
Expand All @@ -122,7 +118,7 @@ clients:
defaultDesktopIDE: "intellij"
desktopIDEs: ["intellij", "goland", "pycharm", "phpstorm"]
installationSteps: [
"If you don't see an open dialog by the browser, make sure you have <a target='_blank' class='gp-link' href='https://www.jetbrains.com/remote-development/gateway'>JetBrains Gateway</a> with <a target='_blank' class='gp-link' href='https://plugins.jetbrains.com/plugin/download?rel=true&updateId=154074'>Gitpod Plugin</a> installed on your machine, and then click <b>${OPEN_LINK_LABEL}</b> below.",
"If you don't see an open dialog by the browser, make sure you have <a target='_blank' class='gp-link' href='https://www.jetbrains.com/remote-development/gateway'>JetBrains Gateway</a> with <a target='_blank' class='gp-link' href='https://github.com/gitpod-io/gitpod/blob/main/components/ide/jetbrains/gateway-plugin/doc/installing.md'>Gitpod Plugin</a> installed on your machine, and then click <b>${OPEN_LINK_LABEL}</b> below.",
]
{{ end }}

Expand Down
1 change: 1 addition & 0 deletions components/BUILD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ packages:
- components/local-app-api/typescript-grpcweb:publish
- components/supervisor-api/typescript-grpc:publish
- components/supervisor-api/typescript-grpcweb:publish
- components/ide/jetbrains/gateway-plugin:publish
- name: all-apps
type: generic
deps:
Expand Down
6 changes: 5 additions & 1 deletion components/gitpod-protocol/java/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
implementation group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j.jsonrpc', version: '0.12.0'
implementation group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j.websocket', version: '0.12.0'
compileOnly group: 'javax.websocket', name: 'javax.websocket-api', version: '1.1'
implementation group: 'org.glassfish.tyrus.bundles', name: 'tyrus-standalone-client', version: '1.18'
implementation("org.eclipse.jetty.websocket:javax-websocket-client-impl:9.4.44.v20210927")
}

application {
Expand All @@ -27,6 +27,10 @@ java {
withJavadocJar()
}

compileJava {
sourceCompatibility = "11"
targetCompatibility = "11"
}

publishing {
publications {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package io.gitpod.gitpodprotocol.api;

import org.eclipse.lsp4j.jsonrpc.JsonRpcException;
import org.eclipse.lsp4j.jsonrpc.MessageConsumer;
import org.eclipse.lsp4j.jsonrpc.MessageIssueException;
import org.eclipse.lsp4j.jsonrpc.json.MessageJsonHandler;
import org.eclipse.lsp4j.jsonrpc.messages.Message;

import javax.websocket.Session;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BufferingWebSocketMessageWriter implements MessageConsumer {

private static final Logger LOG = Logger.getLogger(BufferingWebSocketMessageWriter.class.getName());

private Session session;

private final MessageJsonHandler jsonHandler;
private List<String> buffer = new ArrayList<>();

public BufferingWebSocketMessageWriter(MessageJsonHandler jsonHandler) {
this.jsonHandler = jsonHandler;
}

public synchronized void setSession(Session session) {
this.session = session;
if (this.buffer.isEmpty()) {
return;
}
List<String> buffer = this.buffer;
this.buffer = new ArrayList<>();
for (String msg : buffer) {
this.send(msg);
}
}

@Override
public synchronized void consume(Message message) throws MessageIssueException, JsonRpcException {
this.send(jsonHandler.serialize(message));
}

private void send(String msg) {
if (this.session == null || !this.session.isOpen()) {
this.buffer.add(msg);
return;
}
try {
int length = msg.length();
if (length <= session.getMaxTextMessageBufferSize()) {
session.getBasicRemote().sendText(msg);
} else {
int currentOffset = 0;
while (currentOffset < length) {
int currentEnd = Math.min(currentOffset + session.getMaxTextMessageBufferSize(), length);
session.getBasicRemote().sendText(msg.substring(currentOffset, currentEnd), currentEnd == length);
currentOffset = currentEnd;
}
}
} catch (IOException e) {
LOG.log(Level.WARNING, "failed to send message", e);
this.buffer.add(msg);
}
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@

package io.gitpod.gitpodprotocol.api;

public interface GitpodClient {
void connect(GitpodServer server);
import io.gitpod.gitpodprotocol.api.entities.WorkspaceInstance;
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification;

GitpodServer server();
public class GitpodClient {

private GitpodServer server;

public void connect(GitpodServer server) {
this.server = server;
}

public GitpodServer getServer() {
if (this.server == null) {
throw new IllegalStateException("not connected");
}
return this.server;
}

public void notifyConnect() {
}

@JsonNotification
public void onInstanceUpdate(WorkspaceInstance instance) {

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,31 @@

package io.gitpod.gitpodprotocol.api;

import java.util.concurrent.CompletableFuture;

import io.gitpod.gitpodprotocol.api.entities.*;
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest;

import io.gitpod.gitpodprotocol.api.entities.SendHeartBeatOptions;
import io.gitpod.gitpodprotocol.api.entities.User;
import java.util.List;
import java.util.concurrent.CompletableFuture;

public interface GitpodServer {
@JsonRequest
CompletableFuture<User> getLoggedInUser();

@JsonRequest
CompletableFuture<Void> sendHeartBeat(SendHeartBeatOptions options);

@JsonRequest
CompletableFuture<List<String>> getGitpodTokenScopes(String tokenHash);

@JsonRequest
CompletableFuture<WorkspaceInfo> getWorkspace(String workspaceId);

@JsonRequest
CompletableFuture<String> getOwnerToken(String workspaceId);

@JsonRequest
CompletableFuture<List<WorkspaceInfo>> getWorkspaces(GetWorkspacesOptions options);

@JsonRequest
CompletableFuture<IDEOptions> getIDEOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
// Licensed under the GNU Affero General Public License (AGPL).
// See License-AGPL.txt in the project root for license information.

package io.gitpod.gitpodprotocol.api;

import javax.websocket.CloseReason;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.Future;

public interface GitpodServerConnection extends Future<CloseReason>, CompletionStage<CloseReason> {
}
Loading