refactor(context): Implement more explicit merging of variables

The hierarchy for loading variables was previously not expressed
explicitly.

This commit refactors the logic for merging variables to explicitly
set the different layers of variables as values on the context object
and merge them for each resource set in `mergeContextValues`.
This commit is contained in:
Vincent Ambo 2018-06-09 16:23:09 +02:00 committed by Vincent Ambo
parent 5cf9d53e80
commit b33c353233
5 changed files with 96 additions and 62 deletions

View file

@ -184,16 +184,11 @@ func createCommand() {
}
func loadContextAndResources(file *string) (*context.Context, *[]templater.RenderedResourceSet) {
ctx, err := context.LoadContextFromFile(*file)
ctx, err := context.LoadContext(*file, variables)
if err != nil {
app.Fatalf("Error loading context: %v\n", err)
}
err = ctx.SetVariablesFromArguments(variables)
if err != nil {
app.Fatalf("Error setting explicit variables in context: %v\n", err)
}
resources, err := templater.LoadAndApplyTemplates(includes, excludes, ctx)
if err != nil {
app.Fatalf("Error templating resource sets: %v\n", err)