From 6aa72288b3e4d18884cc889f5e211c1711343351 Mon Sep 17 00:00:00 2001 From: Coen Meulenkamp Date: Fri, 15 Nov 2024 00:10:04 +0100 Subject: [PATCH] Fix s3bucket option for stackset deploy --- internal/cmd/rain/rain.go | 2 +- internal/cmd/stackset/stackset.go | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/cmd/rain/rain.go b/internal/cmd/rain/rain.go index 6dc29e8d..cb9a46cb 100644 --- a/internal/cmd/rain/rain.go +++ b/internal/cmd/rain/rain.go @@ -91,7 +91,7 @@ func init() { addCommand(stackGroup, true, false, ls.Cmd) addCommand(stackGroup, true, false, rm.Cmd) addCommand(stackGroup, true, false, watch.Cmd) - addCommand(stackGroup, true, true, stackset.StackSetCmd) + addCommand(stackGroup, true, false, stackset.StackSetCmd) // Template commands addCommand(templateGroup, true, true, bootstrap.Cmd) diff --git a/internal/cmd/stackset/stackset.go b/internal/cmd/stackset/stackset.go index d92683cb..4666ff37 100644 --- a/internal/cmd/stackset/stackset.go +++ b/internal/cmd/stackset/stackset.go @@ -1,6 +1,7 @@ package stackset import ( + "github.com/aws-cloudformation/rain/internal/aws/s3" "github.com/aws-cloudformation/rain/internal/config" "github.com/aws-cloudformation/rain/internal/console" "github.com/spf13/cobra" @@ -33,11 +34,16 @@ Use "{{.CommandPath}} [command] --help" for more information about a command.{{e var delegatedAdmin bool // addCommand adds a command to the root command. -func addCommand(profileOptions bool, c *cobra.Command) { +func addCommand(profileOptions bool, bucketOptions bool, c *cobra.Command) { if profileOptions { c.Flags().StringVarP(&config.Profile, "profile", "p", "", "AWS profile name; read from the AWS CLI configuration file") c.Flags().StringVarP(&config.Region, "region", "r", "", "AWS region to use") } + if bucketOptions { + c.Flags().StringVar(&s3.BucketName, "s3-bucket", "", "Name of the S3 bucket that is used to upload assets") + c.Flags().StringVar(&s3.BucketKeyPrefix, "s3-prefix", "", "Prefix to add to objects uploaded to S3 bucket") + c.Flags().StringVar(&s3.ExpectedBucketOwner, "s3-owner", "", "The account where S3 assets are stored") + } c.Flags().BoolVar(&delegatedAdmin, "admin", false, "Use delegated admin permissions") @@ -51,9 +57,9 @@ var StackSetCmd = &cobra.Command{ } func init() { - addCommand(true, LsCmd) - addCommand(true, DeployCmd) - addCommand(true, RmCmd) + addCommand(true, false, LsCmd) + addCommand(true, true, DeployCmd) + addCommand(true, false, RmCmd) oldUsageFunc := StackSetCmd.UsageFunc() StackSetCmd.SetUsageFunc(func(c *cobra.Command) error {