Merge pull request #385 from helmfile/382-invalid-path-to-chart-when-running-helmfile-apply
fix path issue in windows
This commit is contained in:
		
						commit
						bef8aaceee
					
				|  | @ -1,15 +1,21 @@ | ||||||
| package state | package state | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"fmt" | ||||||
|  | 	"os" | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"regexp" |  | ||||||
| 	"strings" | 	"strings" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | var ( | ||||||
|  | 	// current working directory
 | ||||||
|  | 	currentDirSymbol = "." | ||||||
|  | 	// parent directory
 | ||||||
|  | 	parentDirSymbol = ".." | ||||||
|  | ) | ||||||
|  | 
 | ||||||
| func isLocalChart(chart string) bool { | func isLocalChart(chart string) bool { | ||||||
| 	regex := regexp.MustCompile("^[.]?./") | 	if strings.HasPrefix(chart, fmt.Sprintf("%s%c", currentDirSymbol, os.PathSeparator)) || strings.HasPrefix(chart, fmt.Sprintf("%s%c", parentDirSymbol, os.PathSeparator)) { | ||||||
| 	matched := regex.MatchString(chart) |  | ||||||
| 	if matched { |  | ||||||
| 		return true | 		return true | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -19,8 +25,8 @@ func isLocalChart(chart string) bool { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return chart == "" || | 	return chart == "" || | ||||||
| 		chart[0] == '/' || | 		filepath.IsAbs(chart) || | ||||||
| 		!strings.Contains(chart, "/") || | 		!strings.Contains(chart, fmt.Sprintf("%c", os.PathSeparator)) || | ||||||
| 		(len(strings.Split(chart, "/")) != 2 && | 		(len(strings.Split(chart, "/")) != 2 && | ||||||
| 			len(strings.Split(chart, "/")) != 3) | 			len(strings.Split(chart, "/")) != 3) | ||||||
| } | } | ||||||
|  | @ -51,7 +57,7 @@ func resolveRemoteChart(repoAndChart string) (string, string, bool) { | ||||||
| // be constructed relative to the `base path`.
 | // be constructed relative to the `base path`.
 | ||||||
| // - Everything else is assumed to be an absolute path or an actual <repository>/<chart> reference.
 | // - Everything else is assumed to be an absolute path or an actual <repository>/<chart> reference.
 | ||||||
| func normalizeChart(basePath, chart string) string { | func normalizeChart(basePath, chart string) string { | ||||||
| 	if !isLocalChart(chart) || chart[0] == '/' { | 	if !isLocalChart(chart) || filepath.IsAbs(chart) { | ||||||
| 		return chart | 		return chart | ||||||
| 	} | 	} | ||||||
| 	return filepath.Join(basePath, chart) | 	return filepath.Join(basePath, chart) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue