github.com/sgoings/helm@v2.0.0-alpha.2.0.20170406211108-734e92851ac3+incompatible/cmd/helm/dependency_build.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 21 "github.com/spf13/cobra" 22 23 "k8s.io/helm/pkg/downloader" 24 "k8s.io/helm/pkg/helm/helmpath" 25 ) 26 27 const dependencyBuildDesc = ` 28 Build out the charts/ directory from the requirements.lock file. 29 30 Build is used to reconstruct a chart's dependencies to the state specified in 31 the lock file. This will not re-negotiate dependencies, as 'helm dependency update' 32 does. 33 34 If no lock file is found, 'helm dependency build' will mirror the behavior 35 of 'helm dependency update'. 36 ` 37 38 type dependencyBuildCmd struct { 39 out io.Writer 40 chartpath string 41 verify bool 42 keyring string 43 helmhome helmpath.Home 44 } 45 46 func newDependencyBuildCmd(out io.Writer) *cobra.Command { 47 dbc := &dependencyBuildCmd{ 48 out: out, 49 } 50 51 cmd := &cobra.Command{ 52 Use: "build [flags] CHART", 53 Short: "rebuild the charts/ directory based on the requirements.lock file", 54 Long: dependencyBuildDesc, 55 RunE: func(cmd *cobra.Command, args []string) error { 56 dbc.helmhome = helmpath.Home(homePath()) 57 dbc.chartpath = "." 58 59 if len(args) > 0 { 60 dbc.chartpath = args[0] 61 } 62 return dbc.run() 63 }, 64 } 65 66 f := cmd.Flags() 67 f.BoolVar(&dbc.verify, "verify", false, "verify the packages against signatures") 68 f.StringVar(&dbc.keyring, "keyring", defaultKeyring(), "keyring containing public keys") 69 70 return cmd 71 } 72 73 func (d *dependencyBuildCmd) run() error { 74 man := &downloader.Manager{ 75 Out: d.out, 76 ChartPath: d.chartpath, 77 HelmHome: d.helmhome, 78 Keyring: d.keyring, 79 } 80 if d.verify { 81 man.Verify = downloader.VerifyIfPossible 82 } 83 84 return man.Build() 85 }