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

feat: add image property for better organization #4426

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1836,8 +1836,10 @@
"None",
"Ports",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"State",
"Status",
Expand Down Expand Up @@ -1868,8 +1870,10 @@
"Networks",
"Ports",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"State",
"Status",
Expand All @@ -1891,8 +1895,10 @@
"Networks",
"Ports",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"State",
"Status",
Expand Down Expand Up @@ -1948,8 +1954,10 @@
"ImageId",
"None",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"Tag"
]
Expand All @@ -1967,8 +1975,10 @@
"FullTag",
"ImageId",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"Tag",
"Size"
Expand All @@ -1984,8 +1994,10 @@
"FullTag",
"ImageId",
"Registry",
"RegistryAndPath",
"Repository",
"RepositoryName",
"RepositoryNameShort",
"RepositoryNameAndTag",
"Tag",
"Size"
Expand Down
12 changes: 6 additions & 6 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 23 additions & 3 deletions src/tree/images/ImageProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ImageProperty>[] = [
...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' },
Expand All @@ -28,9 +40,11 @@ export const imageProperties: ITreePropertyInfo<ImageProperty>[] = [
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':
Expand All @@ -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;
Expand Down
24 changes: 24 additions & 0 deletions src/tree/images/NormalizedImageNameInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<none>' 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
*/
Expand Down
Loading