diff --git a/package.json b/package.json index ef131a0262..a8f7c8f5f3 100644 --- a/package.json +++ b/package.json @@ -1836,8 +1836,10 @@ "None", "Ports", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "State", "Status", @@ -1868,8 +1870,10 @@ "Networks", "Ports", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "State", "Status", @@ -1891,8 +1895,10 @@ "Networks", "Ports", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "State", "Status", @@ -1948,8 +1954,10 @@ "ImageId", "None", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "Tag" ] @@ -1967,8 +1975,10 @@ "FullTag", "ImageId", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "Tag", "Size" @@ -1984,8 +1994,10 @@ "FullTag", "ImageId", "Registry", + "RegistryAndPath", "Repository", "RepositoryName", + "RepositoryNameShort", "RepositoryNameAndTag", "Tag", "Size" diff --git a/package.nls.json b/package.nls.json index f9a040027c..c5e6f86adb 100644 --- a/package.nls.json +++ b/package.nls.json @@ -158,17 +158,17 @@ "vscode-docker.config.template.composeDown.label": "The label displayed to the user.", "vscode-docker.config.template.composeDown.match": "The regular expression for choosing the right template. Checked against docker-compose YAML files, folder name, etc.", "vscode-docker.config.template.composeDown.description": "Command templates for `docker-compose down` commands.", - "vscode-docker.config.docker.containers.groupBy": "The property to use to group containers in Docker view: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, Repository, RepositoryName, RepositoryNameAndTag, State, Status, Tag, or None", + "vscode-docker.config.docker.containers.groupBy": "The property to use to group containers in Docker view: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, State, Status, Tag, or None", "vscode-docker.config.docker.containers.groupByLabel": "The items will be grouped by the value of this container label (e.g. `com.microsoft.created-by`)", - "vscode-docker.config.docker.containers.description": "Any secondary properties to display for a container (an array). Possible elements include: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, Repository, RepositoryName, RepositoryNameAndTag, State, Status, and Tag", - "vscode-docker.config.docker.containers.label": "The primary property to display for a container: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, Repository, RepositoryName, RepositoryNameAndTag, State, Status, or Tag", + "vscode-docker.config.docker.containers.description": "Any secondary properties to display for a container (an array). Possible elements include: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, State, Status, and Tag", + "vscode-docker.config.docker.containers.label": "The primary property to display for a container: ContainerId, ContainerName, CreatedTime, FullTag, ImageId, Networks, Ports, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, State, Status, or Tag", "vscode-docker.config.docker.containers.sortBy": "The property to use to sort containers in Docker view: CreatedTime or Label", "vscode-docker.config.docker.contexts.description": "Any secondary properties to display for a Docker context (an array). Possible elements include: Name, Description and DockerEndpoint", "vscode-docker.config.docker.contexts.label": "The primary property to display for a Docker context: Name, Description or DockerEndpoint", "vscode-docker.config.docker.contexts.showInStatusBar": "Show current Docker context in the status bar", - "vscode-docker.config.docker.images.groupBy": "The property to use to group images in Docker view: CreatedTime, FullTag, ImageId, None, Registry, Repository, RepositoryName, RepositoryNameAndTag, or Tag", - "vscode-docker.config.docker.images.description": "Any secondary properties to display for a image (an array). Possible elements include: CreatedTime, FullTag, ImageId, Registry, Repository, RepositoryName, RepositoryNameAndTag, Tag, and Size", - "vscode-docker.config.docker.images.label": "The primary property to display for a image: CreatedTime, FullTag, ImageId, Registry, Repository, RepositoryName, RepositoryNameAndTag, Tag, or Size", + "vscode-docker.config.docker.images.groupBy": "The property to use to group images in Docker view: CreatedTime, FullTag, ImageId, None, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, or Tag", + "vscode-docker.config.docker.images.description": "Any secondary properties to display for a image (an array). Possible elements include: CreatedTime, FullTag, ImageId, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, Tag, and Size", + "vscode-docker.config.docker.images.label": "The primary property to display for a image: CreatedTime, FullTag, ImageId, Registry, RegistryAndPath, Repository, RepositoryName, RepositoryNameShort, RepositoryNameAndTag, Tag, or Size", "vscode-docker.config.docker.images.sortBy": "The property to use to sort images in Docker view: CreatedTime, Label, or Size", "vscode-docker.config.docker.images.checkForOutdatedImages": "Check for outdated base images once per Visual Studio Code session", "vscode-docker.config.docker.networks.groupBy": "The property to use to group networks in Docker view: CreatedTime, NetworkDriver, NetworkId, NetworkName, or None", diff --git a/src/tree/images/ImageProperties.ts b/src/tree/images/ImageProperties.ts index 2b4c4e3bbe..4fa7090e61 100644 --- a/src/tree/images/ImageProperties.ts +++ b/src/tree/images/ImageProperties.ts @@ -11,15 +11,27 @@ import { CommonGroupBy, CommonProperty, commonProperties, getCommonGroupIcon, ge import { ITreePropertyInfo } from '../settings/ITreeSettingInfo'; import { NormalizedImageNameInfo } from "./NormalizedImageNameInfo"; -export type ImageProperty = CommonProperty | 'FullTag' | 'ImageId' | 'Registry' | 'Repository' | 'RepositoryName' | 'RepositoryNameAndTag' | 'Tag'; +export type ImageProperty = + | CommonProperty + | 'FullTag' + | 'ImageId' + | 'Registry' + | 'RegistryAndPath' + | 'Repository' + | 'RepositoryNameShort' + | 'RepositoryName' + | 'RepositoryNameAndTag' + | 'Tag'; export const imageProperties: ITreePropertyInfo[] = [ ...commonProperties, { property: 'FullTag', exampleValue: 'example.azurecr.io/hello-world:latest' }, { property: 'ImageId', exampleValue: 'd9d09edd6115' }, { property: 'Registry', exampleValue: 'example.azurecr.io' }, - { property: 'Repository', exampleValue: 'example.azurecr.io/hello-world' }, - { property: 'RepositoryName', exampleValue: 'hello-world' }, + { property: 'RegistryAndPath', exampleValue: 'example.azurecr.io/my-path/hello-world' }, + { property: 'Repository', exampleValue: 'example.azurecr.io' }, + { property: 'RepositoryNameShort', exampleValue: 'hello-world' }, + { property: 'RepositoryName', exampleValue: 'my-path/hello-world' }, { property: 'RepositoryNameAndTag', exampleValue: 'hello-world:latest' }, { property: 'Tag', exampleValue: 'latest' }, { property: 'Size', exampleValue: '27 MB' }, @@ -28,9 +40,11 @@ export const imageProperties: ITreePropertyInfo[] = [ export function getImageGroupIcon(property: ImageProperty | CommonGroupBy): ThemeIcon { switch (property) { case 'Registry': + case 'RegistryAndPath': return new ThemeIcon('briefcase'); case 'Repository': case 'RepositoryName': + case 'RepositoryNameShort': return new ThemeIcon('repo'); case 'FullTag': case 'ImageId': @@ -57,12 +71,18 @@ export function getImagePropertyValue(item: ListImagesItem, property: ImagePrope case 'Registry': result = normalizedImageNameInfo.normalizedRegistry; break; + case 'RegistryAndPath': + result = normalizedImageNameInfo.normalizedRegistryAndPath; + break; case 'Repository': result = normalizedImageNameInfo.normalizedRegistryAndImageName; break; case 'RepositoryName': result = normalizedImageNameInfo.normalizedImageName; break; + case 'RepositoryNameShort': + result = normalizedImageNameInfo.normalizedImageShortName; + break; case 'RepositoryNameAndTag': result = normalizedImageNameInfo.normalizedImageNameAndTag; break; diff --git a/src/tree/images/NormalizedImageNameInfo.ts b/src/tree/images/NormalizedImageNameInfo.ts index 4aa332bd3d..7cd0f6e70a 100644 --- a/src/tree/images/NormalizedImageNameInfo.ts +++ b/src/tree/images/NormalizedImageNameInfo.ts @@ -70,6 +70,30 @@ export class NormalizedImageNameInfo { return this.imageNameInfo.registry || 'docker.io'; } + /** + * Registry (if it is truthy), otherwise 'docker.io' + */ + public get normalizedRegistryAndPath(): string { + if (this.normalizedRepositoryPath.length === 0) { + return this.normalizedRegistry; + } + return this.normalizedRegistry + "/" + this.normalizedRepositoryPath; + } + + /** + * The short image name or '' if the image name is falsy + */ + public get normalizedImageShortName(): string { + return this.normalizedImageName.split("/").pop() || noneTag; + } + + /** + * The repository path or empty string if the image path is empty + */ + public get normalizedRepositoryPath(): string { + return this.normalizedImageName.split("/").slice(0, -1).join("/"); + } + /** * Normalized registry + normalized image name */