improve error handling for value rendering (#235)
Fixes #233 Output on values render error: ``` err: failed to render [/Users/sstarcher/xxx/xxx/values.yaml], because of template: stringTemplate:10:18: executing "stringTemplate" at <requiredEnv "HELM_AC...>: error calling requiredEnv: required env var `HELM_ACCOUNT` is not set ``` Also removes panic and sets the output as `apps.Run()` can and will return errors. Panic makes no sense. Changelog: * improve error handling for value rendering * only output if error exists * add exit status
This commit is contained in:
		
							parent
							
								
									fa69ac2cfa
								
							
						
					
					
						commit
						543a653864
					
				
							
								
								
									
										3
									
								
								main.go
								
								
								
								
							
							
						
						
									
										3
									
								
								main.go
								
								
								
								
							| 
						 | 
				
			
			@ -386,7 +386,8 @@ func main() {
 | 
			
		|||
 | 
			
		||||
	err := app.Run(os.Args)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		log.Panicf("[bug] this code path shouldn't be arrived: helmfile is expected to exit from within the `cleanup` func in main.go: %v", err)
 | 
			
		||||
		logger.Errorf("%v", err)
 | 
			
		||||
		os.Exit(3)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -703,9 +703,11 @@ func (state *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, basePat
 | 
			
		|||
			if _, err := os.Stat(path); os.IsNotExist(err) {
 | 
			
		||||
				return nil, err
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			yamlBuf, err := RenderTemplateFileToBuffer(path)
 | 
			
		||||
			if err != nil {
 | 
			
		||||
				return nil, err
 | 
			
		||||
 | 
			
		||||
				return nil, fmt.Errorf("failed to render [%s], because of %v", path, err)
 | 
			
		||||
			}
 | 
			
		||||
			valfile, err := ioutil.TempFile("", "values")
 | 
			
		||||
			if err != nil {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue