MCPcopy
hub / github.com/docker/compose / pullServiceImage

Method pullServiceImage

pkg/compose/pull.go:176–256  ·  pkg/compose/pull.go::composeService.pullServiceImage
(ctx context.Context, service types.ServiceConfig, quietPull bool, defaultPlatform string)

Source from the content-addressed store, hash-verified

174}
175
176func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, quietPull bool, defaultPlatform string) (string, error) {
177 resource := "Image " + service.Image
178 s.events.On(newEvent(resource, api.Working, api.StatusPulling))
179 ref, err := reference.ParseNormalizedNamed(service.Image)
180 if err != nil {
181 return "", err
182 }
183
184 encodedAuth, err := encodedAuth(ref, s.configFile())
185 if err != nil {
186 return "", err
187 }
188
189 platform := service.Platform
190 if platform == "" {
191 platform = defaultPlatform
192 }
193
194 var ociPlatforms []ocispec.Platform
195 if platform != "" {
196 p, err := platforms.Parse(platform)
197 if err != nil {
198 return "", err
199 }
200 ociPlatforms = append(ociPlatforms, p)
201 }
202
203 stream, err := s.apiClient().ImagePull(ctx, service.Image, client.ImagePullOptions{
204 RegistryAuth: encodedAuth,
205 Platforms: ociPlatforms,
206 })
207
208 if ctx.Err() != nil {
209 s.events.On(api.Resource{
210 ID: resource,
211 Status: api.Warning,
212 Text: "Interrupted",
213 })
214 return "", nil
215 }
216
217 // check if it has an error and the service has a build section
218 // then the status should be warning instead of error
219 if err != nil && service.Build != nil {
220 s.events.On(api.Resource{
221 ID: resource,
222 Status: api.Warning,
223 Text: getUnwrappedErrorMessage(err),
224 })
225 return "", err
226 }
227
228 if err != nil {
229 s.events.On(errorEvent(resource, getUnwrappedErrorMessage(err)))
230 return "", err
231 }
232
233 dec := json.NewDecoder(stream)

Callers 2

pullMethod · 0.95
pullRequiredImagesMethod · 0.95

Calls 11

configFileMethod · 0.95
apiClientMethod · 0.95
newEventFunction · 0.85
encodedAuthFunction · 0.85
getUnwrappedErrorMessageFunction · 0.85
errorEventFunction · 0.85
toPullProgressEventFunction · 0.85
OnMethod · 0.65
ErrMethod · 0.65
ImagePullMethod · 0.45
ImageInspectMethod · 0.45

Tested by

no test coverage detected