MCPcopy
hub / github.com/moby/moby / Pull

Method Pull

daemon/pkg/plugin/backend_linux.go:265–317  ·  view source on GitHub ↗

Pull pulls a plugin, check if the correct privileges are provided and install the plugin. TODO: replace reference package usage with simpler url.Parse semantics

(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges plugin.Privileges, outStream io.Writer, opts ...CreateOpt)

Source from the content-addressed store, hash-verified

263//
264// TODO: replace reference package usage with simpler url.Parse semantics
265func (pm *Manager) Pull(ctx context.Context, ref reference.Named, name string, metaHeader http.Header, authConfig *registry.AuthConfig, privileges plugin.Privileges, outStream io.Writer, opts ...CreateOpt) error {
266 pm.muGC.RLock()
267 defer pm.muGC.RUnlock()
268
269 // revalidate because Pull is public
270 nameref, err := reference.ParseNormalizedNamed(name)
271 if err != nil {
272 return errors.Wrapf(errdefs.InvalidParameter(err), "failed to parse %q", name)
273 }
274 name = reference.FamiliarString(reference.TagNameOnly(nameref))
275
276 if err := pm.config.Store.validateName(name); err != nil {
277 return errdefs.InvalidParameter(err)
278 }
279
280 tmpRootFSDir, err := os.MkdirTemp(pm.tmpDir(), ".rootfs")
281 if err != nil {
282 return errors.Wrap(errdefs.System(err), "error preparing upgrade")
283 }
284 defer os.RemoveAll(tmpRootFSDir)
285
286 var md fetchMeta
287
288 ctx, cancel := context.WithCancel(ctx)
289 out, waitProgress := setupProgressOutput(outStream, cancel)
290 defer waitProgress()
291
292 if err := pm.fetch(ctx, ref, authConfig, out, metaHeader, storeFetchMetadata(&md), childrenHandler(pm.blobStore), applyLayer(pm.blobStore, tmpRootFSDir, out)); err != nil {
293 return err
294 }
295 pm.config.LogPluginEvent(reference.FamiliarString(ref), name, events.ActionPull)
296
297 if err := validateFetchedMetadata(md); err != nil {
298 return err
299 }
300
301 refOpt := func(p *v2.Plugin) {
302 p.PluginObj.PluginReference = ref.String()
303 }
304 optsList := make([]CreateOpt, 0, len(opts)+1)
305 optsList = append(optsList, opts...)
306 optsList = append(optsList, refOpt)
307
308 // TODO: tmpRootFSDir is empty but should have layers in it
309 p, err := pm.createPlugin(name, md.config, md.manifest, md.blobs, tmpRootFSDir, &privileges, optsList...)
310 if err != nil {
311 return err
312 }
313
314 pm.publisher.Publish(EventCreate{Plugin: p.PluginObj})
315
316 return nil
317}
318
319// List displays the list of plugins and associated metadata.
320func (pm *Manager) List(pluginFilters filters.Args) ([]plugin.Plugin, error) {

Callers

nothing calls this directly

Calls 14

tmpDirMethod · 0.95
fetchMethod · 0.95
createPluginMethod · 0.95
InvalidParameterFunction · 0.92
SystemFunction · 0.92
setupProgressOutputFunction · 0.85
storeFetchMetadataFunction · 0.85
childrenHandlerFunction · 0.85
applyLayerFunction · 0.85
validateFetchedMetadataFunction · 0.85
RemoveAllMethod · 0.80
LogPluginEventMethod · 0.80

Tested by

no test coverage detected