@@ -24,6 +24,7 @@ import (
24
24
"io"
25
25
"net"
26
26
"net/http"
27
+ "runtime"
27
28
"strings"
28
29
"sync"
29
30
@@ -84,6 +85,12 @@ func NewDryRunClient(apiClient client.APIClient, cli *command.DockerCli) (*DryRu
84
85
}, nil
85
86
}
86
87
88
+ func getCallingFunction () string {
89
+ pc , _ , _ , _ := runtime .Caller (2 )
90
+ fullName := runtime .FuncForPC (pc ).Name ()
91
+ return fullName [strings .LastIndex (fullName , "." )+ 1 :]
92
+ }
93
+
87
94
// All methods and functions which need to be overridden for dry run.
88
95
89
96
func (d * DryRunClient ) ContainerAttach (ctx context.Context , container string , options moby.ContainerAttachOptions ) (moby.HijackedResponse , error ) {
@@ -162,7 +169,14 @@ func (d *DryRunClient) ImageBuild(ctx context.Context, reader io.Reader, options
162
169
}
163
170
164
171
func (d * DryRunClient ) ImageInspectWithRaw (ctx context.Context , imageName string ) (moby.ImageInspect , []byte , error ) {
165
- return moby.ImageInspect {ID : "dryRunId" }, nil , nil
172
+ caller := getCallingFunction ()
173
+ switch caller {
174
+ case "pullServiceImage" , "buildContainerVolumes" :
175
+ return moby.ImageInspect {ID : "dryRunId" }, nil , nil
176
+ default :
177
+ return d .apiClient .ImageInspectWithRaw (ctx , imageName )
178
+ }
179
+
166
180
}
167
181
168
182
func (d * DryRunClient ) ImagePull (ctx context.Context , ref string , options moby.ImagePullOptions ) (io.ReadCloser , error ) {
@@ -204,7 +218,10 @@ func (d *DryRunClient) NetworkConnect(ctx context.Context, networkName, containe
204
218
}
205
219
206
220
func (d * DryRunClient ) NetworkCreate (ctx context.Context , name string , options moby.NetworkCreate ) (moby.NetworkCreateResponse , error ) {
207
- return moby.NetworkCreateResponse {}, ErrNotImplemented
221
+ return moby.NetworkCreateResponse {
222
+ ID : name ,
223
+ Warning : "" ,
224
+ }, nil
208
225
}
209
226
210
227
func (d * DryRunClient ) NetworkDisconnect (ctx context.Context , networkName , container string , force bool ) error {
0 commit comments