github.com/sgoings/helm@v2.0.0-alpha.2.0.20170406211108-734e92851ac3+incompatible/cmd/helm/dependency_update.go (about) 1 /* 2 Copyright 2016 The Kubernetes Authors All rights reserved. 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 "k8s.io/helm/pkg/downloader" 24 "k8s.io/helm/pkg/helm/helmpath" 25 ) 26 27 const dependencyUpDesc = ` 28 Update the on-disk dependencies to mirror the requirements.yaml file. 29 30 This command verifies that the required charts, as expressed in 'requirements.yaml', 31 are present in 'charts/' and are at an acceptable version. It will pull down 32 the latest charts that satisfy the dependencies, and clean up old dependencies. 33 34 On successful update, this will generate a lock file that can be used to 35 rebuild the requirements to an exact version. 36 37 Dependencies are not required to be represented in 'requirements.yaml'. For that 38 reason, an update command will not remove charts unless they are (a) present 39 in the requirements.yaml file, but (b) at the wrong version. 40 ` 41 42 // dependencyUpdateCmd describes a 'helm dependency update' 43 type dependencyUpdateCmd struct { 44 out io.Writer 45 chartpath string 46 helmhome helmpath.Home 47 verify bool 48 keyring string 49 skipRefresh bool 50 } 51 52 // newDependencyUpdateCmd creates a new dependency update command. 53 func newDependencyUpdateCmd(out io.Writer) *cobra.Command { 54 duc := &dependencyUpdateCmd{ 55 out: out, 56 } 57 58 cmd := &cobra.Command{ 59 Use: "update [flags] CHART", 60 Aliases: []string{"up"}, 61 Short: "update charts/ based on the contents of requirements.yaml", 62 Long: dependencyUpDesc, 63 RunE: func(cmd *cobra.Command, args []string) error { 64 cp := "." 65 if len(args) > 0 { 66 cp = args[0] 67 } 68 69 var err error 70 duc.chartpath, err = filepath.Abs(cp) 71 if err != nil { 72 return err 73 } 74 75 duc.helmhome = helmpath.Home(homePath()) 76 77 return duc.run() 78 }, 79 } 80 81 f := cmd.Flags() 82 f.BoolVar(&duc.verify, "verify", false, "verify the packages against signatures") 83 f.StringVar(&duc.keyring, "keyring", defaultKeyring(), "keyring containing public keys") 84 f.BoolVar(&duc.skipRefresh, "skip-refresh", false, "do not refresh the local repository cache") 85 86 return cmd 87 } 88 89 // run runs the full dependency update process. 90 func (d *dependencyUpdateCmd) run() error { 91 man := &downloader.Manager{ 92 Out: d.out, 93 ChartPath: d.chartpath, 94 HelmHome: d.helmhome, 95 Keyring: d.keyring, 96 SkipUpdate: d.skipRefresh, 97 } 98 if d.verify { 99 man.Verify = downloader.VerifyIfPossible 100 } 101 if flagDebug { 102 man.Debug = true 103 } 104 return man.Update() 105 }