-
Notifications
You must be signed in to change notification settings - Fork 17
Add container view to container apps #673
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6abcc50
Add Container tree item
motm32 0a994e7
Merge branch 'main' of github.com:microsoft/vscode-azurecontainerapps…
motm32 f99baf6
Add containers tree items
motm32 d613242
Add containers items
motm32 c46bb55
merge main
motm32 acbd799
Add env var and update
motm32 27b4bdd
Changes
motm32 e6d6a87
more small changes
motm32 9c65959
requested changes
motm32 116fbdf
id changes
motm32 d5c97c0
change to fix image
motm32 e256594
fix env var
motm32 a51a66a
merge main
motm32 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { type Container, type Revision } from "@azure/arm-appcontainers"; | ||
| import { nonNullProp, nonNullValue, type TreeElementBase } from "@microsoft/vscode-azext-utils"; | ||
| import { type AzureSubscription, type ViewPropertiesModel } from "@microsoft/vscode-azureresources-api"; | ||
| import { TreeItemCollapsibleState, type TreeItem } from "vscode"; | ||
| import { getParentResource } from "../../utils/revisionDraftUtils"; | ||
| import { type ContainerAppModel } from "../ContainerAppItem"; | ||
| import { type RevisionsItemModel } from "../revisionManagement/RevisionItem"; | ||
| import { EnvironmentVariablesItem } from "./EnvironmentVariablesItem"; | ||
| import { ImageItem } from "./ImageItem"; | ||
|
|
||
| export class ContainerItem implements RevisionsItemModel { | ||
| id: string; | ||
| label: string; | ||
| static readonly contextValue: string = 'containerItem'; | ||
| static readonly contextValueRegExp: RegExp = new RegExp(ContainerItem.contextValue); | ||
|
|
||
| constructor(readonly subscription: AzureSubscription, readonly containerApp: ContainerAppModel, readonly revision: Revision, readonly container: Container) { | ||
| this.id = `${this.parentResource.id}/${container.name}`; | ||
| this.label = nonNullValue(this.container.name); | ||
| } | ||
|
|
||
| getTreeItem(): TreeItem { | ||
| return { | ||
| id: this.id, | ||
| label: `${this.container.name}`, | ||
| contextValue: ContainerItem.contextValue, | ||
| collapsibleState: TreeItemCollapsibleState.Collapsed, | ||
| } | ||
| } | ||
|
|
||
| getChildren(): TreeElementBase[] { | ||
| return [ | ||
| new ImageItem(this.subscription, this.containerApp, this.revision, this.id, this.container), | ||
| new EnvironmentVariablesItem(this.subscription, this.containerApp, this.revision, this.id, this.container) | ||
| ]; | ||
| } | ||
|
|
||
| private get parentResource(): ContainerAppModel | Revision { | ||
| return getParentResource(this.containerApp, this.revision); | ||
| } | ||
|
|
||
| viewProperties: ViewPropertiesModel = { | ||
| data: this.container, | ||
| label: nonNullProp(this.container, 'name'), | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { KnownActiveRevisionsMode, type Container, type Revision } from "@azure/arm-appcontainers"; | ||
| import { nonNullValue, nonNullValueAndProp, type TreeElementBase } from "@microsoft/vscode-azext-utils"; | ||
| import { type AzureSubscription, type ViewPropertiesModel } from "@microsoft/vscode-azureresources-api"; | ||
| import * as deepEqual from 'deep-eql'; | ||
| import { TreeItemCollapsibleState, type TreeItem } from "vscode"; | ||
| import { ext } from "../../extensionVariables"; | ||
| import { localize } from "../../utils/localize"; | ||
| import { getParentResource } from "../../utils/revisionDraftUtils"; | ||
| import { treeUtils } from "../../utils/treeUtils"; | ||
| import { type ContainerAppModel } from "../ContainerAppItem"; | ||
| import { RevisionDraftDescendantBase } from "../revisionManagement/RevisionDraftDescendantBase"; | ||
| import { RevisionDraftItem } from "../revisionManagement/RevisionDraftItem"; | ||
| import { ContainerItem } from "./ContainerItem"; | ||
| import { EnvironmentVariablesItem } from "./EnvironmentVariablesItem"; | ||
| import { ImageItem } from "./ImageItem"; | ||
|
|
||
| export class ContainersItem extends RevisionDraftDescendantBase { | ||
| id: string; | ||
| label: string; | ||
| private containers: Container[] = []; | ||
|
|
||
| constructor(public readonly subscription: AzureSubscription, | ||
| public readonly containerApp: ContainerAppModel, | ||
| public readonly revision: Revision,) { | ||
| super(subscription, containerApp, revision); | ||
| this.id = `${this.parentResource.id}/containers`; | ||
| this.containers = nonNullValue(revision.template?.containers); | ||
| this.label = this.containers.length === 1 ? localize('container', 'Container') : localize('containers', 'Containers'); | ||
| } | ||
|
|
||
| getChildren(): TreeElementBase[] { | ||
| if (this.containers.length === 1) { | ||
| return [new ImageItem(this.subscription, this.containerApp, this.revision, this.id, this.containers[0]), | ||
| new EnvironmentVariablesItem(this.subscription, this.containerApp, this.revision, this.id, this.containers[0])]; | ||
| } | ||
| return nonNullValue(this.containers?.map(container => new ContainerItem(this.subscription, this.containerApp, this.revision, container))); | ||
| } | ||
|
|
||
| getTreeItem(): TreeItem { | ||
| return { | ||
| id: this.id, | ||
| label: this.label, | ||
| iconPath: treeUtils.getIconPath('containers'), | ||
| collapsibleState: TreeItemCollapsibleState.Collapsed | ||
| } | ||
| } | ||
|
|
||
| private get parentResource(): ContainerAppModel | Revision { | ||
| return getParentResource(this.containerApp, this.revision); | ||
| } | ||
|
|
||
| protected setProperties(): void { | ||
| this.label = this.containers.length === 1 ? localize('container', 'Container') : localize('containers', 'Containers'); | ||
| this.containers = nonNullValueAndProp(this.parentResource.template, 'containers'); | ||
| } | ||
|
|
||
| protected setDraftProperties(): void { | ||
| this.label = this.containers.length === 1 ? localize('container*', 'Container*') : localize('containers*', 'Containers*'); | ||
| this.containers = nonNullValueAndProp(ext.revisionDraftFileSystem.parseRevisionDraft(this), 'containers'); | ||
| } | ||
|
|
||
| viewProperties: ViewPropertiesModel = { | ||
| label: 'Containers', | ||
| getData: async () => { | ||
| return this.containers.length === 1 ? this.containers[0] : JSON.stringify(this.containers) | ||
| } | ||
| } | ||
|
|
||
| hasUnsavedChanges(): boolean { | ||
| // We only care about showing changes to descendants of the revision draft item when in multiple revisions mode | ||
| if (this.containerApp.revisionsMode === KnownActiveRevisionsMode.Multiple && !RevisionDraftItem.hasDescendant(this)) { | ||
| return false; | ||
| } | ||
|
|
||
| const draftTemplate = ext.revisionDraftFileSystem.parseRevisionDraft(this)?.containers; | ||
| const currentTemplate = this.parentResource.template?.containers; | ||
|
|
||
| if (!draftTemplate) { | ||
| return false; | ||
| } | ||
|
|
||
| return !deepEqual(currentTemplate, draftTemplate); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { type Container, type EnvironmentVar, type Revision } from "@azure/arm-appcontainers"; | ||
| import { type IActionContext } from "@microsoft/vscode-azext-utils"; | ||
| import { type AzureSubscription } from "@microsoft/vscode-azureresources-api"; | ||
| import { ThemeIcon, type TreeItem } from "vscode"; | ||
| import { ext } from "../../extensionVariables"; | ||
| import { localize } from "../../utils/localize"; | ||
| import { getParentResource } from "../../utils/revisionDraftUtils"; | ||
| import { type ContainerAppModel } from "../ContainerAppItem"; | ||
| import { type RevisionsItemModel } from "../revisionManagement/RevisionItem"; | ||
|
|
||
| export class EnvironmentVariableItem implements RevisionsItemModel { | ||
| _hideValue: boolean; | ||
| constructor(public readonly subscription: AzureSubscription, | ||
| public readonly containerApp: ContainerAppModel, | ||
| public readonly revision: Revision, | ||
| readonly containerId: string, | ||
| readonly container: Container, | ||
| readonly envVariable: EnvironmentVar) { | ||
| this._hideValue = true; | ||
| } | ||
| id: string = `${this.parentResource.id}/${this.container.image}/${this.envVariable.name}` | ||
|
|
||
| getTreeItem(): TreeItem { | ||
| return { | ||
| label: this._hideValue ? `${this.envVariable.name}=Hidden value. Click to view.` : `${this.envVariable.name}=${this.envVariable.value}`, | ||
| contextValue: 'environmentVariableItem', | ||
| iconPath: new ThemeIcon('symbol-constant'), | ||
| command: { | ||
| command: 'containerapps.toggleEnvironmentVariableVisibility', | ||
| title: localize('commandtitle', 'Toggle Environment Variable Visibility'), | ||
| arguments: [this, this._hideValue,] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public async toggleValueVisibility(_: IActionContext): Promise<void> { | ||
| this._hideValue = !this._hideValue; | ||
| ext.branchDataProvider.refresh(this); | ||
| } | ||
|
|
||
| private get parentResource(): ContainerAppModel | Revision { | ||
| return getParentResource(this.containerApp, this.revision); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.md in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| import { type Container, type Revision } from "@azure/arm-appcontainers"; | ||
| import { type TreeElementBase } from "@microsoft/vscode-azext-utils"; | ||
| import { type AzureSubscription } from "@microsoft/vscode-azureresources-api"; | ||
| import { ThemeIcon, TreeItemCollapsibleState, type TreeItem } from "vscode"; | ||
| import { localize } from "../../utils/localize"; | ||
| import { getParentResource } from "../../utils/revisionDraftUtils"; | ||
| import { type ContainerAppModel } from "../ContainerAppItem"; | ||
| import { type RevisionsItemModel } from "../revisionManagement/RevisionItem"; | ||
| import { EnvironmentVariableItem } from "./EnvironmentVariableItem"; | ||
|
|
||
| export class EnvironmentVariablesItem implements RevisionsItemModel { | ||
| static readonly contextValue: string = 'environmentVariablesItem'; | ||
| static readonly contextValueRegExp: RegExp = new RegExp(EnvironmentVariablesItem.contextValue); | ||
|
|
||
| constructor(public readonly subscription: AzureSubscription, | ||
| public readonly containerApp: ContainerAppModel, | ||
| public readonly revision: Revision, | ||
| readonly containerId: string, | ||
| readonly container: Container) { | ||
| } | ||
| id: string = `${this.parentResource.id}/environmentVariables/${this.container.image}`; | ||
|
|
||
| getTreeItem(): TreeItem { | ||
| return { | ||
| id: this.id, | ||
| label: localize('environmentVariables', 'Environment Variables'), | ||
| iconPath: new ThemeIcon('settings'), | ||
| contextValue: EnvironmentVariablesItem.contextValue, | ||
| collapsibleState: TreeItemCollapsibleState.Collapsed | ||
| } | ||
| } | ||
|
|
||
| getChildren(): TreeElementBase[] | undefined { | ||
| if (!this.container.env) { | ||
| return; | ||
| } | ||
| return this.container.env?.map(env => new EnvironmentVariableItem(this.subscription, this.containerApp, this.revision, this.id, this.container, env)); | ||
| } | ||
|
|
||
| private get parentResource(): ContainerAppModel | Revision { | ||
| return getParentResource(this.containerApp, this.revision); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.