chore: fixing usage of async calls

Change-Id: Id96a54810cd7e0e141070adf99778b4660df3774
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2023-05-10 23:47:24 +02:00 committed by Florent BENOIT
parent 1aba2c167e
commit d4c5121723
3 changed files with 17 additions and 13 deletions

View file

@ -116,12 +116,12 @@ export class ComposeExtension {
this.statusBarItem.command = statusBarChangesToApply.command;
}
this.notifyOnChecks(firstCheck);
await this.notifyOnChecks(firstCheck);
}
protected notifyOnChecks(firstCheck: boolean): void {
protected async notifyOnChecks(firstCheck: boolean): Promise<void> {
if (this.currentInformation && !firstCheck) {
this.showCurrentInformation();
await this.showCurrentInformation();
}
}
@ -182,10 +182,10 @@ export class ComposeExtension {
// make it executable
await this.makeExecutable(dockerComposeDownloadLocation);
extensionApi.window.showInformationMessage(`Docker Compose ${selectedRelease.label} installed`);
await extensionApi.window.showInformationMessage(`Docker Compose ${selectedRelease.label} installed`);
// update checks
this.runChecks(false);
await this.runChecks(false);
}
}
@ -215,9 +215,9 @@ export class ComposeExtension {
await this.makeExecutable(composeWrapperScript);
}
showCurrentInformation(): void {
async showCurrentInformation(): Promise<void> {
if (this.currentInformation) {
extensionApi.window.showInformationMessage(this.currentInformation);
await extensionApi.window.showInformationMessage(this.currentInformation);
}
}

View file

@ -87,7 +87,7 @@ async function isDisguisedPodman(socketPath: string): Promise<boolean> {
});
}
async function monitorDaemon(extensionContext: extensionApi.ExtensionContext) {
async function monitorDaemon(extensionContext: extensionApi.ExtensionContext): Promise<void> {
// call us again
if (!stopLoop) {
try {
@ -96,7 +96,9 @@ async function monitorDaemon(extensionContext: extensionApi.ExtensionContext) {
// ignore the update of machines
}
await timeout(5000);
monitorDaemon(extensionContext);
monitorDaemon(extensionContext).catch(err => {
console.error('Error while monitoring docker daemon', err);
});
}
}
@ -144,7 +146,9 @@ export async function activate(extensionContext: extensionApi.ExtensionContext):
}
// monitor daemon
monitorDaemon(extensionContext);
monitorDaemon(extensionContext).catch(err => {
console.error('Error while monitoring docker daemon', err);
});
}
function initProvider(extensionContext: extensionApi.ExtensionContext) {

View file

@ -83,12 +83,12 @@ export class ImageHandler {
// Show a dialog to the user that the image was pushed
// TODO: Change this to taskbar notification when implemented
extensionApi.window.showInformationMessage(
await extensionApi.window.showInformationMessage(
`Image ${image.name} pushed to Kind cluster: ${selectedCluster.label}`,
);
} catch (err) {
// Show a dialog error to the user that the image was not pushed
extensionApi.window.showErrorMessage(
await extensionApi.window.showErrorMessage(
`Unable to push image ${image.name} to Kind cluster: ${selectedCluster.label}. Error: ${err}`,
);
@ -97,7 +97,7 @@ export class ImageHandler {
} finally {
// Remove the temporary file if one was created
if (filename !== undefined) {
fs.promises.rm(filename);
await fs.promises.rm(filename);
}
}
}