github.com/zsuzhengdu/helm@v3.0.0-beta.3+incompatible/pkg/action/chart_pull.go (about)

     1  /*
     2  Copyright The Helm Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package action
    18  
    19  import (
    20  	"io"
    21  
    22  	"helm.sh/helm/internal/experimental/registry"
    23  )
    24  
    25  // ChartPull performs a chart pull operation.
    26  type ChartPull struct {
    27  	cfg *Configuration
    28  }
    29  
    30  // NewChartPull creates a new ChartPull object with the given configuration.
    31  func NewChartPull(cfg *Configuration) *ChartPull {
    32  	return &ChartPull{
    33  		cfg: cfg,
    34  	}
    35  }
    36  
    37  // Run executes the chart pull operation
    38  func (a *ChartPull) Run(out io.Writer, ref string) error {
    39  	r, err := registry.ParseReference(ref)
    40  	if err != nil {
    41  		return err
    42  	}
    43  	return a.cfg.RegistryClient.PullChart(r)
    44  }