template

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package template renders the static files under the "/templates/" directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DashReplacedLogicalIDToOriginal

func DashReplacedLogicalIDToOriginal(safeLogicalID string) string

DashReplacedLogicalIDToOriginal takes a "sanitized" logical ID and converts it back to its original form, with dashes.

func EnvVarNameFunc

func EnvVarNameFunc(s string) string

EnvVarNameFunc converts an input resource name to LogicalIDSafe, then appends "Name" to the end.

func FmtSliceFunc

func FmtSliceFunc(elems []string) string

FmtSliceFunc renders a string representation of a go string slice, surrounded by brackets and joined by commas.

func IncFunc

func IncFunc(i int) int

IncFunc increments an integer value and returns the result.

func QuotePSliceFunc

func QuotePSliceFunc(elems []*string) []string

QuotePSliceFunc places quotation marks around all dereferenced elements of elems and returns a []string slice.

func QuoteSliceFunc

func QuoteSliceFunc(elems []string) []string

QuoteSliceFunc places quotation marks around all elements of a go string slice.

func ReplaceDashesFunc

func ReplaceDashesFunc(logicalID string) string

ReplaceDashesFunc takes a CloudFormation logical ID, and sanitizes it by removing "-" characters (not allowed) and replacing them with "DASH" (allowed by CloudFormation but not permitted in ecs-cli generated resource names).

func StripNonAlphaNumFunc

func StripNonAlphaNumFunc(s string) string

StripNonAlphaNumFunc strips non-alphanumeric characters from an input string.

func ToSnakeCaseFunc

func ToSnakeCaseFunc(s string) string

ToSnakeCaseFunc transforms a CamelCase input string s into an upper SNAKE_CASE string and returns it. For example, "usersDdbTableName" becomes "USERS_DDB_TABLE_NAME".

Types

type Content

type Content struct {
	*bytes.Buffer
}

Content represents the parsed template.

func (*Content) MarshalBinary

func (c *Content) MarshalBinary() ([]byte, error)

MarshalBinary returns the contents as binary and implements the encoding.BinaryMarshaler interface.

type LogConfigOpts

type LogConfigOpts struct {
	Image          *string
	Destination    map[string]string
	EnableMetadata *string
	SecretOptions  map[string]string
	ConfigFile     *string
}

LogConfigOpts holds configuration that's needed if the service is configured with Firelens to route its logs.

type ParseOption

type ParseOption func(t *template.Template) *template.Template

ParseOption represents a functional option for the Parse method.

func WithFuncs

func WithFuncs(fns map[string]interface{}) ParseOption

WithFuncs returns a template that can parse additional custom functions.

type Parser

type Parser interface {
	Parse(path string, data interface{}, options ...ParseOption) (*Content, error)
}

Parser is the interface that wraps the Parse method.

type ReadParser

type ReadParser interface {
	Read(path string) (*Content, error)
	Parser
}

ReadParser is the interface that wraps the Read and Parse methods.

type ServiceNestedStackOpts

type ServiceNestedStackOpts struct {
	StackName string

	VariableOutputs []string
	SecretOutputs   []string
	PolicyOutputs   []string
}

ServiceNestedStackOpts holds configuration that's needed if the service stack has a nested stack.

type ServiceOpts

type ServiceOpts struct {
	// Additional options that're common between **all** service templates.
	Variables   map[string]string
	Secrets     map[string]string
	NestedStack *ServiceNestedStackOpts // Outputs from nested stacks such as the addons stack.
	Sidecars    []*SidecarOpts
	LogConfig   *LogConfigOpts

	// Additional options that're not shared across all service templates.
	HealthCheck        *ecs.HealthCheck
	RulePriorityLambda string
}

ServiceOpts holds optional data that can be provided to enable features in a service stack template.

type SidecarOpts

type SidecarOpts struct {
	Name       *string
	Image      *string
	Port       *string
	Protocol   *string
	CredsParam *string
}

SidecarOpts holds configuration that's needed if the service has sidecar containers.

type Template

type Template struct {
	// contains filtered or unexported fields
}

Template represents the "/templates/" directory that holds static files to be embedded in the binary.

func New

func New() *Template

New returns a Template object that can be used to parse files under the "/templates/" directory.

func (*Template) Parse

func (t *Template) Parse(path string, data interface{}, options ...ParseOption) (*Content, error)

Parse parses the template under "/templates/{path}" with the specified data object and returns its content.

func (*Template) ParseBackendService

func (t *Template) ParseBackendService(data ServiceOpts) (*Content, error)

ParseBackendService parses a backend service's CloudFormation template with the specified data object and returns its content.

func (*Template) ParseLoadBalancedWebService

func (t *Template) ParseLoadBalancedWebService(data ServiceOpts) (*Content, error)

ParseLoadBalancedWebService parses a load balanced web service's CloudFormation template with the specified data object and returns its content.

func (*Template) Read

func (t *Template) Read(path string) (*Content, error)

Read returns the contents of the template under "/templates/{path}".

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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