chore templater: Use new util.Merge func
This commit is contained in:
		
							parent
							
								
									7a930aad11
								
							
						
					
					
						commit
						f81fe551bc
					
				
					 1 changed files with 2 additions and 11 deletions
				
			
		| 
						 | 
					@ -13,6 +13,7 @@ import (
 | 
				
			||||||
	"github.com/Masterminds/sprig"
 | 
						"github.com/Masterminds/sprig"
 | 
				
			||||||
	"github.com/polydawn/meep"
 | 
						"github.com/polydawn/meep"
 | 
				
			||||||
	"github.com/tazjin/kontemplate/context"
 | 
						"github.com/tazjin/kontemplate/context"
 | 
				
			||||||
 | 
						"github.com/tazjin/kontemplate/util"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Error that is caused by non-existent template files being specified
 | 
					// Error that is caused by non-existent template files being specified
 | 
				
			||||||
| 
						 | 
					@ -88,17 +89,7 @@ func templateFile(c *context.Context, rs *context.ResourceSet, filename string)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var b bytes.Buffer
 | 
						var b bytes.Buffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Guard against empty map before merging keys
 | 
						rs.Values = *util.Merge(&c.Global, &rs.Values)
 | 
				
			||||||
	if rs.Values == nil {
 | 
					 | 
				
			||||||
		rs.Values = make(map[string]interface{}, 0)
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Merge global and resourceset-specific values (don't override from global)
 | 
					 | 
				
			||||||
	for k, v := range c.Global {
 | 
					 | 
				
			||||||
		if _, ok := rs.Values[k]; !ok {
 | 
					 | 
				
			||||||
			rs.Values[k] = v
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tpl.Execute(&b, rs.Values)
 | 
						err = tpl.Execute(&b, rs.Values)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue