@@ -53,7 +53,7 @@ type pullDryRunServiceResult struct {
53
53
Plan string
54
54
}
55
55
56
- type pullDrayRunView struct {
56
+ type pullDryRunResults struct {
57
57
Services []pullDryRunServiceResult
58
58
}
59
59
@@ -69,6 +69,23 @@ func (s *composeService) Pull(ctx context.Context, project *types.Project, opts
69
69
})
70
70
}
71
71
72
+ func (s * composeService ) pullDryRun (ctx context.Context , project * types.Project , opts api.PullOptions ) error {
73
+ results , err := s .pullDryRunSimulate (ctx , project , opts )
74
+ if err != nil {
75
+ return err
76
+ }
77
+ return formatter .Print (results , opts .Format , os .Stdout , func (w io.Writer ) {
78
+ for _ , service := range results .Services {
79
+ d := service .DistributionDigest
80
+ if d == "" {
81
+ // follow `docker images --digests` format
82
+ d = "<none>"
83
+ }
84
+ _ , _ = fmt .Fprintf (w , "%s\t %s\t %s\t %s\n " , service .Name , service .Image , service .Plan , d )
85
+ }
86
+ }, "SERVICE" , "IMAGE" , "PLAN" , "REMOTE DIGEST" )
87
+ }
88
+
72
89
func getEncodedRegistryAuth (image string , info moby.Info , configFile driver.Auth ) (string , error ) {
73
90
ref , err := reference .ParseNormalizedNamed (image )
74
91
if err != nil {
@@ -204,13 +221,13 @@ func getPullPlan(service types.ServiceConfig, localDigests []string, dstrDigest
204
221
return
205
222
}
206
223
207
- func (s * composeService ) pullDryRun (ctx context.Context , project * types.Project , opts api.PullOptions ) error {
224
+ func (s * composeService ) pullDryRunSimulate (ctx context.Context , project * types.Project , opts api.PullOptions ) ( * pullDryRunResults , error ) {
208
225
// ignore errors
209
226
dstrDigests , _ := s .getDistributionImagesDigests (ctx , project )
210
227
211
228
localDigests , err := s .getLocalImagesDigests (ctx , project )
212
229
if err != nil {
213
- return err
230
+ return nil , err
214
231
}
215
232
216
233
var results []pullDryRunServiceResult
@@ -232,20 +249,8 @@ func (s *composeService) pullDryRun(ctx context.Context, project *types.Project,
232
249
results = append (results , * result )
233
250
}
234
251
235
- view := & pullDrayRunView {
236
- Services : results ,
237
- }
252
+ return & pullDryRunResults {Services : results }, nil
238
253
239
- return formatter .Print (view , opts .Format , os .Stdout , func (w io.Writer ) {
240
- for _ , result := range results {
241
- d := result .DistributionDigest
242
- if d == "" {
243
- // follow `docker images --digests` format
244
- d = "<none>"
245
- }
246
- _ , _ = fmt .Fprintf (w , "%s\t %s\t %s\t %s\n " , result .Name , result .Image , result .Plan , d )
247
- }
248
- }, "SERVICE" , "IMAGE" , "PLAN" , "REMOTE DIGEST" )
249
254
}
250
255
251
256
func (s * composeService ) pullRequiredImages (ctx context.Context , project * types.Project , images map [string ]string , quietPull bool ) error {
0 commit comments