Skip to content

Commit

Permalink
Add networks information to containers (#1344)
Browse files Browse the repository at this point in the history
* Add networks information to containers to allow grouping by network
  • Loading branch information
stuartthomson authored and bwateratmsft committed Oct 14, 2019
1 parent 534e1b2 commit 127c5dd
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,7 @@
"CreatedTime",
"FullTag",
"ImageId",
"Networks",
"None",
"Ports",
"Registry",
Expand All @@ -1127,6 +1128,7 @@
"CreatedTime",
"FullTag",
"ImageId",
"Networks",
"Ports",
"Registry",
"Repository",
Expand All @@ -1148,6 +1150,7 @@
"CreatedTime",
"FullTag",
"ImageId",
"Networks",
"Ports",
"Registry",
"Repository",
Expand Down
3 changes: 3 additions & 0 deletions src/tree/containers/ContainerGroupTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export class ContainerGroupTreeItem extends LocalGroupTreeItemBase<LocalContaine
switch (this.parent.groupBySetting) {
case 'ContainerId':
case 'ContainerName':
case 'Networks':
icon = 'network';
break;
case 'Ports':
case 'Status':
icon = 'applicationGroup';
Expand Down
3 changes: 2 additions & 1 deletion src/tree/containers/ContainerProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { getThemedIconPath, IconPath } from "../IconPath";
import { imageProperties, ImageProperty } from "../images/ImageProperties";
import { ITreePropertyInfo } from "../settings/ITreeSettingInfo";

export type ContainerProperty = ImageProperty | 'ContainerId' | 'ContainerName' | 'Ports' | 'State' | 'Status';
export type ContainerProperty = ImageProperty | 'ContainerId' | 'ContainerName' | 'Networks' | 'Ports' | 'State' | 'Status';

export const containerProperties: ITreePropertyInfo<ContainerProperty>[] = [
...imageProperties,
{ property: 'ContainerId', exampleValue: 'fdeab20e859d' },
{ property: 'ContainerName', exampleValue: 'amazing_hoover' },
{ property: 'Networks', exampleValue: 'mybridge_network' },
{ property: 'Ports', exampleValue: '8080' },
{ property: 'State', exampleValue: 'exited' },
{ property: 'Status', exampleValue: 'Exited (0) 2 hours ago' }
Expand Down
2 changes: 2 additions & 0 deletions src/tree/containers/ContainersTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export class ContainersTreeItem extends LocalRootTreeItemBase<LocalContainerInfo
return item.containerId.slice(0, 12);
case 'ContainerName':
return item.containerName;
case 'Networks':
return item.networks.length > 0 ? item.networks.join(',') : '<none>';
case 'Ports':
return item.ports.length > 0 ? item.ports.join(',') : '<none>';
case 'State':
Expand Down
4 changes: 4 additions & 0 deletions src/tree/containers/LocalContainerInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export class LocalContainerInfo implements ILocalImageInfo {
return this.data.ImageID;
}

public get networks(): string[] {
return Object.keys(this.data.NetworkSettings.Networks);
}

public get ports(): number[] {
return this.data.Ports.map(p => p.PublicPort);
}
Expand Down

0 comments on commit 127c5dd

Please sign in to comment.