fix: fixed up OCI repos so they support paths and URLs that differ from chart names contained there (#1661)
This commit is contained in:
		
							parent
							
								
									2a71640095
								
							
						
					
					
						commit
						8212b630ff
					
				|  | @ -1316,16 +1316,18 @@ In order to use OCI chart registries firstly they must be marked in the reposito | ||||||
| ```yaml | ```yaml | ||||||
| repositories: | repositories: | ||||||
|   - name: myOCIRegistry |   - name: myOCIRegistry | ||||||
|     url: https://myregistry.azurecr.io |     url: myregistry.azurecr.io | ||||||
|     oci: true |     oci: true | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
|  | It is important not to include a scheme for the URL as helm requires that these are not present for OCI registries | ||||||
|  | 
 | ||||||
| Secondly the credentials for the OCI registry can either be specified within `helmfile.yaml` similar to | Secondly the credentials for the OCI registry can either be specified within `helmfile.yaml` similar to | ||||||
| 
 | 
 | ||||||
| ```yaml | ```yaml | ||||||
| repositories: | repositories: | ||||||
|   - name: myOCIRegistry |   - name: myOCIRegistry | ||||||
|     url: https://myregistry.azurecr.io |     url: myregistry.azurecr.io | ||||||
|     oci: true |     oci: true | ||||||
|     username: spongebob |     username: spongebob | ||||||
|     password: squarepants |     password: squarepants | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								go.mod
								
								
								
								
							
							
						
						
									
										1
									
								
								go.mod
								
								
								
								
							|  | @ -19,7 +19,6 @@ require ( | ||||||
| 	github.com/hashicorp/go-version v1.2.1 | 	github.com/hashicorp/go-version v1.2.1 | ||||||
| 	github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect | 	github.com/howeyc/gopass v0.0.0-20190910152052-7cb4b85ec19c // indirect | ||||||
| 	github.com/imdario/mergo v0.3.11 | 	github.com/imdario/mergo v0.3.11 | ||||||
| 	github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect |  | ||||||
| 	github.com/pierrec/lz4 v2.3.0+incompatible // indirect | 	github.com/pierrec/lz4 v2.3.0+incompatible // indirect | ||||||
| 	github.com/r3labs/diff v1.1.0 | 	github.com/r3labs/diff v1.1.0 | ||||||
| 	github.com/spf13/cobra v1.1.1 | 	github.com/spf13/cobra v1.1.1 | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								go.sum
								
								
								
								
							
							
						
						
									
										4
									
								
								go.sum
								
								
								
								
							|  | @ -429,8 +429,6 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW | ||||||
| github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= | github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= | ||||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= |  | ||||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= |  | ||||||
| github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= | github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= | ||||||
| github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | ||||||
| github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||||||
|  | @ -630,8 +628,6 @@ github.com/variantdev/chartify v0.6.0 h1:QQ00a8Vtuhk6F9jeTZJEXV2g0zRXhYG43xovWZr | ||||||
| github.com/variantdev/chartify v0.6.0/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= | github.com/variantdev/chartify v0.6.0/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= | ||||||
| github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= | github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= | ||||||
| github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= | github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= | ||||||
| github.com/variantdev/vals v0.11.0 h1:818ztGk5yPTiixbUeE3LkkBGGATEAKtWq09n8q8PFqc= |  | ||||||
| github.com/variantdev/vals v0.11.0/go.mod h1:pZ0ZJZnOwB5aCJmXZgwrgMMMKMfIYMrhpsHllInRQ8c= |  | ||||||
| github.com/variantdev/vals v0.12.0 h1:1fk2nlSzGkoY5/Ij7dyIB6r0eemFGWQMa5TD2ZhDSB8= | github.com/variantdev/vals v0.12.0 h1:1fk2nlSzGkoY5/Ij7dyIB6r0eemFGWQMa5TD2ZhDSB8= | ||||||
| github.com/variantdev/vals v0.12.0/go.mod h1:KHSazZ2M3pFiwu6mw4O56YdjNatCZpJZkk4s23rexW8= | github.com/variantdev/vals v0.12.0/go.mod h1:KHSazZ2M3pFiwu6mw4O56YdjNatCZpJZkk4s23rexW8= | ||||||
| github.com/vektra/mockery v1.1.2/go.mod h1:VcfZjKaFOPO+MpN4ZvwPjs4c48lkq1o3Ym8yHZJu0jU= | github.com/vektra/mockery v1.1.2/go.mod h1:VcfZjKaFOPO+MpN4ZvwPjs4c48lkq1o3Ym8yHZJu0jU= | ||||||
|  |  | ||||||
|  | @ -18,7 +18,6 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"text/template" | 	"text/template" | ||||||
| 
 | 
 | ||||||
| 	"github.com/hashicorp/go-getter/helper/url" |  | ||||||
| 	"github.com/imdario/mergo" | 	"github.com/imdario/mergo" | ||||||
| 	"github.com/variantdev/chartify" | 	"github.com/variantdev/chartify" | ||||||
| 
 | 
 | ||||||
|  | @ -2996,22 +2995,14 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm | ||||||
| 		return isOCI, release.Chart, nil | 		return isOCI, release.Chart, nil | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	repoUrl, err := url.Parse(repo.URL) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return isOCI, release.Chart, err |  | ||||||
| 	} |  | ||||||
| 	if repoUrl.Scheme == "" { |  | ||||||
| 		return isOCI, release.Chart, fmt.Errorf("unable to detect scheme - a valid url must be supplied for OCI registry %s", repo.URL) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	chartVersion := "latest" | 	chartVersion := "latest" | ||||||
| 	if release.Version != "" { | 	if release.Version != "" { | ||||||
| 		chartVersion = release.Version | 		chartVersion = release.Version | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	qualifiedChartName := fmt.Sprintf("%s/%s:%s", repoUrl.Host, name, chartVersion) | 	qualifiedChartName := fmt.Sprintf("%s/%s:%s", repo.URL, name, chartVersion) | ||||||
| 
 | 
 | ||||||
| 	err = helm.ChartPull(qualifiedChartName) | 	err := helm.ChartPull(qualifiedChartName) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return isOCI, release.Chart, err | 		return isOCI, release.Chart, err | ||||||
| 	} | 	} | ||||||
|  | @ -3030,12 +3021,14 @@ func (st *HelmState) getOCIChart(release *ReleaseSpec, tempDir string, helm helm | ||||||
| 
 | 
 | ||||||
| 	pathElems = append(pathElems, release.Name, name, chartVersion) | 	pathElems = append(pathElems, release.Name, name, chartVersion) | ||||||
| 
 | 
 | ||||||
| 	dir := filepath.Join(pathElems...) | 	chartPath := path.Join(pathElems...) | ||||||
| 	err = helm.ChartExport(qualifiedChartName, dir) | 	err = helm.ChartExport(qualifiedChartName, chartPath) | ||||||
| 
 | 
 | ||||||
|  | 	fullChartPath, err := findChartDirectory(chartPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return isOCI, release.Chart, err | 		return isOCI, release.Chart, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return isOCI, filepath.Join(dir, name), nil | 	chartPath = filepath.Dir(fullChartPath) | ||||||
|  | 	return isOCI, chartPath, nil | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue