Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Service Connector #381

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Add Service Connector #381

wants to merge 4 commits into from

Conversation

motm32
Copy link
Contributor

@motm32 motm32 commented Jun 6, 2023

Related to microsoft/vscode-azuretools#1419

A couple of notes:

Currently just for testing the create, delete, and validate service connector commands are accessible from right clicking on a container app.
image
These commands will be moved to the service connector node once that is added in tools. In order to view if the service connector was created/deleted correctly you will have to look at the portal.

@motm32 motm32 requested a review from a team as a code owner June 6, 2023 17:31
src/commands/serviceConnector/ContainerPickStep.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/ContainerPickStep.ts Outdated Show resolved Hide resolved
import { IServiceConnectorContext } from "./IServiceConnectorContext";

export class ContainerPickStep extends AzureWizardPromptStep<IActionContext> {
public async prompt(context: IServiceConnectorContext): Promise<void> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note, you don't have to change it, adding public here is optional. TS assumes things are public by default.

I saw Phil H. doing this and I like it better because it shortens line widths and makes things a bit cleaner.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping public to keep things explicit. Time for a cage match!

src/commands/serviceConnector/createServiceConnector.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/createServiceConnector.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/deleteServiceConnector.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/validateServiceConnector.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/createServiceConnector.ts Outdated Show resolved Hide resolved
import { ContainerAppModel } from "../../tree/ContainerAppItem";

export interface IServiceConnectorContext extends ICreateLinkerContext {
containerApp: ContainerAppModel;
Copy link
Contributor

@MicroFish91 MicroFish91 Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could extend from IContainerAppContext (on main branch) which includes the containerApp and subscription.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended from the ICreateLinkerContext since I needed the scope.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, IStreamLogsContext and IAddScaleRuleWizardContext could as well though IContainerAppContext has containerApp as an optional property. Not sure if that gunks things up a bit.

Copy link
Contributor

@MicroFish91 MicroFish91 Jun 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extended from the ICreateLinkerContext since I needed the scope.

Is there a reason we shouldn't extend from both?

Yeah, IStreamLogsContext and IAddScaleRuleWizardContext could as well though IContainerAppContext has containerApp as an optional property. Not sure if that gunks things up a bit.

Yeah, there are a few contexts that probably still need to be migrated to extend from IContainerAppContext since it was only recently added. Scale rules is definitely one of those.

package.json Outdated Show resolved Hide resolved
import { IServiceConnectorContext } from "./IServiceConnectorContext";

export class ContainerPickStep extends AzureWizardPromptStep<IActionContext> {
public async prompt(context: IServiceConnectorContext): Promise<void> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer keeping public to keep things explicit. Time for a cage match!

src/commands/serviceConnector/ContainerPickStep.ts Outdated Show resolved Hide resolved
src/commands/serviceConnector/validateServiceConnector.ts Outdated Show resolved Hide resolved
import { localize } from "../../utils/localize";
import { IServiceConnectorContext } from "./IServiceConnectorContext";

export class ContainerPickStep extends AzureWizardPromptStep<IServiceConnectorContext> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this is called a ListStep not a PickStep.

Though I get that there is already a ContainerListStep, I think we should rename things to be more explicit. The ContainerListStep today is technically the ReplicaContainerListStep and has a hard requirement of having a replica defined on the context (which happens in the previous step). So maybe just rename that one and then call this ContainerListStep or TemplateContainerListStep?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will rename the other one!

}
}

private async getPicks(context: IServiceConnectorContext): Promise<IAzureQuickPickItem<string>[]> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be async.

import { ContainerAppModel } from "../../tree/ContainerAppItem";

export interface IServiceConnectorContext extends ICreateLinkerContext {
containerApp: ContainerAppModel;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, IStreamLogsContext and IAddScaleRuleWizardContext could as well though IContainerAppContext has containerApp as an optional property. Not sure if that gunks things up a bit.

Comment on lines 31 to 32
// @azure/container-registry doesn't support ADAL tokens at all. If it sees `signRequest` is defined
// it errors, but we don't actually need `signRequest` because this is a T2 package
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this comment now 😃

import { ICreateLinkerContext } from "@microsoft/vscode-azext-serviceconnector";
import { IContainerAppContext } from "../createContainerApp/IContainerAppContext";

export interface IServiceConnectorContext extends ICreateLinkerContext, IContainerAppContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: A possible cleaner looking alternative (if you don't end up adding any properties):

export type IServiceConnectorContext = ICreateLinkerContext & IContainerAppContext;

On a side note, I'm more and more agreeing with Alex on not liking the I prefix for context interfaces/types (that's not a change request, more of just a general musing 🙂).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants