@@ -21,7 +21,9 @@ import (
2121
2222 "helm.sh/helm/v3/pkg/action"
2323 "helm.sh/helm/v3/pkg/chart/loader"
24+ "helm.sh/helm/v3/pkg/cli"
2425 "helm.sh/helm/v3/pkg/getter"
26+ "helm.sh/helm/v3/pkg/repo"
2527 "helm.sh/helm/v3/pkg/storage/driver"
2628 "k8s.io/cli-runtime/pkg/genericclioptions"
2729 "knative.dev/pkg/logging"
@@ -47,9 +49,16 @@ type Chart struct {
4749 Values map [string ]interface {}
4850}
4951
50- func (c * Client ) Apply (ctx context.Context , chart * Chart ) error {
52+ func (c * Client ) Apply (ctx context.Context , chart * Chart ) ( err error ) {
5153 // Get the chart from the repository
52- charts , err := c .httpGetter .Get (fmt .Sprintf ("%s/%s-%s.tgz" , chart .Repository , chart .Name , chart .Version ))
54+ chartPath := fmt .Sprintf ("%s/%s-%s.tgz" , chart .Repository , chart .Name , chart .Version )
55+ if chart .Version == "" {
56+ chartPath , err = repo .FindChartInRepoURL (chart .Repository , chart .Name , "" , "" , "" , "" , getter .All (& cli.EnvSettings {}))
57+ if err != nil {
58+ return fmt .Errorf ("failed to find chart, %w" , err )
59+ }
60+ }
61+ charts , err := c .httpGetter .Get (chartPath )
5362 if err != nil {
5463 return fmt .Errorf ("getting chart, %w" , err )
5564 }
0 commit comments