format

package
v1.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Overview

Package format contains functionality to render a cft.Template into YAML or JSON

Index

Constants

View Source
const (
	SUB       = "Fn::Sub"
	REF       = "Ref"
	GETATT    = "Fn::GetAtt"
	EQUALS    = "Fn::Equals"
	CONTAINS  = "Fn::Contains"
	FINDINMAP = "Fn::FindInMap"
	GETAZS    = "Fn::GetAZs"
	SELECT    = "Fn::Select"
	SPLIT     = "Fn::Split"
)

Variables

View Source
var NodeStyle string

Global, set by command arg --node-style

View Source
var NodeStyleDocs = "Set the node output style to tagged, doublequoted, singlequoted, literal, folded, quotescalars, original, or flow"

Functions

func CftToPkl added in v1.8.2

func CftToPkl(t cft.Template, basic bool, pklPackageAlias string) (string, error)

CftToPkl serializes the template as pkl. It assumes that the user is importing the cloudformation package

func CftToYaml added in v1.7.0

func CftToYaml(t cft.Template) string

CftToYaml converts a template to a YAML string

func CheckMultilineBegin added in v1.6.0

func CheckMultilineBegin(s string) bool

func Jsonise added in v1.7.0

func Jsonise(node *yaml.Node) interface{}

func PrettyPrint added in v1.3.0

func PrettyPrint(i interface{}) string

converts struct to a JSON formatted string

func String

func String(t cft.Template, opt Options) string

String returns a string representation of the supplied cft.Template

func ToJson added in v1.7.5

func ToJson(i interface{}, indent string) ([]byte, error)

ToJson overrides the default behavior of json.Marshal to leave < > alone

Types

type MapItem added in v1.7.5

type MapItem struct {
	Key, Value interface{}
	// contains filtered or unexported fields
}

MapItem representation of one map item.

func (MapItem) String added in v1.7.5

func (mi MapItem) String() string

MapItem as a string.

func (*MapItem) UnmarshalJSON added in v1.7.5

func (mi *MapItem) UnmarshalJSON(b []byte) error

UnmarshalJSON for map item.

type MapSlice added in v1.7.5

type MapSlice []MapItem

MapSlice of map items.

func (MapSlice) Len added in v1.7.5

func (ms MapSlice) Len() int

func (MapSlice) Less added in v1.7.5

func (ms MapSlice) Less(i, j int) bool

func (MapSlice) MarshalJSON added in v1.7.5

func (ms MapSlice) MarshalJSON() ([]byte, error)

MarshalJSON for map slice.

func (MapSlice) Swap added in v1.7.5

func (ms MapSlice) Swap(i, j int)

func (*MapSlice) UnmarshalJSON added in v1.7.5

func (ms *MapSlice) UnmarshalJSON(b []byte) error

UnmarshalJSON for map slice.

type Options

type Options struct {
	// JSON determines whether the outputs will be JSON (true) or YAML (false)
	JSON bool

	// Unsorted will cause the formatter to leave the ordering of template elements
	// as in the original template if true.
	// If false, the formatter will rearrange the template elements into
	// canonical order.
	Unsorted bool
}

Options contains options for formatting cfn templates

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL