mirror of
https://github.com/helm/helm.git
synced 2026-08-05 07:30:46 +00:00
Merge pull request #4566 from adamreese/dev-v3-chartlock
ref(*): rename requirements.lock to Chart.lock
This commit is contained in:
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
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
|
||||
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{
|
||||
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,
|
||||
Args: require.MaximumNArgs(1),
|
||||
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,
|
||||
// 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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ package chart
|
||||
type Chart struct {
|
||||
// Metadata is the contents of the Chartfile.
|
||||
Metadata *Metadata
|
||||
// RequirementsLock is the contents of requirements.lock.
|
||||
RequirementsLock *RequirementsLock
|
||||
// LocK is the contents of Chart.lock.
|
||||
Lock *Lock
|
||||
// Templates for this chart.
|
||||
Templates []*File
|
||||
// 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 {
|
||||
return c, errors.Wrap(err, "cannot load Chart.yaml")
|
||||
}
|
||||
case f.Name == "requirements.lock":
|
||||
c.RequirementsLock = new(chart.RequirementsLock)
|
||||
if err := yaml.Unmarshal(f.Data, &c.RequirementsLock); err != nil {
|
||||
return c, errors.Wrap(err, "cannot load requirements.lock")
|
||||
case f.Name == "Chart.lock":
|
||||
c.Lock = new(chart.Lock)
|
||||
if err := yaml.Unmarshal(f.Data, &c.Lock); err != nil {
|
||||
return c, errors.Wrap(err, "cannot load Chart.lock")
|
||||
}
|
||||
case f.Name == "values.yaml":
|
||||
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 {
|
||||
t.Fatalf("Expected 2 Requirements.Dependency, got %d", len(c.Metadata.Requirements))
|
||||
}
|
||||
if len(c.RequirementsLock.Dependencies) != 2 {
|
||||
t.Fatalf("Expected 2 RequirementsLock.Dependency, got %d", len(c.RequirementsLock.Dependencies))
|
||||
if len(c.Lock.Dependencies) != 2 {
|
||||
t.Fatalf("Expected 2 Lock.Dependency, got %d", len(c.Lock.Dependencies))
|
||||
}
|
||||
|
||||
for _, dep := range c.Dependencies() {
|
||||
|
||||
BIN
pkg/chart/loader/testdata/frobnitz-1.2.3.tgz
vendored
BIN
pkg/chart/loader/testdata/frobnitz-1.2.3.tgz
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -49,10 +49,10 @@ type Dependency struct {
|
||||
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.
|
||||
type RequirementsLock struct {
|
||||
type Lock struct {
|
||||
// Genderated is the date the lock file was last generated.
|
||||
Generated time.Time `json:"generated"`
|
||||
// Digest is a hash of the requirements file used to generate it.
|
||||
|
||||
@@ -35,12 +35,12 @@ func TestLoadRequirements(t *testing.T) {
|
||||
verifyRequirements(t, c)
|
||||
}
|
||||
|
||||
func TestLoadRequirementsLock(t *testing.T) {
|
||||
func TestLoadChartLock(t *testing.T) {
|
||||
c, err := loader.Load("testdata/frobnitz")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to load testdata: %s", err)
|
||||
}
|
||||
verifyRequirementsLock(t, c)
|
||||
verifyChartLock(t, c)
|
||||
}
|
||||
|
||||
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 {
|
||||
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
|
||||
// an update.
|
||||
lock := c.RequirementsLock
|
||||
lock := c.Lock
|
||||
if lock == nil {
|
||||
return m.Update()
|
||||
}
|
||||
|
||||
req := c.Metadata.Requirements
|
||||
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.
|
||||
@@ -155,7 +155,7 @@ func (m *Manager) Update() error {
|
||||
}
|
||||
|
||||
// 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 {
|
||||
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.
|
||||
//
|
||||
// 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)
|
||||
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
|
||||
func writeLock(chartpath string, lock *chart.RequirementsLock) error {
|
||||
func writeLock(chartpath string, lock *chart.Lock) error {
|
||||
data, err := yaml.Marshal(lock)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dest := filepath.Join(chartpath, "requirements.lock")
|
||||
dest := filepath.Join(chartpath, "Chart.lock")
|
||||
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.
|
||||
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.
|
||||
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 {
|
||||
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(),
|
||||
Digest: d,
|
||||
Dependencies: locked,
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestResolve(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
req []*chart.Dependency
|
||||
expect *chart.RequirementsLock
|
||||
expect *chart.Lock
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
@@ -61,7 +61,7 @@ func TestResolve(t *testing.T) {
|
||||
req: []*chart.Dependency{
|
||||
{Name: "alpine", Repository: "http://example.com", Version: ">=0.1.0"},
|
||||
},
|
||||
expect: &chart.RequirementsLock{
|
||||
expect: &chart.Lock{
|
||||
Dependencies: []*chart.Dependency{
|
||||
{Name: "alpine", Repository: "http://example.com", Version: "0.2.0"},
|
||||
},
|
||||
@@ -72,7 +72,7 @@ func TestResolve(t *testing.T) {
|
||||
req: []*chart.Dependency{
|
||||
{Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"},
|
||||
},
|
||||
expect: &chart.RequirementsLock{
|
||||
expect: &chart.Lock{
|
||||
Dependencies: []*chart.Dependency{
|
||||
{Name: "signtest", Repository: "file://../../../../cmd/helm/testdata/testcharts/signtest", Version: "0.1.0"},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user