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

Show progress bar for credentials and token Login #1236

Merged
merged 3 commits into from
Oct 23, 2019
Merged
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions src/openshift/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import open = require("open");
import { TokenStore } from "../util/credentialManager";
import { KubeConfigUtils } from '../util/kubeUtils';
import { Filters } from "../util/filters";
import { Progress } from "../util/progress";

class CreateUrlItem implements QuickPickItem {
get label(): string { return `$(plus) Provide new URL...`; }
Expand Down Expand Up @@ -173,11 +174,12 @@ export class Cluster extends OpenShiftItem {

if (!passwd) return null;

return Promise.resolve()
.then(() => Cluster.odo.execute(Command.odoLoginWithUsernamePassword(clusterURL, username, passwd)))
return Progress.execFunctionWithProgress(`login to cluster: ${clusterURL}`,
sudhirverma marked this conversation as resolved.
Show resolved Hide resolved
() => Cluster.odo.execute(Command.odoLoginWithUsernamePassword(clusterURL, username, passwd))
.then((result) => Cluster.save(username, passwd, password, result))
.then((result) => Cluster.loginMessage(clusterURL, result))
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterPassword(error.message)}'!`)));
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterPassword(error.message)}'!`)))
);
}

static async readFromClipboard(): Promise<string> {
Expand Down Expand Up @@ -207,10 +209,11 @@ export class Cluster extends OpenShiftItem {
password: true
});
if (!ocToken) return null;
return Promise.resolve()
.then(() => Cluster.odo.execute(Command.odoLoginWithToken(clusterURL, ocToken)))
return Progress.execFunctionWithProgress(`login to cluster: ${clusterURL}`,
sudhirverma marked this conversation as resolved.
Show resolved Hide resolved
() => Cluster.odo.execute(Command.odoLoginWithToken(clusterURL, ocToken))
.then((result) => Cluster.loginMessage(clusterURL, result))
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterToken(error.message)}'!`)));
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterToken(error.message)}'!`)))
);
}

private static async loginMessage(clusterURL: string, result: CliExitData): Promise<string> {
Expand Down