Merge pull request #6943 from hangpark/fix/resolve-repo-alias-before-build

fix(pkg/downloader): Resolve repo alias before checking digests on build
pull/6945/head
Matthew Fisher 5 years ago committed by GitHub
commit 9be2445da5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,7 +79,12 @@ func (m *Manager) Build() error {
return m.Update()
}
// Check that all of the repos we're dependent on actually exist.
req := c.Metadata.Dependencies
if _, err := m.resolveRepoNames(req); err != nil {
return err
}
if sum, err := resolver.HashReq(req, lock.Dependencies); err != nil || sum != lock.Digest {
return errors.New("Chart.lock is out of sync with Chart.yaml")
}
@ -120,7 +125,7 @@ func (m *Manager) Update() error {
// Check that all of the repos we're dependent on actually exist and
// the repo index names.
repoNames, err := m.getRepoNames(req)
repoNames, err := m.resolveRepoNames(req)
if err != nil {
return err
}
@ -372,8 +377,9 @@ Loop:
return nil
}
// getRepoNames returns the repo names of the referenced deps which can be used to fetch the cahced index file.
func (m *Manager) getRepoNames(deps []*chart.Dependency) (map[string]string, error) {
// resolveRepoNames returns the repo names of the referenced deps which can be used to fetch the cached index file
// and replaces aliased repository URLs into resolved URLs in dependencies.
func (m *Manager) resolveRepoNames(deps []*chart.Dependency) (map[string]string, error) {
rf, err := loadRepoConfig(m.RepositoryConfig)
if err != nil {
if os.IsNotExist(err) {

@ -161,7 +161,7 @@ func TestGetRepoNames(t *testing.T) {
}
for _, tt := range tests {
l, err := m.getRepoNames(tt.req)
l, err := m.resolveRepoNames(tt.req)
if err != nil {
if tt.err {
continue
@ -181,7 +181,8 @@ func TestGetRepoNames(t *testing.T) {
}
}
// This function is the skeleton test code of failing tests for #6416 and bugs due to #5874.
// This function is the skeleton test code of failing tests for #6416 and #6871 and bugs due to #5874.
//
// This function is used by below tests that ensures success of build operation
// with optional fields, alias, condition, tags, and even with ranged version.
// Parent chart includes local-subchart 0.1.0 subchart from a fake repository, by default.
@ -283,3 +284,11 @@ func TestBuild_WithTags(t *testing.T) {
Tags: []string{"tag1", "tag2"},
})
}
// Failing test for #6871
func TestBuild_WithRepositoryAlias(t *testing.T) {
// Dependency repository is aliased in Chart.yaml
checkBuildWithOptionalFields(t, "with-repository-alias", chart.Dependency{
Repository: "@test",
})
}

Loading…
Cancel
Save