Skip to content

Commit 984f337

Browse files
sudhirvermadgolovin
authored andcommitted
Show progress bar for credentials and token Login (#1236)
* Show progress bar for credentials and token Login
1 parent 182e0c0 commit 984f337

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/openshift/cluster.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import open = require("open");
1111
import { TokenStore } from "../util/credentialManager";
1212
import { KubeConfigUtils } from '../util/kubeUtils';
1313
import { Filters } from "../util/filters";
14+
import { Progress } from "../util/progress";
1415

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

174175
if (!passwd) return null;
175176

176-
return Promise.resolve()
177-
.then(() => Cluster.odo.execute(Command.odoLoginWithUsernamePassword(clusterURL, username, passwd)))
177+
return Progress.execFunctionWithProgress(`Login to the cluster: ${clusterURL}`,
178+
() => Cluster.odo.execute(Command.odoLoginWithUsernamePassword(clusterURL, username, passwd))
178179
.then((result) => Cluster.save(username, passwd, password, result))
179180
.then((result) => Cluster.loginMessage(clusterURL, result))
180-
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterPassword(error.message)}'!`)));
181+
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterPassword(error.message)}'!`)))
182+
);
181183
}
182184

183185
static async readFromClipboard(): Promise<string> {
@@ -207,10 +209,11 @@ export class Cluster extends OpenShiftItem {
207209
password: true
208210
});
209211
if (!ocToken) return null;
210-
return Promise.resolve()
211-
.then(() => Cluster.odo.execute(Command.odoLoginWithToken(clusterURL, ocToken)))
212+
return Progress.execFunctionWithProgress(`Login to the cluster: ${clusterURL}`,
213+
() => Cluster.odo.execute(Command.odoLoginWithToken(clusterURL, ocToken))
212214
.then((result) => Cluster.loginMessage(clusterURL, result))
213-
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterToken(error.message)}'!`)));
215+
.catch((error) => Promise.reject(new Error(`Failed to login to cluster '${clusterURL}' with '${Filters.filterToken(error.message)}'!`)))
216+
);
214217
}
215218

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

0 commit comments

Comments
 (0)