Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Add ssh-plugin #31

Merged
merged 2 commits into from
Feb 26, 2019
Merged

Add ssh-plugin #31

merged 2 commits into from
Feb 26, 2019

Conversation

vparfonov
Copy link
Contributor

@vparfonov vparfonov commented Jan 17, 2019

eclipse-che/che#12306

Signed-off-by: Vitalii Parfonov vparfonov@redhat.com

@benoitf
Copy link
Contributor

benoitf commented Jan 17, 2019

FYI seems there is a conflict

plugins/ssh-plugin/package.json Show resolved Hide resolved
plugins/ssh-plugin/package.json Outdated Show resolved Hide resolved
@@ -0,0 +1,47 @@
/*********************************************************************
* Copyright (c) 2018 Red Hat, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019 now

plugins/ssh-plugin/src/common/ssh-protocol.ts Outdated Show resolved Hide resolved
plugins/ssh-plugin/src/node/ssh-key-service-client.ts Outdated Show resolved Hide resolved
plugins/ssh-plugin/src/node/ssh-key-service-client.ts Outdated Show resolved Hide resolved
plugins/ssh-plugin/src/node/ws-master-http-client.ts Outdated Show resolved Hide resolved
plugins/ssh-plugin/src/ssh-plugin-backend.ts Outdated Show resolved Hide resolved
try {
const client = await this.wsClient();
if (client) {
return await client.generateSshKey(service, name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks odd to return await as we're returning a promise ?

return await client.generateSshKey(service, name);
}

return Promise.reject(`Unable to generate SSH Key for ${service}:${name}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with async methods we can just do throw new Error()

try {
const client = await this.wsClient();
if (client) {
return await client.createSshKey(sshKeyPair);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a return and await ?

try {
const client = await this.wsClient();
if (client) {
return await client.getAllSshKey(service);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why return await ?

* @inheritDoc
*/
create(sshKeyPair: cheApi.ssh.SshPair): Promise<void> {
return new Promise<void>((resolve, reject) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here why are we not using async/await as well ?


import * as theia from '@theia/plugin';
import { RemoteSshKeyManager, SshKeyManager, CheService } from './node/ssh-key-manager';
import WorkspaceClient from '@eclipse-che/workspace-client';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need workspace-client ?
AFAIK @eclipse-che/plugin should provide the access to ssh no ?

@@ -0,0 +1,43 @@
/*********************************************************************
* Copyright (c) 2018 Red Hat, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


throw new Error(`Unable to generate SSH Key for ${service}:${name}`);
} catch (e) {
throw new Error('Unable to create Che API REST Client');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rethrow original error ? here message is lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, you are right


throw new Error(`Unable to create SSH Key`);
} catch (e) {
throw new Error('Unable to create Che API REST Client');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if try () catch is only for

 await this.wsClient()

why not throw an error instead of returning undefined ?
also try / catch block should be just around this.wsClient() if kept like this

note: this comment applies to all get***() methods

@@ -0,0 +1,78 @@
/*********************************************************************
* Copyright (c) 2018 Red Hat, Inc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2019

@@ -22,6 +22,9 @@ module.exports = {
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, why do we need this change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is temporary, in some reason got error form webpack

export namespace ssh {
export function generate(service: string, name: string): Promise<cheApi.ssh.SshPair>;

export function create(sshKeyPair: cheApi.ssh.SshPair): Promise<void>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it be PromiseLike in return type ?

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
"include": [
"src"
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: EOF

"@theia/plugin-packager": "latest",
"rimraf": "2.6.2",
"typescript-formatter": "7.2.2",
"typescript": "2.9.2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove all devDependencies that are already in the parent folder (yarn workspace)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also probably axios is no longer used there ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Signed-off-by: Vitalii Parfonov <vparfonov@redhat.com>
Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Vitalii 👍

@vparfonov vparfonov merged commit ea3edba into master Feb 26, 2019
@vparfonov vparfonov deleted the che#12306 branch February 26, 2019 08:23
vinokurig pushed a commit that referenced this pull request Apr 6, 2021
Signed-off-by: Oleksandr Garagatyi <ogaragat@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants