@@ -102,8 +102,7 @@ func (r *Repo) getTagManifest(chartName, version string) (*ocispec.Manifest, err
102102 u := * r .url
103103 u .Path = path .Join (u .Path , "/" , chartName )
104104
105- // helm replaces plus(+) characters with underscores(_) in the tag (version)
106- ref , err := name .ParseReference (u .Host + u .Path + ":" + strings .ReplaceAll (version , "+" , "_" ))
105+ ref , err := r .parseReference (u , version )
107106 if err != nil {
108107 return nil , errors .Errorf ("failed parsing OCI reference: %s" , err )
109108 }
@@ -213,8 +212,7 @@ func (r *Repo) Fetch(chartName string, version string) (string, error) {
213212 u := * r .url
214213 u .Path = path .Join (u .Path , "/" , chartName )
215214
216- // helm replaces plus(+) characters with underscores(_) in the tag (version)
217- ref , err := name .ParseReference (u .Host + u .Path + ":" + strings .ReplaceAll (version , "+" , "_" ))
215+ ref , err := r .parseReference (u , version )
218216 if err != nil {
219217 return "" , errors .Errorf ("failed parsing OCI reference: %s" , err )
220218 }
@@ -285,9 +283,7 @@ func (r *Repo) Has(chartName string, version string) (bool, error) {
285283 u := * r .url
286284 u .Path = path .Join (u .Path , "/" , chartName )
287285
288- // helm replaces plus(+) characters with underscores(_) in the tag (version)
289- ref , err := name .ParseReference (u .Host + u .Path + ":" + strings .ReplaceAll (version , "+" , "_" ))
290-
286+ ref , err := r .parseReference (u , version )
291287 if err != nil {
292288 return false , errors .Errorf ("failed parsing OCI reference: %s" , err )
293289 }
@@ -353,24 +349,13 @@ func isHelmChartContentLayerMediaType(t string) bool {
353349 return false
354350}
355351
356- // ociReferenceExists checks if a given oci reference exists in the repository
357- func ociReferenceExists (ociRef , username , password string ) (bool , error ) {
358- ociReference , err := name .ParseReference (ociRef )
359- if err != nil {
360- return false , errors .Trace (err )
361- }
362- authOptions := authn.Basic {Username : username , Password : password }
363- opt := []remote.Option {
364- remote .WithAuth (& authOptions ),
365- }
366- _ , err = remote .Head (ociReference , opt ... )
367- if err != nil {
368- if strings .Contains (err .Error (), "404 Not Found" ) {
369- return false , nil
370- }
371- return false , errors .Trace (err )
352+ func (r * Repo ) parseReference (u url.URL , version string ) (name.Reference , error ) {
353+ // helm replaces plus(+) characters with underscores(_) in the tag (version)
354+ ref := u .Host + u .Path + ":" + strings .ReplaceAll (version , "+" , "_" )
355+ if r .usePlainHTTP {
356+ return name .ParseReference (ref , name .Insecure )
372357 }
373- return true , nil
358+ return name . ParseReference ( ref )
374359}
375360
376361// populateEntries populates the entries map with the info from the charts index
0 commit comments