Skip to content

Commit e29ce2a

Browse files
hangparkMatthew Fisher
authored andcommitted
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>
1 parent bd47ae7 commit e29ce2a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

pkg/downloader/manager.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,12 @@ func (m *Manager) Build() error {
7979
return m.Update()
8080
}
8181

82+
// Check that all of the repos we're dependent on actually exist.
8283
req := c.Metadata.Dependencies
84+
if _, err := m.resolveRepoNames(req); err != nil {
85+
return err
86+
}
87+
8388
if sum, err := resolver.HashReq(req, lock.Dependencies); err != nil || sum != lock.Digest {
8489
return errors.New("Chart.lock is out of sync with Chart.yaml")
8590
}
@@ -120,7 +125,7 @@ func (m *Manager) Update() error {
120125

121126
// Check that all of the repos we're dependent on actually exist and
122127
// the repo index names.
123-
repoNames, err := m.getRepoNames(req)
128+
repoNames, err := m.resolveRepoNames(req)
124129
if err != nil {
125130
return err
126131
}
@@ -372,8 +377,9 @@ Loop:
372377
return nil
373378
}
374379

375-
// getRepoNames returns the repo names of the referenced deps which can be used to fetch the cahced index file.
376-
func (m *Manager) getRepoNames(deps []*chart.Dependency) (map[string]string, error) {
380+
// resolveRepoNames returns the repo names of the referenced deps which can be used to fetch the cached index file
381+
// and replaces aliased repository URLs into resolved URLs in dependencies.
382+
func (m *Manager) resolveRepoNames(deps []*chart.Dependency) (map[string]string, error) {
377383
rf, err := loadRepoConfig(m.RepositoryConfig)
378384
if err != nil {
379385
if os.IsNotExist(err) {

pkg/downloader/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func TestGetRepoNames(t *testing.T) {
161161
}
162162

163163
for _, tt := range tests {
164-
l, err := m.getRepoNames(tt.req)
164+
l, err := m.resolveRepoNames(tt.req)
165165
if err != nil {
166166
if tt.err {
167167
continue

0 commit comments

Comments
 (0)