Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Commit

Permalink
fixed #82 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojkelly authored Jul 31, 2018
1 parent c8e1df1 commit 4cbbe32
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/plugins/api/marshalling.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package api

import (
"fmt"
"log"

"github.com/KablamoOSS/yaml"
Expand Down Expand Up @@ -57,10 +58,21 @@ func cleanResult(objects kombustionTypes.TemplateObject) (result kombustionTypes
result = make(kombustionTypes.TemplateObject)

for k, v := range objects {
if obj, err := yaml.Marshal(v); err == nil {
var tempObject kombustionTypes.TemplateObject
if err = yaml.Unmarshal(obj, &tempObject); err == nil {
result[k] = tempObject
// We need to check the value is not empty, to prevent a nil pointer in the yaml.Marshall
// it will be empty when the user leaves a key blank in their template
if v != nil {
obj, err := yaml.Marshal(v)
// fmt.Println(err)
if err == nil {
var tempObject kombustionTypes.TemplateObject
err = yaml.Unmarshal(obj, &tempObject)
if err == nil {
result[k] = tempObject
} else {
fmt.Println(err)
}
} else {
fmt.Println(err)
}
}
}
Expand Down

0 comments on commit 4cbbe32

Please sign in to comment.