Skip to content

Commit

Permalink
feat: prompt to select output folder
Browse files Browse the repository at this point in the history
Add prompt to select output folder.

Signed-off-by: Tim deBoer <[email protected]>
  • Loading branch information
deboer-tim committed Jan 9, 2024
1 parent d916e0b commit 9a7a075
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ export async function activate(extensionContext: ExtensionContext): Promise<void
const selectedType = await extensionApi.window.showQuickPick(['.oci', '.qcow2', '.ami', '.iso'], {
placeHolder: 'Select image type',
});
if (!selectedType)
return;

const selectedFolder = await extensionApi.window.showInputBox({
prompt: 'Select the folder to generate disk' + selectedType + ' into',
value: '~/',
ignoreFocusOut: true,
});
if (!selectedFolder)
return;

// TODO: check if file exists and warn or error out

return extensionApi.window.withProgress(
{ location: extensionApi.ProgressLocation.TASK_WIDGET, title: 'Building disk image ' + image.name },
Expand All @@ -50,7 +62,7 @@ export async function activate(extensionContext: ExtensionContext): Promise<void

await pullBootcImageBuilderImage();
await removePreviousBuildImage(image);
await createImage(image, selectedType);
await createImage(image, selectedType, selectedFolder);

// TODO:
// Wait until container has stopped
Expand Down Expand Up @@ -103,7 +115,7 @@ async function pullBootcImageBuilderImage() {
}
}

async function createImage(image, type: string) {
async function createImage(image, type, folder: string) {

console.log('Building ' + diskImageBuildingName + ' to ' + type);

Expand All @@ -129,12 +141,12 @@ let options: ContainerCreateOptions = {
HostConfig: {
Privileged: true,
SecurityOpt: ['label=type:unconfined_t'],
// Binds: ['/tmp:/tmp']
Binds: [folder + ':/tmp/' + type]
},
// Outputs to:
// <type>/disk.<type>
// in the directory provided
Cmd: [image.name,"--output","/tmp/bootc/"],
Cmd: [image.name,"--output","/tmp/"],
};
try {
await extensionApi.containerEngine.createContainer(image.engineId, options);
Expand Down

0 comments on commit 9a7a075

Please sign in to comment.