-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kevin Zhao <kevin.zhao@arm.com>
- Loading branch information
Kevin Zhao
committed
Apr 12, 2018
1 parent
0028ca2
commit 8f026cc
Showing
3 changed files
with
24 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
package capsules | ||
|
||
// Template is a structure that represents OpenStack Heat templates | ||
import ( | ||
"encoding/json" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
type Template struct { | ||
TE | ||
// Bin stores the contents of the template or environment. | ||
Bin []byte | ||
// Parsed contains a parsed version of Bin. Since there are 2 different | ||
// fields referring to the same value, you must be careful when accessing | ||
// this filed. | ||
Parsed map[string]interface{} | ||
} | ||
|
||
// Parse will parse the contents and then validate. The contents MUST be either JSON or YAML. | ||
func (t *Template) Parse() error { | ||
if jerr := json.Unmarshal(t.Bin, &t.Parsed); jerr != nil { | ||
if yerr := yaml.Unmarshal(t.Bin, &t.Parsed); yerr != nil { | ||
return ErrInvalidDataFormat{} | ||
} | ||
} | ||
return nil | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters