From b9680a4f324b961a5ca5d7c05dd0e0f133d93d41 Mon Sep 17 00:00:00 2001 From: gouglhupf Date: Thu, 30 Sep 2021 15:31:25 +0200 Subject: [PATCH] Add cli config flag --- internal/cmd/deploy/deploy.go | 80 ++++++++++++++++++++++++++++-- internal/cmd/deploy/deploy_test.go | 27 +++++++++- 2 files changed, 101 insertions(+), 6 deletions(-) diff --git a/internal/cmd/deploy/deploy.go b/internal/cmd/deploy/deploy.go index 4bfce67a..1c34b906 100644 --- a/internal/cmd/deploy/deploy.go +++ b/internal/cmd/deploy/deploy.go @@ -3,6 +3,7 @@ package deploy import ( "errors" "fmt" + "io/ioutil" "path/filepath" "regexp" @@ -12,15 +13,22 @@ import ( "github.com/aws-cloudformation/rain/internal/console" "github.com/aws-cloudformation/rain/internal/console/spinner" "github.com/aws-cloudformation/rain/internal/ui" + "gopkg.in/yaml.v3" "github.com/aws/smithy-go/ptr" "github.com/spf13/cobra" ) +type configFileFormat struct { + Parameters map[string]string `yaml:"Parameters"` + Tags map[string]string `yaml:"Tags"` +} + var detach bool var yes bool var params []string var tags []string +var configFilePath string var terminationProtection bool var keep bool @@ -33,7 +41,32 @@ If you don't specify a stack name, rain will use the template filename minus its If a template needs to be packaged before it can be deployed, rain will package the template first. Rain will attempt to create an S3 bucket to store artifacts that it packages and deploys. -The bucket's name will be of the format rain-artifacts--`, +The bucket's name will be of the format rain-artifacts--. + +The config flag can be used to programmatically set tags and parameters. +The format is similar to the "Template configuration file" for AWS CodePipeline just without the +'StackPolicy' key. The file can be in YAML or JSON format. + +JSON: +{ + "Parameters" : { + "NameOfTemplateParameter" : "ValueOfParameter", + ... + }, + "Tags" : { + "TagKey" : "TagValue", + ... + } +} + +YAML: +Parameters: + NameOfTemplateParameter: ValueOfParameter + ... +Tags: + TagKey: TagValue + ... +`, Args: cobra.RangeArgs(1, 2), DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { @@ -56,10 +89,46 @@ The bucket's name will be of the format rain-artifacts----- + // The bucket's name will be of the format rain-artifacts--. + // + // The config flag can be used to programmatically set tags and parameters. + // The format is similar to the "Template configuration file" for AWS CodePipeline just without the + // 'StackPolicy' key. The file can be in YAML or JSON format. + // + // JSON: + // { + // "Parameters" : { + // "NameOfTemplateParameter" : "ValueOfParameter", + // ... + // }, + // "Tags" : { + // "TagKey" : "TagValue", + // ... + // } + // } + // + // YAML: + // Parameters: + // NameOfTemplateParameter: ValueOfParameter + // ... + // Tags: + // TagKey: TagValue + // ... // // Usage: // deploy