From 8954b6f620cd80cba339de5c6a67d9e0e34683f9 Mon Sep 17 00:00:00 2001 From: psihachina Date: Mon, 19 Sep 2022 15:13:50 +0300 Subject: [PATCH 1/3] fixed handling of missing commands --- internal/commands/exec.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/internal/commands/exec.go b/internal/commands/exec.go index edcfa344..c7c33b76 100644 --- a/internal/commands/exec.go +++ b/internal/commands/exec.go @@ -2,25 +2,24 @@ package commands import ( "fmt" - "github.com/hazelops/ize/internal/requirements" - "strings" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ecs" "github.com/hazelops/ize/internal/config" + "github.com/hazelops/ize/internal/requirements" "github.com/hazelops/ize/pkg/ssmsession" "github.com/hazelops/ize/pkg/templates" "github.com/pterm/pterm" "github.com/sirupsen/logrus" "github.com/spf13/cobra" + "strings" ) type ExecOptions struct { Config *config.Project AppName string EcsCluster string - Command string + Command []string Task string ContainerName string } @@ -90,7 +89,9 @@ func (o *ExecOptions) Complete(cmd *cobra.Command, args []string, argsLenAtDash o.ContainerName = o.AppName } - o.Command = strings.Join(args[argsLenAtDash:], " ") + if argsLenAtDash > -1 { + o.Command = args[argsLenAtDash:] + } return nil } @@ -109,7 +110,7 @@ func (o *ExecOptions) Validate() error { } if len(o.Command) == 0 { - return fmt.Errorf("can't validate: command must be specified") + return fmt.Errorf("can't validate: you must specify at least one command for the container") } return nil @@ -156,7 +157,7 @@ func (o *ExecOptions) Run() error { Interactive: aws.Bool(true), Cluster: &o.EcsCluster, Task: &o.Task, - Command: aws.String(o.Command), + Command: aws.String(strings.Join(o.Command, " ")), }) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { From 6937d85295dde7dd380929fdd8fb082f9ba48971 Mon Sep 17 00:00:00 2001 From: psihachina Date: Mon, 19 Sep 2022 15:14:11 +0300 Subject: [PATCH 2/3] fixed detection of env parameter in 'ize terraform` command --- internal/commands/ize.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/commands/ize.go b/internal/commands/ize.go index f562df4c..fdff4970 100644 --- a/internal/commands/ize.go +++ b/internal/commands/ize.go @@ -119,14 +119,14 @@ func Execute() { } func getConfig(cfg *config.Project) { - if !(slices.Contains(os.Args, "aws-profile") || - slices.Contains(os.Args, "doc") || - slices.Contains(os.Args, "completion") || - slices.Contains(os.Args, "version") || - slices.Contains(os.Args, "init") || - slices.Contains(os.Args, "validate") || - slices.Contains(os.Args, "config")) || - slices.Contains(os.Args, "terraform") { + if slices.Contains(os.Args, "terraform") || + !(slices.Contains(os.Args, "aws-profile") || + slices.Contains(os.Args, "doc") || + slices.Contains(os.Args, "completion") || + slices.Contains(os.Args, "version") || + slices.Contains(os.Args, "init") || + slices.Contains(os.Args, "validate") || + slices.Contains(os.Args, "config")) { err := cfg.GetConfig() if err != nil { pterm.Error.Println(err) From 15f545f5ba661ea160aecde0c6b87a003701f5c3 Mon Sep 17 00:00:00 2001 From: psihachina Date: Mon, 19 Sep 2022 15:14:17 +0300 Subject: [PATCH 3/3] fixed command documentation generation --- internal/commands/doc.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/commands/doc.go b/internal/commands/doc.go index 98d6583b..1940435b 100644 --- a/internal/commands/doc.go +++ b/internal/commands/doc.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" + "os" ) func NewCmdDoc() *cobra.Command { @@ -14,8 +15,12 @@ func NewCmdDoc() *cobra.Command { Long: "Create docs with ize commands description", RunE: func(cmd *cobra.Command, args []string) error { cmd.SilenceUsage = true + err := os.MkdirAll("./website/commands", 0777) + if err != nil { + return err + } - err := doc.GenMarkdownTree(cmd.Root(), "./commands") + err = doc.GenMarkdownTree(cmd.Root(), "./website/commands") if err != nil { return err }