Remove extra appending of chartName for lint and template (#406)
Closes #407
This commit is contained in:
		
							parent
							
								
									4b23213ce4
								
							
						
					
					
						commit
						2a35b6864c
					
				|  | @ -7,6 +7,7 @@ import ( | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
|  | 	"sort" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
|  | @ -385,8 +386,13 @@ func (state *HelmState) downloadCharts(helm helmexec.Interface, dir string, work | ||||||
| 							errs = append(errs, err) | 							errs = append(errs, err) | ||||||
| 						} | 						} | ||||||
| 					} | 					} | ||||||
| 					chartPath = path.Join(chartPath, chartNameWithoutRepository(release.Chart)) | 					// Set chartPath to be the path containing Chart.yaml, if found
 | ||||||
|  | 					fullChartPath, err := findChartDirectory(chartPath) | ||||||
|  | 					if err == nil { | ||||||
|  | 						chartPath = filepath.Dir(fullChartPath) | ||||||
| 					} | 					} | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
| 				results <- &downloadResults{release.Name, chartPath} | 				results <- &downloadResults{release.Name, chartPath} | ||||||
| 			} | 			} | ||||||
| 			wgFetch.Done() | 			wgFetch.Done() | ||||||
|  | @ -968,6 +974,28 @@ func chartNameWithoutRepository(chart string) string { | ||||||
| 	return chartSplit[len(chartSplit)-1] | 	return chartSplit[len(chartSplit)-1] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // find "Chart.yaml"
 | ||||||
|  | func findChartDirectory(topLevelDir string) (string, error) { | ||||||
|  | 	var files []string | ||||||
|  | 	filepath.Walk(topLevelDir, func(path string, f os.FileInfo, _ error) error { | ||||||
|  | 		if !f.IsDir() { | ||||||
|  | 			r, err := regexp.MatchString("Chart.yaml", f.Name()) | ||||||
|  | 			if err == nil && r { | ||||||
|  | 				files = append(files, path) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 		return nil | ||||||
|  | 	}) | ||||||
|  | 	// Sort to get the shortest path
 | ||||||
|  | 	sort.Strings(files) | ||||||
|  | 	if len(files) > 0 { | ||||||
|  | 		first := files[0] | ||||||
|  | 		return first, nil | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return topLevelDir, errors.New("No Chart.yaml found") | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (state *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSpec) ([]string, error) { | func (state *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSpec) ([]string, error) { | ||||||
| 	flags := []string{} | 	flags := []string{} | ||||||
| 	if release.Version != "" { | 	if release.Version != "" { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue