From f5f3e28b23a9ac41004a0ce790a948c52a3ac379 Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Tue, 2 Aug 2016 22:36:51 -0700 Subject: [PATCH] ignore empty json fields when processing templates --- util.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util.go b/util.go index 77a5935d..927d56d2 100644 --- a/util.go +++ b/util.go @@ -322,6 +322,9 @@ func yamlFixup(data interface{}) (interface{}, error) { return nil, err } } + if len(copy) == 0 { + return nil, nil + } return copy, nil case map[string]interface{}: copy := make(map[string]interface{}) @@ -332,6 +335,9 @@ func yamlFixup(data interface{}) (interface{}, error) { copy[k] = fixed } } + if len(copy) == 0 { + return nil, nil + } return copy, nil case []interface{}: copy := make([]interface{}, 0, len(d)) @@ -342,6 +348,9 @@ func yamlFixup(data interface{}) (interface{}, error) { copy = append(copy, fixed) } } + if len(copy) == 0 { + return nil, nil + } return copy, nil case string: if d == "" || d == "\n" {