Skip to content
This repository was archived by the owner on Jul 20, 2026. It is now read-only.

Commit a45a3df

Browse files
authored
feat: add image property RepositoryNameShort and RegistryAndPath for better organization (#4426)
Co-authored-by: yoyoys <yoyoys@topctek.com>
1 parent b88fe8a commit a45a3df

4 files changed

Lines changed: 65 additions & 9 deletions

File tree

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,8 +1836,10 @@
18361836
"None",
18371837
"Ports",
18381838
"Registry",
1839+
"RegistryAndPath",
18391840
"Repository",
18401841
"RepositoryName",
1842+
"RepositoryNameShort",
18411843
"RepositoryNameAndTag",
18421844
"State",
18431845
"Status",
@@ -1868,8 +1870,10 @@
18681870
"Networks",
18691871
"Ports",
18701872
"Registry",
1873+
"RegistryAndPath",
18711874
"Repository",
18721875
"RepositoryName",
1876+
"RepositoryNameShort",
18731877
"RepositoryNameAndTag",
18741878
"State",
18751879
"Status",
@@ -1891,8 +1895,10 @@
18911895
"Networks",
18921896
"Ports",
18931897
"Registry",
1898+
"RegistryAndPath",
18941899
"Repository",
18951900
"RepositoryName",
1901+
"RepositoryNameShort",
18961902
"RepositoryNameAndTag",
18971903
"State",
18981904
"Status",
@@ -1948,8 +1954,10 @@
19481954
"ImageId",
19491955
"None",
19501956
"Registry",
1957+
"RegistryAndPath",
19511958
"Repository",
19521959
"RepositoryName",
1960+
"RepositoryNameShort",
19531961
"RepositoryNameAndTag",
19541962
"Tag"
19551963
]
@@ -1967,8 +1975,10 @@
19671975
"FullTag",
19681976
"ImageId",
19691977
"Registry",
1978+
"RegistryAndPath",
19701979
"Repository",
19711980
"RepositoryName",
1981+
"RepositoryNameShort",
19721982
"RepositoryNameAndTag",
19731983
"Tag",
19741984
"Size"
@@ -1984,8 +1994,10 @@
19841994
"FullTag",
19851995
"ImageId",
19861996
"Registry",
1997+
"RegistryAndPath",
19871998
"Repository",
19881999
"RepositoryName",
2000+
"RepositoryNameShort",
19892001
"RepositoryNameAndTag",
19902002
"Tag",
19912003
"Size"

package.nls.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,17 @@
158158
"vscode-docker.config.template.composeDown.label": "The label displayed to the user.",
159159
"vscode-docker.config.template.composeDown.match": "The regular expression for choosing the right template. Checked against docker-compose YAML files, folder name, etc.",
160160
"vscode-docker.config.template.composeDown.description": "Command templates for `docker-compose down` commands.",
161-
"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",
161+
"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",
162162
"vscode-docker.config.docker.containers.groupByLabel": "The items will be grouped by the value of this container label (e.g. `com.microsoft.created-by`)",
163-
"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",
164-
"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",
163+
"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",
164+
"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",
165165
"vscode-docker.config.docker.containers.sortBy": "The property to use to sort containers in Docker view: CreatedTime or Label",
166166
"vscode-docker.config.docker.contexts.description": "Any secondary properties to display for a Docker context (an array). Possible elements include: Name, Description and DockerEndpoint",
167167
"vscode-docker.config.docker.contexts.label": "The primary property to display for a Docker context: Name, Description or DockerEndpoint",
168168
"vscode-docker.config.docker.contexts.showInStatusBar": "Show current Docker context in the status bar",
169-
"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",
170-
"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",
171-
"vscode-docker.config.docker.images.label": "The primary property to display for a image: CreatedTime, FullTag, ImageId, Registry, Repository, RepositoryName, RepositoryNameAndTag, Tag, or Size",
169+
"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",
170+
"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",
171+
"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",
172172
"vscode-docker.config.docker.images.sortBy": "The property to use to sort images in Docker view: CreatedTime, Label, or Size",
173173
"vscode-docker.config.docker.images.checkForOutdatedImages": "Check for outdated base images once per Visual Studio Code session",
174174
"vscode-docker.config.docker.networks.groupBy": "The property to use to group networks in Docker view: CreatedTime, NetworkDriver, NetworkId, NetworkName, or None",

src/tree/images/ImageProperties.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,27 @@ import { CommonGroupBy, CommonProperty, commonProperties, getCommonGroupIcon, ge
1111
import { ITreePropertyInfo } from '../settings/ITreeSettingInfo';
1212
import { NormalizedImageNameInfo } from "./NormalizedImageNameInfo";
1313

14-
export type ImageProperty = CommonProperty | 'FullTag' | 'ImageId' | 'Registry' | 'Repository' | 'RepositoryName' | 'RepositoryNameAndTag' | 'Tag';
14+
export type ImageProperty =
15+
| CommonProperty
16+
| 'FullTag'
17+
| 'ImageId'
18+
| 'Registry'
19+
| 'RegistryAndPath'
20+
| 'Repository'
21+
| 'RepositoryNameShort'
22+
| 'RepositoryName'
23+
| 'RepositoryNameAndTag'
24+
| 'Tag';
1525

1626
export const imageProperties: ITreePropertyInfo<ImageProperty>[] = [
1727
...commonProperties,
1828
{ property: 'FullTag', exampleValue: 'example.azurecr.io/hello-world:latest' },
1929
{ property: 'ImageId', exampleValue: 'd9d09edd6115' },
2030
{ property: 'Registry', exampleValue: 'example.azurecr.io' },
21-
{ property: 'Repository', exampleValue: 'example.azurecr.io/hello-world' },
22-
{ property: 'RepositoryName', exampleValue: 'hello-world' },
31+
{ property: 'RegistryAndPath', exampleValue: 'example.azurecr.io/my-path/hello-world' },
32+
{ property: 'Repository', exampleValue: 'example.azurecr.io' },
33+
{ property: 'RepositoryNameShort', exampleValue: 'hello-world' },
34+
{ property: 'RepositoryName', exampleValue: 'my-path/hello-world' },
2335
{ property: 'RepositoryNameAndTag', exampleValue: 'hello-world:latest' },
2436
{ property: 'Tag', exampleValue: 'latest' },
2537
{ property: 'Size', exampleValue: '27 MB' },
@@ -28,9 +40,11 @@ export const imageProperties: ITreePropertyInfo<ImageProperty>[] = [
2840
export function getImageGroupIcon(property: ImageProperty | CommonGroupBy): ThemeIcon {
2941
switch (property) {
3042
case 'Registry':
43+
case 'RegistryAndPath':
3144
return new ThemeIcon('briefcase');
3245
case 'Repository':
3346
case 'RepositoryName':
47+
case 'RepositoryNameShort':
3448
return new ThemeIcon('repo');
3549
case 'FullTag':
3650
case 'ImageId':
@@ -57,12 +71,18 @@ export function getImagePropertyValue(item: ListImagesItem, property: ImagePrope
5771
case 'Registry':
5872
result = normalizedImageNameInfo.normalizedRegistry;
5973
break;
74+
case 'RegistryAndPath':
75+
result = normalizedImageNameInfo.normalizedRegistryAndPath;
76+
break;
6077
case 'Repository':
6178
result = normalizedImageNameInfo.normalizedRegistryAndImageName;
6279
break;
6380
case 'RepositoryName':
6481
result = normalizedImageNameInfo.normalizedImageName;
6582
break;
83+
case 'RepositoryNameShort':
84+
result = normalizedImageNameInfo.normalizedImageShortName;
85+
break;
6686
case 'RepositoryNameAndTag':
6787
result = normalizedImageNameInfo.normalizedImageNameAndTag;
6888
break;

src/tree/images/NormalizedImageNameInfo.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ export class NormalizedImageNameInfo {
7070
return this.imageNameInfo.registry || 'docker.io';
7171
}
7272

73+
/**
74+
* Registry (if it is truthy), otherwise 'docker.io'
75+
*/
76+
public get normalizedRegistryAndPath(): string {
77+
if (this.normalizedRepositoryPath.length === 0) {
78+
return this.normalizedRegistry;
79+
}
80+
return this.normalizedRegistry + "/" + this.normalizedRepositoryPath;
81+
}
82+
83+
/**
84+
* The short image name or '<none>' if the image name is falsy
85+
*/
86+
public get normalizedImageShortName(): string {
87+
return this.normalizedImageName.split("/").pop() || noneTag;
88+
}
89+
90+
/**
91+
* The repository path or empty string if the image path is empty
92+
*/
93+
public get normalizedRepositoryPath(): string {
94+
return this.normalizedImageName.split("/").slice(0, -1).join("/");
95+
}
96+
7397
/**
7498
* Normalized registry + normalized image name
7599
*/

0 commit comments

Comments
 (0)