Skip to content

Commit

Permalink
fix(helm): add URL escaping for chart names in RemoteReference (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcotuna authored Dec 2, 2024
1 parent ce62c18 commit d85dc91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/build/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func (h *Helm) buildFromHelmRepository(ctx context.Context, obj *sourcev1beta2.H
}

ref := chart.RemoteReference{Name: obj.Spec.Chart, Version: obj.Spec.Version}
path, chartCacheKey, err := h.cache.GetOrLock(normalizedURL, ref)
path, chartCacheKey, err := h.cache.GetOrLock(normalizedURL, ref.WithEscapedName())
if err != nil {
return err
}
Expand Down
7 changes: 7 additions & 0 deletions internal/helm/chart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package chart
import (
"context"
"fmt"
"net/url"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -75,6 +76,12 @@ type RemoteReference struct {
Version string
}

// WithEscapedName returns a new RemoteReference with the Name URL-escaped.
func (r RemoteReference) WithEscapedName() RemoteReference {
r.Name = url.PathEscape(r.Name)
return r
}

// Validate returns an error if the RemoteReference does not have
// a Name set.
func (r RemoteReference) Validate() error {
Expand Down

0 comments on commit d85dc91

Please sign in to comment.