Skip to content

Commit

Permalink
Use abstract class
Browse files Browse the repository at this point in the history
  • Loading branch information
MicroFish91 committed Jan 9, 2025
1 parent 856032d commit 519424d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ type StartingResourcesLogContext = IActionContext & Partial<ExecuteActivityConte
/**
* Use to display primary Azure resources to the output and activity log
*/
export class StartingResourcesLogStep<T extends StartingResourcesLogContext> extends AzureWizardPromptStep<T> {
export abstract class StartingResourcesLogStepBase<T extends StartingResourcesLogContext> extends AzureWizardPromptStep<T> {
public hideStepCount: boolean = true;
protected hasLogged: boolean = false;

abstract configureStartingResources(context: T): void | Promise<void>;

public async configureBeforePrompt(context: T): Promise<void> {
if (this.hasLogged) {
return;
}
await this.configureStartingResources(context);
await this.logStartingResources(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ import { type ResourceGroup } from "@azure/arm-resources";
import { LocationListStep, ResourceGroupListStep } from "@microsoft/vscode-azext-azureutils";
import { nonNullValue, nonNullValueAndProp } from "@microsoft/vscode-azext-utils";
import { localize } from "../../utils/localize";
import { StartingResourcesLogStep } from "../StartingResourcesLogStep";
import { StartingResourcesLogStepBase } from "../StartingResourcesLogStepBase";
import { type ContainerEditContext } from "./ContainerEditContext";

export class ContainerEditStartingResourcesLogStep<T extends ContainerEditContext> extends StartingResourcesLogStep<T> {
override async configureBeforePrompt(context: T): Promise<void> {
if (this.hasLogged) {
return;
}

export class ContainerEditStartingResourcesLogStep<T extends ContainerEditContext> extends StartingResourcesLogStepBase<T> {
async configureStartingResources(context: T): Promise<void> {
const resourceGroups: ResourceGroup[] = await ResourceGroupListStep.getResourceGroups(context);
context.resourceGroup = nonNullValue(
resourceGroups.find(rg => rg.name === context.containerApp?.resourceGroup),
localize('containerAppResourceGroup', 'Expected to find the container app\'s resource group.'),
);

await LocationListStep.setLocation(context, nonNullValueAndProp(context.containerApp, 'location'));
await this.logStartingResources(context);
}
}

0 comments on commit 519424d

Please sign in to comment.