Skip to content

Commit 30f7abf

Browse files
authored
Add a client for Podman (#222)
1 parent 13fc9fa commit 30f7abf

24 files changed

+4663
-3840
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vscode-container-client/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.2.0 - 10 February 2025
2+
### Added
3+
* Added a client for Podman. [#221](https://github.com/microsoft/vscode-docker-extensibility/issues/221)
4+
5+
### Changed
6+
* Some properties on certain objects have become optional, due to Podman not containing them. For example, network ID on network listing is not present on Podman v3.
7+
18
## 0.1.2 - 1 August 2024
29
### Fixed
310
* Listing files fails due to new Bash behavior. [#231](https://github.com/microsoft/vscode-docker-extensibility/issues/231)

packages/vscode-container-client/NOTICE.html

Lines changed: 74 additions & 151 deletions
Large diffs are not rendered by default.

packages/vscode-container-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@microsoft/vscode-container-client",
33
"author": "Microsoft Corporation",
4-
"version": "0.1.2",
4+
"version": "0.2.0",
55
"description": "Extensibility model for implementing container runtime providers (shared by VS and VS Code)",
66
"license": "See LICENSE in the project root for license information.",
77
"repository": {

packages/vscode-container-client/src/clients/DockerClient/DockerClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class DockerClient extends DockerClientBase implements IContainersClient
4848
private getListContextsCommandArgs(options: ListContextsCommandOptions): CommandLineArgs {
4949
return composeArgs(
5050
withArg('context', 'ls'),
51-
withDockerJsonFormatArg,
51+
withDockerJsonFormatArg(this.defaultFormatForJson),
5252
)();
5353
}
5454

@@ -156,7 +156,7 @@ export class DockerClient extends DockerClientBase implements IContainersClient
156156
private getInspectContextsCommandArgs(options: InspectContextsCommandOptions): CommandLineArgs {
157157
return composeArgs(
158158
withArg('context', 'inspect'),
159-
withDockerJsonFormatArg,
159+
withDockerJsonFormatArg(this.defaultFormatForJson),
160160
withArg(...options.contexts),
161161
)();
162162
}

packages/vscode-container-client/src/clients/DockerClientBase/DockerClientBase.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,19 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
132132
*/
133133
public readonly defaultTag: string = 'latest';
134134

135+
/**
136+
* The default argument given to `--format`
137+
*/
138+
protected readonly defaultFormatForJson: string = "{{json .}}";
139+
135140
//#region Information Commands
136141

137142
protected getInfoCommandArgs(
138143
options: InfoCommandOptions,
139144
): CommandLineArgs {
140145
return composeArgs(
141146
withArg('info'),
142-
withDockerJsonFormatArg,
147+
withDockerJsonFormatArg(this.defaultFormatForJson),
143148
)();
144149
}
145150

@@ -173,7 +178,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
173178
protected getVersionCommandArgs(options: VersionCommandOptions): CommandLineArgs {
174179
return composeArgs(
175180
withArg('version'),
176-
withDockerJsonFormatArg,
181+
withDockerJsonFormatArg(this.defaultFormatForJson),
177182
)();
178183
}
179184

@@ -243,7 +248,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
243248
withDockerLabelFilterArgs(options.labels),
244249
withDockerFilterArg(options.types?.map((type) => `type=${type}`)),
245250
withDockerFilterArg(options.events?.map((event) => `event=${event}`)),
246-
withDockerJsonFormatArg,
251+
withDockerJsonFormatArg(this.defaultFormatForJson),
247252
)();
248253
}
249254

@@ -391,7 +396,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
391396
withDockerFilterArg(options.references?.map((reference) => `reference=${reference}`)),
392397
withDockerLabelFilterArgs(options.labels),
393398
withDockerNoTruncArg,
394-
withDockerJsonFormatArg,
399+
withDockerJsonFormatArg(this.defaultFormatForJson),
395400
)();
396401
}
397402

@@ -462,7 +467,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
462467

463468
protected getRemoveImagesCommandArgs(options: RemoveImagesCommandOptions): CommandLineArgs {
464469
return composeArgs(
465-
withArg('image', 'remove'),
470+
withArg('image', 'rm'), // Docker supports both `remove` and `rm`, but Podman supports only `rm`
466471
withFlagArg('--force', options.force),
467472
withArg(...options.imageRefs),
468473
)();
@@ -602,7 +607,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
602607
): CommandLineArgs {
603608
return composeArgs(
604609
withArg('image', 'inspect'),
605-
withDockerJsonFormatArg,
610+
withDockerJsonFormatArg(this.defaultFormatForJson),
606611
withArg(...options.imageRefs),
607612
)();
608613
}
@@ -770,7 +775,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
770775
withDockerFilterArg(options.volumes?.map((volume) => `volume=${volume}`)),
771776
withDockerFilterArg(options.networks?.map((network) => `network=${network}`)),
772777
withDockerNoTruncArg,
773-
withDockerJsonFormatArg,
778+
withDockerJsonFormatArg(this.defaultFormatForJson),
774779
withDockerIgnoreSizeArg,
775780
)();
776781
}
@@ -1046,7 +1051,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
10461051
): CommandLineArgs {
10471052
return composeArgs(
10481053
withArg('container', 'inspect'),
1049-
withDockerJsonFormatArg,
1054+
withDockerJsonFormatArg(this.defaultFormatForJson),
10501055
withArg(...options.containers)
10511056
)();
10521057
}
@@ -1117,7 +1122,6 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
11171122
withArg('volume', 'create'),
11181123
withNamedArg('--driver', options.driver),
11191124
withArg(options.name),
1120-
withDockerJsonFormatArg,
11211125
)();
11221126
}
11231127

@@ -1138,11 +1142,11 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
11381142
withDockerBooleanFilterArg('dangling', options.dangling),
11391143
withDockerFilterArg(options.driver ? `driver=${options.driver}` : undefined),
11401144
withDockerLabelFilterArgs(options.labels),
1141-
withDockerJsonFormatArg,
1145+
withDockerJsonFormatArg(this.defaultFormatForJson),
11421146
)();
11431147
}
11441148

1145-
protected async parseListVolumesCommandOputput(
1149+
protected async parseListVolumesCommandOutput(
11461150
options: ListVolumesCommandOptions,
11471151
output: string,
11481152
strict: boolean,
@@ -1198,7 +1202,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
11981202
return {
11991203
command: this.commandName,
12001204
args: this.getListVolumesCommandArgs(options),
1201-
parse: (output, strict) => this.parseListVolumesCommandOputput(options, output, strict),
1205+
parse: (output, strict) => this.parseListVolumesCommandOutput(options, output, strict),
12021206
};
12031207
}
12041208

@@ -1292,7 +1296,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
12921296
): CommandLineArgs {
12931297
return composeArgs(
12941298
withArg('volume', 'inspect'),
1295-
withDockerJsonFormatArg,
1299+
withDockerJsonFormatArg(this.defaultFormatForJson),
12961300
withArg(...options.volumes),
12971301
)();
12981302
}
@@ -1375,7 +1379,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
13751379
withArg('network', 'ls'),
13761380
withDockerLabelFilterArgs(options.labels),
13771381
withDockerNoTruncArg,
1378-
withDockerJsonFormatArg,
1382+
withDockerJsonFormatArg(this.defaultFormatForJson),
13791383
)();
13801384
}
13811385

@@ -1495,7 +1499,7 @@ export abstract class DockerClientBase extends ConfigurableClient implements ICo
14951499
): CommandLineArgs {
14961500
return composeArgs(
14971501
withArg('network', 'inspect'),
1498-
withDockerJsonFormatArg,
1502+
withDockerJsonFormatArg(this.defaultFormatForJson),
14991503
withArg(...options.networks),
15001504
)();
15011505
}

packages/vscode-container-client/src/clients/DockerClientBase/withDockerJsonFormatArg.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@
55

66
import { withNamedArg } from '../../utils/commandLineBuilder';
77

8-
export const withDockerJsonFormatArg = withNamedArg('--format', '{{json .}}');
8+
export function withDockerJsonFormatArg(jsonFormat: string = '{{json .}}') {
9+
return withNamedArg('--format', jsonFormat);
10+
}

0 commit comments

Comments
 (0)