github.com/kruglovmax/helm@v3.0.0-beta.3+incompatible/cmd/helm/dependency.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 ) 27 28 const dependencyDesc = ` 29 Manage the dependencies of a chart. 30 31 Helm charts store their dependencies in 'charts/'. For chart developers, it is 32 often easier to manage dependencies in 'Chart.yaml' which declares all 33 dependencies. 34 35 The dependency commands operate on that file, making it easy to synchronize 36 between the desired dependencies and the actual dependencies stored in the 37 'charts/' directory. 38 39 For example, this Chart.yaml declares two dependencies: 40 41 # Chart.yaml 42 dependencies: 43 - name: nginx 44 version: "1.2.3" 45 repository: "https://example.com/charts" 46 - name: memcached 47 version: "3.2.1" 48 repository: "https://another.example.com/charts" 49 50 51 The 'name' should be the name of a chart, where that name must match the name 52 in that chart's 'Chart.yaml' file. 53 54 The 'version' field should contain a semantic version or version range. 55 56 The 'repository' URL should point to a Chart Repository. Helm expects that by 57 appending '/index.yaml' to the URL, it should be able to retrieve the chart 58 repository's index. Note: 'repository' can be an alias. The alias must start 59 with 'alias:' or '@'. 60 61 Starting from 2.2.0, repository can be defined as the path to the directory of 62 the dependency charts stored locally. The path should start with a prefix of 63 "file://". For example, 64 65 # Chart.yaml 66 dependencies: 67 - name: nginx 68 version: "1.2.3" 69 repository: "file://../dependency_chart/nginx" 70 71 If the dependency chart is retrieved locally, it is not required to have the 72 repository added to helm by "helm add repo". Version matching is also supported 73 for this case. 74 ` 75 76 const dependencyListDesc = ` 77 List all of the dependencies declared in a chart. 78 79 This can take chart archives and chart directories as input. It will not alter 80 the contents of a chart. 81 82 This will produce an error if the chart cannot be loaded. 83 ` 84 85 func newDependencyCmd(out io.Writer) *cobra.Command { 86 cmd := &cobra.Command{ 87 Use: "dependency update|build|list", 88 Aliases: []string{"dep", "dependencies"}, 89 Short: "manage a chart's dependencies", 90 Long: dependencyDesc, 91 Args: require.NoArgs, 92 } 93 94 cmd.AddCommand(newDependencyListCmd(out)) 95 cmd.AddCommand(newDependencyUpdateCmd(out)) 96 cmd.AddCommand(newDependencyBuildCmd(out)) 97 98 return cmd 99 } 100 101 func newDependencyListCmd(out io.Writer) *cobra.Command { 102 client := action.NewDependency() 103 104 cmd := &cobra.Command{ 105 Use: "list CHART", 106 Aliases: []string{"ls"}, 107 Short: "list the dependencies for the given chart", 108 Long: dependencyListDesc, 109 Args: require.MaximumNArgs(1), 110 RunE: func(cmd *cobra.Command, args []string) error { 111 chartpath := "." 112 if len(args) > 0 { 113 chartpath = filepath.Clean(args[0]) 114 } 115 return client.List(chartpath, out) 116 }, 117 } 118 return cmd 119 }