commands

package
v0.81.1-beta Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// OutputRegex for printing yaml/json output
	OutputRegex = `(?m)^[ ]*([^\r\n:]+?)\s*:`
)

config environment variable

Variables

View Source
var (

	// gentime function maps
	GenTimeFunctions = template.FuncMap{

		"add": func(a int, b int) int {
			log.Debug("Calling Template Function [add] with arguments: %s + %s", a, b)
			return a + b
		},

		"strip": func(s string, rmv string) string {
			log.Debug("Calling Template Function [strip] with arguments: (%s, %s) ", s, rmv)
			return strings.Replace(s, rmv, "", -1)
		},

		"cat": func(path string) string {
			log.Debug("Calling Template Function [cat] with arguments: %s", path)
			b, err := ioutil.ReadFile(path)
			utils.HandleError(err)
			return string(b)
		},

		"literal": literal,

		"suffix": suffix,

		"prefix": prefix,

		"contains": contains,

		"loop": loop,

		"GET": httpGet,

		"s3_read": s3Read,

		"invoke": lambdaInvoke,

		"kms_encrypt": kmsEncrypt,

		"kms_decrypt": kmsDecrypt,

		"mod": func(a int, b int) int {
			log.Debug("Calling Template Function [mod] with arguments: %s % %s", a, b)
			return a % b
		},

		"seq": func(from, to int) []int {
			log.Debug("Calling Template Function [seq] with arguments: %s % %s", from, to)
			seq := make([]int, to-from+1)
			for i := range seq {
				seq[i] = from + i
			}
			return seq
		},
	}

	// deploytime function maps
	DeployTimeFunctions = template.FuncMap{

		"stack_output": func(target string) string {
			log.Debug("Deploy-Time function resolving: %s", target)
			req := strings.Split(target, "::")

			s, ok := stacks.Get(req[0])
			if !ok {
				utils.HandleError(fmt.Errorf("stack_output errror: stack [%s] not found", req[0]))
			}

			utils.HandleError(s.Outputs())

			for _, i := range s.Output.Stacks {
				for _, o := range i.Outputs {
					if *o.OutputKey == req[1] {
						return *o.OutputValue
					}
				}
			}
			utils.HandleError(fmt.Errorf("Stack Output Not found - Stack:%s | Output:%s", req[0], req[1]))
			return ""
		},

		"stack_output_ext": func(target string) string {
			log.Debug("Deploy-Time function resolving: %s", target)
			req := strings.Split(target, "::")

			sess, err := GetSession()
			utils.HandleError(err)

			s := stks.Stack{
				Stackname: req[0],
				Session:   sess,
			}

			err = s.Outputs()
			utils.HandleError(err)

			for _, i := range s.Output.Stacks {
				for _, o := range i.Outputs {
					if *o.OutputKey == req[1] {
						return *o.OutputValue
					}
				}
			}

			utils.HandleError(fmt.Errorf("Stack Output Not found - Stack:%s | Output:%s", req[0], req[1]))
			return ""
		},

		"suffix": suffix,

		"prefix": prefix,

		"contains": contains,

		"loop": loop,

		"literal": literal,

		"GET": httpGet,

		"s3_read": s3Read,

		"invoke": lambdaInvoke,

		"kms_encrypt": kmsEncrypt,

		"kms_decrypt": kmsDecrypt,
	}
)

Common Functions - Both Deploy/Gen

View Source
var (
	// RootCmd command (calls all other commands)
	RootCmd = &cobra.Command{
		Use:   "qaz",
		Short: version,
		Run: func(cmd *cobra.Command, args []string) {

			if run.version {
				fmt.Printf("qaz - Version %s"+"\n", version)
				return
			}

			cmd.Help()
		},
	}
)

Functions

func Configure

func Configure(confSource string, conf string) (err error)

Configure parses the config file abd setos stacjs abd ebv

func GetSession

func GetSession(options ...func(*session.Options)) (*session.Session, error)

GetSession - Returns aws session based on default run.profile and run.Region options can be overwritten by passing a function: func(*session.Options)

Types

This section is empty.

Jump to

Keyboard shortcuts

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