Skip to content

Commit 67c9ecb

Browse files
authored
Merge pull request docker#10404 from glours/dry-run-run-support
add dry-run support to run command
2 parents 0b6133f + 72a61c0 commit 67c9ecb

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

pkg/api/dryrunclient.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,27 @@ func NewDryRunClient(apiClient client.APIClient, cli *command.DockerCli) (*DryRu
8787
// All methods and functions which need to be overridden for dry run.
8888

8989
func (d *DryRunClient) ContainerAttach(ctx context.Context, container string, options moby.ContainerAttachOptions) (moby.HijackedResponse, error) {
90-
return moby.HijackedResponse{}, ErrNotImplemented
90+
return moby.HijackedResponse{}, errors.New("interactive run is not supported in dry-run mode")
9191
}
9292

9393
func (d *DryRunClient) ContainerCreate(ctx context.Context, config *containerType.Config, hostConfig *containerType.HostConfig,
9494
networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (containerType.CreateResponse, error) {
95-
return containerType.CreateResponse{}, ErrNotImplemented
95+
return containerType.CreateResponse{ID: "dryRunId"}, nil
96+
}
97+
98+
func (d *DryRunClient) ContainerInspect(ctx context.Context, container string) (moby.ContainerJSON, error) {
99+
containerJSON, err := d.apiClient.ContainerInspect(ctx, container)
100+
if err != nil {
101+
return moby.ContainerJSON{
102+
ContainerJSONBase: &moby.ContainerJSONBase{
103+
ID: "dryRunId",
104+
},
105+
Mounts: nil,
106+
Config: &containerType.Config{},
107+
NetworkSettings: &moby.NetworkSettings{},
108+
}, nil
109+
}
110+
return containerJSON, err
96111
}
97112

98113
func (d *DryRunClient) ContainerKill(ctx context.Context, container, signal string) error {
@@ -108,15 +123,15 @@ func (d *DryRunClient) ContainerRemove(ctx context.Context, container string, op
108123
}
109124

110125
func (d *DryRunClient) ContainerRename(ctx context.Context, container, newContainerName string) error {
111-
return ErrNotImplemented
126+
return nil
112127
}
113128

114129
func (d *DryRunClient) ContainerRestart(ctx context.Context, container string, options containerType.StopOptions) error {
115130
return nil
116131
}
117132

118133
func (d *DryRunClient) ContainerStart(ctx context.Context, container string, options moby.ContainerStartOptions) error {
119-
return ErrNotImplemented
134+
return nil
120135
}
121136

122137
func (d *DryRunClient) ContainerStop(ctx context.Context, container string, options containerType.StopOptions) error {
@@ -185,15 +200,15 @@ func (d *DryRunClient) ImageRemove(ctx context.Context, imageName string, option
185200
}
186201

187202
func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, container string, config *network.EndpointSettings) error {
188-
return ErrNotImplemented
203+
return nil
189204
}
190205

191206
func (d *DryRunClient) NetworkCreate(ctx context.Context, name string, options moby.NetworkCreate) (moby.NetworkCreateResponse, error) {
192207
return moby.NetworkCreateResponse{}, ErrNotImplemented
193208
}
194209

195210
func (d *DryRunClient) NetworkDisconnect(ctx context.Context, networkName, container string, force bool) error {
196-
return ErrNotImplemented
211+
return nil
197212
}
198213

199214
func (d *DryRunClient) NetworkRemove(ctx context.Context, networkName string) error {
@@ -275,10 +290,6 @@ func (d *DryRunClient) ContainerExport(ctx context.Context, container string) (i
275290
return d.apiClient.ContainerExport(ctx, container)
276291
}
277292

278-
func (d *DryRunClient) ContainerInspect(ctx context.Context, container string) (moby.ContainerJSON, error) {
279-
return d.apiClient.ContainerInspect(ctx, container)
280-
}
281-
282293
func (d *DryRunClient) ContainerInspectWithRaw(ctx context.Context, container string, getSize bool) (moby.ContainerJSON, []byte, error) {
283294
return d.apiClient.ContainerInspectWithRaw(ctx, container, getSize)
284295
}

0 commit comments

Comments
 (0)