Skip to content

Commit

Permalink
Change run commands to use imageId instead of tag (#4112)
Browse files Browse the repository at this point in the history
* Change run commands to use imageId instead of name

* changes proposed by bwateratmsft

* Update src/commands/images/runImage.ts

Co-authored-by: Alex Yang [MSFT] <59073590+alexyaang@users.noreply.github.com>

* Update src/commands/selectCommandTemplate.ts

Co-authored-by: Alex Yang [MSFT] <59073590+alexyaang@users.noreply.github.com>

---------

Co-authored-by: Alex Yang [MSFT] <59073590+alexyaang@users.noreply.github.com>
  • Loading branch information
jnsjunior and alexyaang committed Oct 18, 2023
1 parent c68fa17 commit 4a343b5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/commands/images/runImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ async function runImageCore(context: IActionContext, node: ImageTreeItem | undef
const terminalCommand = await selectRunCommand(
context,
node.fullTag,
node.imageId,
interactive,
inspectResult?.[0]?.ports
);

const taskCRF = new TaskCommandRunnerFactory(
{
taskName: node.fullTag,
taskName: node.fullTag === '<none>' ? node.imageId : node.fullTag,
alwaysRunNew: interactive,
}
);
Expand Down
9 changes: 6 additions & 3 deletions src/commands/selectCommandTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,21 @@ export async function selectBuildCommand(context: IActionContext, folder: vscode
);
}

export async function selectRunCommand(context: IActionContext, fullTag: string, interactive: boolean, exposedPorts?: PortBinding[]): Promise<VoidCommandResponse> {
export async function selectRunCommand(context: IActionContext, fullTag: string, imageId: string, interactive: boolean, exposedPorts?: PortBinding[]): Promise<VoidCommandResponse> {
let portsString: string = '';
if (exposedPorts) {
portsString = exposedPorts.map(pb => `-p ${pb.containerPort}:${pb.containerPort}${pb.protocol ? '/' + pb.protocol : ''}`).join(' ');
}

const tagOrImageId = fullTag === '<none>' ? imageId : fullTag;


return await selectCommandTemplate(
context,
interactive ? 'runInteractive' : 'run',
[fullTag],
[fullTag, imageId],
undefined,
{ 'tag': fullTag, 'exposedPorts': portsString, 'containerCommand': await ext.runtimeManager.getCommand() }
{ 'tag': tagOrImageId, 'exposedPorts': portsString, 'containerCommand': await ext.runtimeManager.getCommand() }
);
}

Expand Down

0 comments on commit 4a343b5

Please sign in to comment.