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)
| 263 | // |
| 264 | // TODO: replace reference package usage with simpler url.Parse semantics |
| 265 | func (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. |
| 320 | func (pm *Manager) List(pluginFilters filters.Args) ([]plugin.Plugin, error) { |
nothing calls this directly
no test coverage detected