github.com/Racer159/jackal@v0.32.7-0.20240401174413-0bd2339e4f2e/src/cmd/tools/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 /* 17 NOTICE: This file's 'package' and some functionality has been modified / removed to fit within Jackal's package structure. 18 */ 19 20 // Package helm is a copy of the main package from helm to include a subset of the helm CLI in Jackal 21 package helm 22 23 import ( 24 "io" 25 "path/filepath" 26 27 "github.com/spf13/cobra" 28 29 "helm.sh/helm/v3/cmd/helm/require" 30 "helm.sh/helm/v3/pkg/action" 31 "helm.sh/helm/v3/pkg/downloader" 32 "helm.sh/helm/v3/pkg/getter" 33 ) 34 35 const dependencyUpDesc = ` 36 Update the on-disk dependencies to mirror Chart.yaml. 37 38 This command verifies that the required charts, as expressed in 'Chart.yaml', 39 are present in 'charts/' and are at an acceptable version. It will pull down 40 the latest charts that satisfy the dependencies, and clean up old dependencies. 41 42 On successful update, this will generate a lock file that can be used to 43 rebuild the dependencies to an exact version. 44 45 Dependencies are not required to be represented in 'Chart.yaml'. For that 46 reason, an update command will not remove charts unless they are (a) present 47 in the Chart.yaml file, but (b) at the wrong version. 48 ` 49 50 // newDependencyUpdateCmd creates a new dependency update command. 51 func newDependencyUpdateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { 52 client := action.NewDependency() 53 54 cmd := &cobra.Command{ 55 Use: "update CHART", 56 Aliases: []string{"up"}, 57 Short: "update charts/ based on the contents of Chart.yaml", 58 Long: dependencyUpDesc, 59 Args: require.MaximumNArgs(1), 60 RunE: func(_ *cobra.Command, args []string) error { 61 chartpath := "." 62 if len(args) > 0 { 63 chartpath = filepath.Clean(args[0]) 64 } 65 man := &downloader.Manager{ 66 Out: out, 67 ChartPath: chartpath, 68 Keyring: client.Keyring, 69 SkipUpdate: client.SkipRefresh, 70 Getters: getter.All(settings), 71 RegistryClient: cfg.RegistryClient, 72 RepositoryConfig: settings.RepositoryConfig, 73 RepositoryCache: settings.RepositoryCache, 74 Debug: settings.Debug, 75 } 76 if client.Verify { 77 man.Verify = downloader.VerifyAlways 78 } 79 return man.Update() 80 }, 81 } 82 83 f := cmd.Flags() 84 f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures") 85 f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys") 86 f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache") 87 88 return cmd 89 }