Skip to content

Commit

Permalink
with discussed changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroFish91 committed Jan 6, 2023
1 parent 2213e46 commit c64e64e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/commands/deployImage/deployImageApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,21 @@ import { IDeployImageContext } from "./IDeployImageContext";
// The interface of the command options passed to the Azure Container Apps extension's deployImageToAca command
// This interface is shared with the Docker extension (https://github.com/microsoft/vscode-docker)
interface DeployImageToAcaOptionsContract {
imageName: string; // Todo: change `imageName` to `image` or vice versa
image: string;
loginServer?: string;
username?: string;
secret?: string;
}

export async function deployImageApi(context: IActionContext & Partial<IDeployImageContext>, deployImageOptions: DeployImageToAcaOptionsContract): Promise<void> {
const subscription: ISubscriptionContext = (await ext.rgApi.appResourceTree.showTreeItemPicker<SubscriptionTreeItemBase>(SubscriptionTreeItemBase.contextValue, context)).subscription;
Object.assign(context, subscription);
Object.assign(context, subscription, deployImageOptions);

// test case for docker hub, will remove later
// deployImageOptions.imageName = 'docker.io/' + deployImageOptions.imageName;
// deployImageOptions.loginServer = 'https://index.docker.io';

context.registryDomain = imageNameUtils.detectRegistryDomain(deployImageOptions.imageName);
context.registryDomain = imageNameUtils.detectRegistryDomain(deployImageOptions.image);
if (context.registryDomain === acrDomain) {
context.registry = await imageNameUtils.getRegistryFromAcrName(<ISubscriptionActionContext>context, deployImageOptions.imageName);
context.registry = await imageNameUtils.getRegistryFromAcrName(<ISubscriptionActionContext>context, deployImageOptions.image);
}

// Todo: change contract from imageName to image (or vice versa) and just run `Object.assign(context, deployImageOptions)`
Object.assign(context, {
image: deployImageOptions.imageName,
loginServer: deployImageOptions.loginServer,
username: deployImageOptions.username,
secret: deployImageOptions.secret
});

// Mask sensitive data
if (context.secret) {
context.valuesToMask.push(context.secret);
Expand Down

0 comments on commit c64e64e

Please sign in to comment.