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