Classes for adding kube config and kube cluster picker to Controller connection dialog (#13479)

This commit is contained in:
Arvind Ranasaria
2020-11-24 20:08:27 -08:00
committed by GitHub
parent c8632c255a
commit d060f1b9a0
10 changed files with 467 additions and 7 deletions

View File

@@ -67,7 +67,7 @@ export function getResourceTypeIcon(resourceType: string | undefined): IconPath
/**
* Returns the text to display for known connection modes
* @param connectionMode The string repsenting the connection mode
* @param connectionMode The string representing the connection mode
*/
export function getConnectionModeDisplayText(connectionMode: string | undefined): string {
connectionMode = connectionMode ?? '';
@@ -282,8 +282,18 @@ export function convertToGibibyteString(value: string): string {
* @param condition
* @param message
*/
export function throwUnless(condition: boolean, message?: string): asserts condition {
export function throwUnless(condition: any, message?: string): asserts condition {
if (!condition) {
throw new Error(message);
}
}
export async function tryExecuteAction<T>(action: () => T | PromiseLike<T>): Promise<{ result: T | undefined, error: any }> {
let error: any, result: T | undefined;
try {
result = await action();
} catch (e) {
error = e;
}
return { result, error };
}