-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yevhen Vydolob <[email protected]>
- Loading branch information
Showing
2 changed files
with
167 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,32 +28,41 @@ export async function pushImageToCrcCluster(image: ImageInfo): Promise<void> { | |
if (!image.name) { | ||
throw new Error('Image selection not supported yet'); | ||
} | ||
|
||
const filename = path.join(os.tmpdir(), image.name ? image.name.replaceAll('/', '') : image.engineId); | ||
try { | ||
let name = image.name; | ||
if (image.tag) { | ||
name = name + ':' + image.tag; | ||
} | ||
await extensionApi.containerEngine.saveImage(image.engineId, name, filename); | ||
const result = await runCliCommand(getPodmanCli(), [ | ||
'--url=ssh://[email protected]:2222/run/podman/podman.sock', | ||
`--identity=${os.homedir()}/.crc/machines/crc/id_ecdsa`, | ||
'load', | ||
'-i', | ||
filename, | ||
]); | ||
|
||
if (result.exitCode !== 0) { | ||
throw new Error(result.stdErr); | ||
} | ||
extensionApi.window.showNotification({ | ||
body: `Image ${image.name} pushed to ${productName} cluster`, | ||
}); | ||
} catch (error) { | ||
const errorMessage = error instanceof Error ? error.message : '' + error; | ||
throw new Error(`Error while pushing image ${image.name} to ${productName} cluster: ${errorMessage}`); | ||
} finally { | ||
fs.promises.rm(filename); | ||
let name = image.name; | ||
if (image.tag) { | ||
name = name + ':' + image.tag; | ||
} | ||
|
||
return extensionApi.window.withProgress( | ||
{ location: extensionApi.ProgressLocation.TASK_WIDGET, title: `Pushing ${name}...` }, | ||
async progress => { | ||
progress.report({ increment: 0 }); | ||
const filename = path.join(os.tmpdir(), image.name ? image.name.replaceAll('/', '') : image.engineId); | ||
try { | ||
await extensionApi.containerEngine.saveImage(image.engineId, name, filename); | ||
progress.report({ increment: 50 }); | ||
const result = await runCliCommand(getPodmanCli(), [ | ||
'--url=ssh://[email protected]:2222/run/podman/podman.sock', | ||
`--identity=${os.homedir()}/.crc/machines/crc/id_ecdsa`, | ||
'load', | ||
'-i', | ||
filename, | ||
]); | ||
progress.report({ increment: 100 }); | ||
if (result.exitCode !== 0) { | ||
throw new Error(result.stdErr); | ||
} | ||
extensionApi.window.showNotification({ | ||
body: `Image ${image.name} pushed to ${productName} cluster`, | ||
}); | ||
} catch (error) { | ||
const errorMessage = error instanceof Error ? error.message : '' + error; | ||
progress.report({ | ||
message: `Error while pushing image ${image.name} to ${productName} cluster: ${errorMessage}`, | ||
}); | ||
} finally { | ||
fs.promises.rm(filename); | ||
} | ||
}, | ||
); | ||
} |
Oops, something went wrong.