ref(*): rename requirements.lock to Chart.lock

Signed-off-by: Adam Reese <adam@reese.io>
pull/4566/head
Adam Reese 7 years ago
parent 0d9a226fd9
commit 21259507bd
No known key found for this signature in database
GPG Key ID: 06F35E60A7A18DD6

@ -26,7 +26,7 @@ import (
) )
const dependencyBuildDesc = ` const dependencyBuildDesc = `
Build out the charts/ directory from the requirements.lock file. Build out the charts/ directory from the Chart.lock file.
Build is used to reconstruct a chart's dependencies to the state specified in Build is used to reconstruct a chart's dependencies to the state specified in
the lock file. This will not re-negotiate dependencies, as 'helm dependency update' the lock file. This will not re-negotiate dependencies, as 'helm dependency update'
@ -50,7 +50,7 @@ func newDependencyBuildCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "build CHART", Use: "build CHART",
Short: "rebuild the charts/ directory based on the requirements.lock file", Short: "rebuild the charts/ directory based on the Chart.lock file",
Long: dependencyBuildDesc, Long: dependencyBuildDesc,
Args: require.MaximumNArgs(1), Args: require.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {

@ -64,7 +64,7 @@ func TestDependencyBuildCmd(t *testing.T) {
// In the second pass, we want to remove the chart's request dependency, // In the second pass, we want to remove the chart's request dependency,
// then see if it restores from the lock. // then see if it restores from the lock.
lockfile := hh.Path(chartname, "requirements.lock") lockfile := hh.Path(chartname, "Chart.lock")
if _, err := os.Stat(lockfile); err != nil { if _, err := os.Stat(lockfile); err != nil {
t.Fatal(err) t.Fatal(err)
} }

@ -20,8 +20,8 @@ package chart
type Chart struct { type Chart struct {
// Metadata is the contents of the Chartfile. // Metadata is the contents of the Chartfile.
Metadata *Metadata Metadata *Metadata
// RequirementsLock is the contents of requirements.lock. // LocK is the contents of Chart.lock.
RequirementsLock *RequirementsLock Lock *Lock
// Templates for this chart. // Templates for this chart.
Templates []*File Templates []*File
// TODO Delete RawValues after unit tests for `create` are refactored. // TODO Delete RawValues after unit tests for `create` are refactored.

@ -77,10 +77,10 @@ func LoadFiles(files []*BufferedFile) (*chart.Chart, error) {
if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil { if err := yaml.Unmarshal(f.Data, c.Metadata); err != nil {
return c, errors.Wrap(err, "cannot load Chart.yaml") return c, errors.Wrap(err, "cannot load Chart.yaml")
} }
case f.Name == "requirements.lock": case f.Name == "Chart.lock":
c.RequirementsLock = new(chart.RequirementsLock) c.Lock = new(chart.Lock)
if err := yaml.Unmarshal(f.Data, &c.RequirementsLock); err != nil { if err := yaml.Unmarshal(f.Data, &c.Lock); err != nil {
return c, errors.Wrap(err, "cannot load requirements.lock") return c, errors.Wrap(err, "cannot load Chart.lock")
} }
case f.Name == "values.yaml": case f.Name == "values.yaml":
c.Values = make(map[string]interface{}) c.Values = make(map[string]interface{})

@ -248,8 +248,8 @@ func verifyChartFileAndTemplate(t *testing.T, c *chart.Chart, name string) {
if len(c.Metadata.Requirements) != 2 { if len(c.Metadata.Requirements) != 2 {
t.Fatalf("Expected 2 Requirements.Dependency, got %d", len(c.Metadata.Requirements)) t.Fatalf("Expected 2 Requirements.Dependency, got %d", len(c.Metadata.Requirements))
} }
if len(c.RequirementsLock.Dependencies) != 2 { if len(c.Lock.Dependencies) != 2 {
t.Fatalf("Expected 2 RequirementsLock.Dependency, got %d", len(c.RequirementsLock.Dependencies)) t.Fatalf("Expected 2 Lock.Dependency, got %d", len(c.Lock.Dependencies))
} }
for _, dep := range c.Dependencies() { for _, dep := range c.Dependencies() {

Binary file not shown.

@ -49,10 +49,10 @@ type Dependency struct {
Alias string `json:"alias,omitempty"` Alias string `json:"alias,omitempty"`
} }
// RequirementsLock is a lock file for requirements. // Lock is a lock file for requirements.
// //
// It represents the state that the dependencies should be in. // It represents the state that the dependencies should be in.
type RequirementsLock struct { type Lock struct {
// Genderated is the date the lock file was last generated. // Genderated is the date the lock file was last generated.
Generated time.Time `json:"generated"` Generated time.Time `json:"generated"`
// Digest is a hash of the requirements file used to generate it. // Digest is a hash of the requirements file used to generate it.

@ -35,12 +35,12 @@ func TestLoadRequirements(t *testing.T) {
verifyRequirements(t, c) verifyRequirements(t, c)
} }
func TestLoadRequirementsLock(t *testing.T) { func TestLoadChartLock(t *testing.T) {
c, err := loader.Load("testdata/frobnitz") c, err := loader.Load("testdata/frobnitz")
if err != nil { if err != nil {
t.Fatalf("Failed to load testdata: %s", err) t.Fatalf("Failed to load testdata: %s", err)
} }
verifyRequirementsLock(t, c) verifyChartLock(t, c)
} }
func TestRequirementsEnabled(t *testing.T) { func TestRequirementsEnabled(t *testing.T) {
@ -426,7 +426,7 @@ func verifyRequirements(t *testing.T, c *chart.Chart) {
} }
} }
func verifyRequirementsLock(t *testing.T, c *chart.Chart) { func verifyChartLock(t *testing.T, c *chart.Chart) {
if len(c.Metadata.Requirements) != 2 { if len(c.Metadata.Requirements) != 2 {
t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements)) t.Errorf("Expected 2 requirements, got %d", len(c.Metadata.Requirements))
} }

@ -73,14 +73,14 @@ func (m *Manager) Build() error {
// If a lock file is found, run a build from that. Otherwise, just do // If a lock file is found, run a build from that. Otherwise, just do
// an update. // an update.
lock := c.RequirementsLock lock := c.Lock
if lock == nil { if lock == nil {
return m.Update() return m.Update()
} }
req := c.Metadata.Requirements req := c.Metadata.Requirements
if sum, err := resolver.HashReq(req); err != nil || sum != lock.Digest { if sum, err := resolver.HashReq(req); err != nil || sum != lock.Digest {
return errors.New("requirements.lock is out of sync with Chart.yaml") return errors.New("Chart.lock is out of sync with Chart.yaml")
} }
// Check that all of the repos we're dependent on actually exist. // Check that all of the repos we're dependent on actually exist.
@ -155,7 +155,7 @@ func (m *Manager) Update() error {
} }
// If the lock file hasn't changed, don't write a new one. // If the lock file hasn't changed, don't write a new one.
oldLock := c.RequirementsLock oldLock := c.Lock
if oldLock != nil && oldLock.Digest == lock.Digest { if oldLock != nil && oldLock.Digest == lock.Digest {
return nil return nil
} }
@ -176,7 +176,7 @@ func (m *Manager) loadChartDir() (*chart.Chart, error) {
// resolve takes a list of requirements and translates them into an exact version to download. // resolve takes a list of requirements and translates them into an exact version to download.
// //
// This returns a lock file, which has all of the requirements normalized to a specific version. // This returns a lock file, which has all of the requirements normalized to a specific version.
func (m *Manager) resolve(req []*chart.Dependency, repoNames map[string]string, hash string) (*chart.RequirementsLock, error) { func (m *Manager) resolve(req []*chart.Dependency, repoNames map[string]string, hash string) (*chart.Lock, error) {
res := resolver.New(m.ChartPath, m.HelmHome) res := resolver.New(m.ChartPath, m.HelmHome)
return res.Resolve(req, repoNames, hash) return res.Resolve(req, repoNames, hash)
} }
@ -585,12 +585,12 @@ func (m *Manager) loadChartRepositories() (map[string]*repo.ChartRepository, err
} }
// writeLock writes a lockfile to disk // writeLock writes a lockfile to disk
func writeLock(chartpath string, lock *chart.RequirementsLock) error { func writeLock(chartpath string, lock *chart.Lock) error {
data, err := yaml.Marshal(lock) data, err := yaml.Marshal(lock)
if err != nil { if err != nil {
return err return err
} }
dest := filepath.Join(chartpath, "requirements.lock") dest := filepath.Join(chartpath, "Chart.lock")
return ioutil.WriteFile(dest, data, 0644) return ioutil.WriteFile(dest, data, 0644)
} }

@ -47,7 +47,7 @@ func New(chartpath string, helmhome helmpath.Home) *Resolver {
} }
// Resolve resolves dependencies and returns a lock file with the resolution. // Resolve resolves dependencies and returns a lock file with the resolution.
func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string, d string) (*chart.RequirementsLock, error) { func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string, d string) (*chart.Lock, error) {
// Now we clone the dependencies, locking as we go. // Now we clone the dependencies, locking as we go.
locked := make([]*chart.Dependency, len(reqs)) locked := make([]*chart.Dependency, len(reqs))
@ -107,7 +107,7 @@ func (r *Resolver) Resolve(reqs []*chart.Dependency, repoNames map[string]string
if len(missing) > 0 { if len(missing) > 0 {
return nil, errors.Errorf("can't get a valid version for repositories %s. Try changing the version constraint in Chart.yaml", strings.Join(missing, ", ")) return nil, errors.Errorf("can't get a valid version for repositories %s. Try changing the version constraint in Chart.yaml", strings.Join(missing, ", "))
} }
return &chart.RequirementsLock{ return &chart.Lock{
Generated: time.Now(), Generated: time.Now(),
Digest: d, Digest: d,
Dependencies: locked, Dependencies: locked,

@ -25,7 +25,7 @@ func TestResolve(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
req []*chart.Dependency req []*chart.Dependency
expect *chart.RequirementsLock expect *chart.Lock
err bool err bool
}{ }{
{ {
@ -61,7 +61,7 @@ func TestResolve(t *testing.T) {
req: []*chart.Dependency{ req: []*chart.Dependency{
{Name: "alpine", Repository: "http://example.com", Version: ">=0.1.0"}, {Name: "alpine", Repository: "http://example.com", Version: ">=0.1.0"},
}, },
expect: &chart.RequirementsLock{ expect: &chart.Lock{
Dependencies: []*chart.Dependency{ Dependencies: []*chart.Dependency{
{Name: "alpine", Repository: "http://example.com", Version: "0.2.0"}, {Name: "alpine", Repository: "http://example.com", Version: "0.2.0"},
}, },
@ -72,7 +72,7 @@ func TestResolve(t *testing.T) {
req: []*chart.Dependency{ req: []*chart.Dependency{
{Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"}, {Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"},
}, },
expect: &chart.RequirementsLock{ expect: &chart.Lock{
Dependencies: []*chart.Dependency{ Dependencies: []*chart.Dependency{
{Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"}, {Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"},
}, },

Loading…
Cancel
Save