|
|
|
@ -70,6 +70,8 @@ type Manager struct {
|
|
|
|
|
Keyring string
|
|
|
|
|
// SkipUpdate indicates that the repository should not be updated first.
|
|
|
|
|
SkipUpdate bool
|
|
|
|
|
// Update repos only in the chart.yaml
|
|
|
|
|
OptimizedUpdate bool
|
|
|
|
|
// Getter collection for the operation
|
|
|
|
|
Getters []getter.Provider
|
|
|
|
|
RegistryClient *registry.Client
|
|
|
|
@ -134,10 +136,17 @@ func (m *Manager) Build() error {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !m.SkipUpdate {
|
|
|
|
|
// For each repo in the file, update the cached copy of that repo
|
|
|
|
|
if !m.OptimizedUpdate {
|
|
|
|
|
if err := m.UpdateRepositories(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// For each repo in the file, update the cached copy of that repo
|
|
|
|
|
if err := m.UpdateRepositoriesInChart(c); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now we need to fetch every package here into charts/
|
|
|
|
@ -184,9 +193,17 @@ func (m *Manager) Update() error {
|
|
|
|
|
// For each of the repositories Helm is configured to know about, update
|
|
|
|
|
// the index information locally.
|
|
|
|
|
if !m.SkipUpdate {
|
|
|
|
|
if !m.OptimizedUpdate {
|
|
|
|
|
if err := m.UpdateRepositories(); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// For each repo in the file, update the cached copy of that repo
|
|
|
|
|
if err := m.UpdateRepositoriesInChart(c); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Now we need to find out which version of a chart best satisfies the
|
|
|
|
@ -648,18 +665,42 @@ func (m *Manager) UpdateRepositories() error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
repos := rf.Repositories
|
|
|
|
|
if len(repos) > 0 {
|
|
|
|
|
fmt.Fprintln(m.Out, "Hang tight while we grab the latest from your chart repositories...")
|
|
|
|
|
// This prints warnings straight to out.
|
|
|
|
|
if err := m.parallelRepoUpdate(repos); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintln(m.Out, "Update Complete. ⎈Happy Helming!⎈")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UpdateRepositoriesInChart updates only the local repos in the chart.yaml to the latest.
|
|
|
|
|
func (m *Manager) UpdateRepositoriesInChart(c *chart.Chart) error {
|
|
|
|
|
rf, err := loadRepoConfig(m.RepositoryConfig)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
repos := []*repo.Entry{}
|
|
|
|
|
// Map of repos in the chart yaml file
|
|
|
|
|
reposRequired := map[string]bool{}
|
|
|
|
|
for _, d := range c.Metadata.Dependencies {
|
|
|
|
|
reposRequired[d.Repository] = true
|
|
|
|
|
}
|
|
|
|
|
//Only updating repos in chart yaml
|
|
|
|
|
for _, e := range rf.Repositories {
|
|
|
|
|
if _, isMapContainsKey := reposRequired[e.URL]; isMapContainsKey {
|
|
|
|
|
repos = append(repos, e)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if err := m.parallelRepoUpdate(repos); err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
|
|
|
|
|
if len(repos) <= 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
fmt.Fprintln(m.Out, "Hang tight while we grab the latest from your chart repositories...")
|
|
|
|
|
// This prints warnings straight to out.
|
|
|
|
|
|
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
for _, c := range repos {
|
|
|
|
@ -692,6 +733,7 @@ func (m *Manager) parallelRepoUpdate(repos []*repo.Entry) error {
|
|
|
|
|
}
|
|
|
|
|
wg.Wait()
|
|
|
|
|
|
|
|
|
|
fmt.Fprintln(m.Out, "Update Complete. ⎈Happy Helming!⎈")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|