// Update updates a local charts directory. // // It first reads the requirements.yaml file, and then attempts to // negotiate versions based on that. It will download the versions // from remote chart repositories. func (m *Manager) Update() error { c, err := m.loadChartDir() if err != nil { return err } // If no requirements file is found, we consider this a successful // completion. req, err := chartutil.LoadRequirements(c) if err != nil { if err == chartutil.ErrRequirementsNotFound { fmt.Fprintf(m.Out, "No requirements found in %s/charts.\n", m.ChartPath) return nil } return err } // Check that all of the repos we're dependent on actually exist and // the repo index names. repoNames, err := m.getRepoNames(req.Dependencies) if err != nil { return err } // For each repo in the file, update the cached copy of that repo if err := m.UpdateRepositories(); err != nil { return err } // Now we need to find out which version of a chart best satisfies the // requirements the requirements.yaml lock, err := m.resolve(req, repoNames) if err != nil { return err } // Now we need to fetch every package here into charts/ if err := m.downloadAll(lock.Dependencies); err != nil { return err } // If the lock file hasn't changed, don't write a new one. oldLock, err := chartutil.LoadRequirementsLock(c) if err == nil && oldLock.Digest == lock.Digest { return nil } // Finally, we need to write the lockfile. return writeLock(m.ChartPath, lock) }
func (l *dependencyListCmd) run() error { c, err := chartutil.Load(l.chartpath) if err != nil { return err } r, err := chartutil.LoadRequirements(c) if err != nil { if err == chartutil.ErrRequirementsNotFound { fmt.Fprintf(l.out, "WARNING: no requirements at %s/charts", l.chartpath) return nil } return err } l.printRequirements(r, l.out) fmt.Fprintln(l.out) l.printMissing(r, l.out) return nil }
// Build rebuilds a local charts directory from a lockfile. // // If the lockfile is not present, this will run a Manager.Update() func (m *Manager) Build() error { c, err := m.loadChartDir() if err != nil { return err } // If a lock file is found, run a build from that. Otherwise, just do // an update. lock, err := chartutil.LoadRequirementsLock(c) if err != nil { return m.Update() } // A lock must accompany a requirements.yaml file. req, err := chartutil.LoadRequirements(c) if err != nil { return fmt.Errorf("requirements.yaml cannot be opened: %s", err) } if sum, err := resolver.HashReq(req); err != nil || sum != lock.Digest { return fmt.Errorf("requirements.lock is out of sync with requirements.yaml") } // Check that all of the repos we're dependent on actually exist. if err := m.hasAllRepos(lock.Dependencies); err != nil { return err } // For each repo in the file, update the cached copy of that repo if err := m.UpdateRepositories(); err != nil { return err } // Now we need to fetch every package here into charts/ if err := m.downloadAll(lock.Dependencies); err != nil { return err } return nil }