@@ -87,12 +87,27 @@ func NewDryRunClient(apiClient client.APIClient, cli *command.DockerCli) (*DryRu
87
87
// All methods and functions which need to be overridden for dry run.
88
88
89
89
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" )
91
91
}
92
92
93
93
func (d * DryRunClient ) ContainerCreate (ctx context.Context , config * containerType.Config , hostConfig * containerType.HostConfig ,
94
94
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
96
111
}
97
112
98
113
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
108
123
}
109
124
110
125
func (d * DryRunClient ) ContainerRename (ctx context.Context , container , newContainerName string ) error {
111
- return ErrNotImplemented
126
+ return nil
112
127
}
113
128
114
129
func (d * DryRunClient ) ContainerRestart (ctx context.Context , container string , options containerType.StopOptions ) error {
115
130
return nil
116
131
}
117
132
118
133
func (d * DryRunClient ) ContainerStart (ctx context.Context , container string , options moby.ContainerStartOptions ) error {
119
- return ErrNotImplemented
134
+ return nil
120
135
}
121
136
122
137
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
185
200
}
186
201
187
202
func (d * DryRunClient ) NetworkConnect (ctx context.Context , networkName , container string , config * network.EndpointSettings ) error {
188
- return ErrNotImplemented
203
+ return nil
189
204
}
190
205
191
206
func (d * DryRunClient ) NetworkCreate (ctx context.Context , name string , options moby.NetworkCreate ) (moby.NetworkCreateResponse , error ) {
192
207
return moby.NetworkCreateResponse {}, ErrNotImplemented
193
208
}
194
209
195
210
func (d * DryRunClient ) NetworkDisconnect (ctx context.Context , networkName , container string , force bool ) error {
196
- return ErrNotImplemented
211
+ return nil
197
212
}
198
213
199
214
func (d * DryRunClient ) NetworkRemove (ctx context.Context , networkName string ) error {
@@ -275,10 +290,6 @@ func (d *DryRunClient) ContainerExport(ctx context.Context, container string) (i
275
290
return d .apiClient .ContainerExport (ctx , container )
276
291
}
277
292
278
- func (d * DryRunClient ) ContainerInspect (ctx context.Context , container string ) (moby.ContainerJSON , error ) {
279
- return d .apiClient .ContainerInspect (ctx , container )
280
- }
281
-
282
293
func (d * DryRunClient ) ContainerInspectWithRaw (ctx context.Context , container string , getSize bool ) (moby.ContainerJSON , []byte , error ) {
283
294
return d .apiClient .ContainerInspectWithRaw (ctx , container , getSize )
284
295
}
0 commit comments