feat(dependency): Add --skip-download-if-exists into dependency build/update

Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
pull/13242/head
Suleiman Dibirov 1 year ago
parent 1a06fe9901
commit 0cf7b19b21

@ -37,6 +37,7 @@ type Dependency struct {
Verify bool
Keyring string
SkipRefresh bool
SkipDownloadIfExists bool
ColumnWidth uint
Username string
Password string

@ -133,4 +133,5 @@ func addDependencySubcommandFlags(f *pflag.FlagSet, client *action.Dependency) {
f.BoolVar(&client.InsecureSkipTLSverify, "insecure-skip-tls-verify", false, "skip tls certificate checks for the chart download")
f.BoolVar(&client.PlainHTTP, "plain-http", false, "use insecure HTTP connections for the chart download")
f.StringVar(&client.CaFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
f.BoolVar(&client.SkipDownloadIfExists, "skip-download-if-exists", false, "skip download of the chart if it already exists in the charts directory")
}

@ -65,6 +65,7 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command {
ChartPath: chartpath,
Keyring: client.Keyring,
SkipUpdate: client.SkipRefresh,
SkipDownloadIfExists: client.SkipDownloadIfExists,
Getters: getter.All(settings),
RegistryClient: registryClient,
RepositoryConfig: settings.RepositoryConfig,

@ -69,6 +69,7 @@ func newDependencyUpdateCmd(_ *action.Configuration, out io.Writer) *cobra.Comma
ChartPath: chartpath,
Keyring: client.Keyring,
SkipUpdate: client.SkipRefresh,
SkipDownloadIfExists: client.SkipDownloadIfExists,
Getters: getter.All(settings),
RegistryClient: registryClient,
RepositoryConfig: settings.RepositoryConfig,

@ -70,6 +70,8 @@ type Manager struct {
Keyring string
// SkipUpdate indicates that the repository should not be updated first.
SkipUpdate bool
// SkipDownloadIfExists indicates that the chart should not be downloaded if it already exists.
SkipDownloadIfExists bool
// Getter collection for the operation
Getters []getter.Provider
RegistryClient *registry.Client
@ -326,6 +328,14 @@ func (m *Manager) downloadAll(deps []*chart.Dependency) error {
continue
}
if m.SkipDownloadIfExists {
name := filepath.Base(churl)
if _, err = os.Stat(filepath.Join(destPath, name)); err == nil {
fmt.Fprintf(m.Out, "Already exists locally %s from repo %s\n", dep.Name, dep.Repository)
continue
}
}
fmt.Fprintf(m.Out, "Downloading %s from repo %s\n", dep.Name, dep.Repository)
dl := ChartDownloader{

Loading…
Cancel
Save