github.com/nickgerace/rancher-helm@v3.0.0-beta.3+incompatible/cmd/helm/dependency_update.go (about) 1 /* 2 Copyright The Helm Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package main 17 18 import ( 19 "io" 20 "path/filepath" 21 22 "github.com/spf13/cobra" 23 24 "helm.sh/helm/cmd/helm/require" 25 "helm.sh/helm/pkg/action" 26 "helm.sh/helm/pkg/downloader" 27 "helm.sh/helm/pkg/getter" 28 ) 29 30 const dependencyUpDesc = ` 31 Update the on-disk dependencies to mirror Chart.yaml. 32 33 This command verifies that the required charts, as expressed in 'Chart.yaml', 34 are present in 'charts/' and are at an acceptable version. It will pull down 35 the latest charts that satisfy the dependencies, and clean up old dependencies. 36 37 On successful update, this will generate a lock file that can be used to 38 rebuild the dependencies to an exact version. 39 40 Dependencies are not required to be represented in 'Chart.yaml'. For that 41 reason, an update command will not remove charts unless they are (a) present 42 in the Chart.yaml file, but (b) at the wrong version. 43 ` 44 45 // newDependencyUpdateCmd creates a new dependency update command. 46 func newDependencyUpdateCmd(out io.Writer) *cobra.Command { 47 client := action.NewDependency() 48 49 cmd := &cobra.Command{ 50 Use: "update CHART", 51 Aliases: []string{"up"}, 52 Short: "update charts/ based on the contents of Chart.yaml", 53 Long: dependencyUpDesc, 54 Args: require.MaximumNArgs(1), 55 RunE: func(cmd *cobra.Command, args []string) error { 56 chartpath := "." 57 if len(args) > 0 { 58 chartpath = filepath.Clean(args[0]) 59 } 60 man := &downloader.Manager{ 61 Out: out, 62 ChartPath: chartpath, 63 Keyring: client.Keyring, 64 SkipUpdate: client.SkipRefresh, 65 Getters: getter.All(settings), 66 RepositoryConfig: settings.RepositoryConfig, 67 RepositoryCache: settings.RepositoryCache, 68 Debug: settings.Debug, 69 } 70 if client.Verify { 71 man.Verify = downloader.VerifyAlways 72 } 73 return man.Update() 74 }, 75 } 76 77 f := cmd.Flags() 78 f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") 79 f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") 80 f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") 81 82 return cmd 83 }