Documentation ¶
Overview ¶
Package format provides functions for formatting CloudFormation templates using an opinionated, idiomatic format as used in AWS documentation.
For each function, CloudFormation templates should be represented using a map[string]interface{} as output by other libraries that parse JSON/YAML such as github.com/awslabs/goformation and encoding/json.
Comments can be passed along with the template data in the following format:
map[interface{}]interface{}{ "": "This is a top-level comment", "Resources": map[interface{}]interface{}{ "": "This is a comment on the whole `Resources` property", "MyBucket": map[interface{}]interface{}{ "Properties": map[interface{}]interface{}{ "BucketName": "This is a comment on BucketName", }, }, }, }
Empty string keys are taken to represent a comment on the overall node that the comment is attached to. Numeric keys can be used to reference elements of arrays in the source data.
Index ¶
Constants ¶
const ( YAML = iota JSON )
Variables ¶
This section is empty.
Functions ¶
func Json ¶
func Json(data interface{}) string
Json formats the CloudFormation template as a Json string
func JsonWithComments ¶
func JsonWithComments(data interface{}, comments map[interface{}]interface{}) string
JsonWithComments formats the CloudFormation template as a Json string with comments as provided
func Yaml ¶
func Yaml(data interface{}) string
Yaml formats the CloudFormation template as a Yaml string
func YamlWithComments ¶
func YamlWithComments(data interface{}, comments map[interface{}]interface{}) string
YamlWithComments formats the CloudFormation template as a Yaml string with comments as provided
Types ¶
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
func NewFormatter ¶
func NewFormatter() Formatter
func (*Formatter) FormatWithComments ¶
func (*Formatter) SetCompact ¶
func (f *Formatter) SetCompact()
func (*Formatter) SetExpanded ¶
func (f *Formatter) SetExpanded()