gitlab.azmi.pl/azmi-open-source/helm@v3.0.0-beta.3+incompatible/cmd/helm/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 main
    18  
    19  import (
    20  	"fmt"
    21  	"io"
    22  
    23  	"github.com/spf13/cobra"
    24  
    25  	"helm.sh/helm/cmd/helm/require"
    26  	"helm.sh/helm/pkg/action"
    27  )
    28  
    29  const pullDesc = `
    30  Retrieve a package from a package repository, and download it locally.
    31  
    32  This is useful for fetching packages to inspect, modify, or repackage. It can
    33  also be used to perform cryptographic verification of a chart without installing
    34  the chart.
    35  
    36  There are options for unpacking the chart after download. This will create a
    37  directory for the chart and uncompress into that directory.
    38  
    39  If the --verify flag is specified, the requested chart MUST have a provenance
    40  file, and MUST pass the verification process. Failure in any part of this will
    41  result in an error, and the chart will not be saved locally.
    42  `
    43  
    44  func newPullCmd(out io.Writer) *cobra.Command {
    45  	client := action.NewPull()
    46  
    47  	cmd := &cobra.Command{
    48  		Use:     "pull [chart URL | repo/chartname] [...]",
    49  		Short:   "download a chart from a repository and (optionally) unpack it in local directory",
    50  		Aliases: []string{"fetch"},
    51  		Long:    pullDesc,
    52  		Args:    require.MinimumNArgs(1),
    53  		RunE: func(cmd *cobra.Command, args []string) error {
    54  			client.Settings = settings
    55  			if client.Version == "" && client.Devel {
    56  				debug("setting version to >0.0.0-0")
    57  				client.Version = ">0.0.0-0"
    58  			}
    59  
    60  			for i := 0; i < len(args); i++ {
    61  				output, err := client.Run(args[i])
    62  				if err != nil {
    63  					return err
    64  				}
    65  				fmt.Fprint(out, output)
    66  			}
    67  			return nil
    68  		},
    69  	}
    70  
    71  	f := cmd.Flags()
    72  	f.BoolVar(&client.Devel, "devel", false, "use development versions, too. Equivalent to version '>0.0.0-0'. If --version is set, this is ignored.")
    73  	f.BoolVar(&client.Untar, "untar", false, "if set to true, will untar the chart after downloading it")
    74  	f.BoolVar(&client.VerifyLater, "prov", false, "fetch the provenance file, but don't perform verification")
    75  	f.StringVar(&client.UntarDir, "untardir", ".", "if untar is specified, this flag specifies the name of the directory into which the chart is expanded")
    76  	f.StringVarP(&client.DestDir, "destination", "d", ".", "location to write the chart. If this and tardir are specified, tardir is appended to this")
    77  	addChartPathOptionsFlags(f, &client.ChartPathOptions)
    78  
    79  	return cmd
    80  }