Pull downloads a chart from a registry
(ref string, options ...PullOption)
| 556 | |
| 557 | // Pull downloads a chart from a registry |
| 558 | func (c *Client) Pull(ref string, options ...PullOption) (*PullResult, error) { |
| 559 | operation := &pullOperation{ |
| 560 | withChart: true, // By default, always download the chart layer |
| 561 | } |
| 562 | for _, option := range options { |
| 563 | option(operation) |
| 564 | } |
| 565 | if !operation.withChart && !operation.withProv { |
| 566 | return nil, errors.New( |
| 567 | "must specify at least one layer to pull (chart/prov)") |
| 568 | } |
| 569 | |
| 570 | // Build allowed media types for chart pull |
| 571 | allowedMediaTypes := []string{ |
| 572 | ocispec.MediaTypeImageIndex, |
| 573 | ocispec.MediaTypeImageManifest, |
| 574 | ConfigMediaType, |
| 575 | } |
| 576 | if operation.withChart { |
| 577 | allowedMediaTypes = append(allowedMediaTypes, ChartLayerMediaType, LegacyChartLayerMediaType) |
| 578 | } |
| 579 | if operation.withProv { |
| 580 | allowedMediaTypes = append(allowedMediaTypes, ProvLayerMediaType) |
| 581 | } |
| 582 | |
| 583 | // Use generic client for the pull operation |
| 584 | genericClient := c.Generic() |
| 585 | genericResult, err := genericClient.PullGeneric(ref, GenericPullOptions{ |
| 586 | AllowedMediaTypes: allowedMediaTypes, |
| 587 | }) |
| 588 | if err != nil { |
| 589 | return nil, err |
| 590 | } |
| 591 | |
| 592 | // Process the result with chart-specific logic |
| 593 | return c.processChartPull(genericResult, operation) |
| 594 | } |
| 595 | |
| 596 | // PullOptWithChart returns a function that sets the withChart setting on pull |
| 597 | func PullOptWithChart(withChart bool) PullOption { |