fix(pkg/downloader): resolve repo alias before checking digests on build

`Update()` gets repo names before resolving a lock file by calling
`resolveRepoNames(req)`. But that method changes aliased repo URLs into
the actual URLs. That makes digests from `helm update` and `helm build`
be different for each other.

To make them in sync, setting actual (resolved) repo URLs into the
loaded chart during `helm build` is necessary. Thus, this commit adds an
extra step in the `Build()` implementation.

For comments, this commit also changes the name of `getRepoNames()` into
`resolveRepoNames()` to avoid misunderstanding since getters are
expected to not mutate their input data in general.

Signed-off-by: Hang Park <hangpark@kaist.ac.kr>
pull/7423/head v3.0.0
Hang Park 5 years ago committed by Matthew Fisher
parent bd47ae79e9
commit e29ce2a54e
No known key found for this signature in database
GPG Key ID: 92AA783CBAAE8E3B

@ -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

Loading…
Cancel
Save