From 0bdf028a5de964121198337b1c708f1ce70bf786 Mon Sep 17 00:00:00 2001 From: Nikita Podshivalov Date: Thu, 20 Oct 2022 19:09:36 +0300 Subject: [PATCH] changed flag `plain-text` to `plain-text-output` --- .../.ize/env/testnut/ize.toml | 2 +- .../ecs-apps-monorepo/.ize/env/testnut/ize.toml | 2 +- .../.ize/env/testnut/ize.toml | 2 +- .../sls-apps-monorepo/.ize/env/testnut/ize.toml | 2 +- internal/commands/console_test.go | 17 +++++++++-------- internal/commands/exec_test.go | 17 +++++++++-------- internal/commands/ize.go | 13 +++++++------ internal/config/project.go | 2 +- internal/schema/ize-spec.json | 2 +- test-e2e/ecs_apps_test.go | 4 ++-- 10 files changed, 33 insertions(+), 30 deletions(-) diff --git a/examples/bastion-tunnel-monorepo/.ize/env/testnut/ize.toml b/examples/bastion-tunnel-monorepo/.ize/env/testnut/ize.toml index 66b815add..a065c7477 100644 --- a/examples/bastion-tunnel-monorepo/.ize/env/testnut/ize.toml +++ b/examples/bastion-tunnel-monorepo/.ize/env/testnut/ize.toml @@ -3,7 +3,7 @@ namespace = "testnut" # (required) Namespace of the project ca terraform_version = "1.2.6" # (optional) Terraform version can be set here. 1.1.3 by default # prefer_runtime = "" # (optional) Prefer a specific runtime. (native or docker) (default 'native') # tag = "" # (optional) Tag can be set statically. Normally it is being constructed automatically based on the git revision. -# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text flag. +# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag. # env = "dev" # (optional) Environment name can be specified here. Normally it should be passed via `ENV` variable or --env flag. # env_dir = "" # (optional) Environment directory can be specified here. Normally it's calculated automatically based on the directory structure convention. # docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. diff --git a/examples/ecs-apps-monorepo/.ize/env/testnut/ize.toml b/examples/ecs-apps-monorepo/.ize/env/testnut/ize.toml index 36b684ddf..070192c42 100644 --- a/examples/ecs-apps-monorepo/.ize/env/testnut/ize.toml +++ b/examples/ecs-apps-monorepo/.ize/env/testnut/ize.toml @@ -3,7 +3,7 @@ namespace = "testnut" # (required) Namespace of the project ca terraform_version = "1.2.6" # (optional) Terraform version can be set here. 1.1.3 by default # prefer_runtime = "" # (optional) Prefer a specific runtime. (native or docker) (default 'native') # tag = "" # (optional) Tag can be set statically. Normally it is being constructed automatically based on the git revision. -# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text flag. +# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag. # env = "dev" # (optional) Environment name can be specified here. Normally it should be passed via `ENV` variable or --env flag. # env_dir = "" # (optional) Environment directory can be specified here. Normally it's calculated automatically based on the directory structure convention. # docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. diff --git a/examples/multistate-monorepo/.ize/env/testnut/ize.toml b/examples/multistate-monorepo/.ize/env/testnut/ize.toml index e4df04214..f6dd17292 100644 --- a/examples/multistate-monorepo/.ize/env/testnut/ize.toml +++ b/examples/multistate-monorepo/.ize/env/testnut/ize.toml @@ -3,7 +3,7 @@ namespace = "testnut" # (required) Namespace of the project ca terraform_version = "1.2.6" # (optional) Terraform version can be set here. 1.1.3 by default # prefer_runtime = "" # (optional) Prefer a specific runtime. (native or docker) (default 'native') # tag = "" # (optional) Tag can be set statically. Normally it is being constructed automatically based on the git revision. -# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text flag. +# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag. # env = "dev" # (optional) Environment name can be specified here. Normally it should be passed via `ENV` variable or --env flag. # env_dir = "" # (optional) Environment directory can be specified here. Normally it's calculated automatically based on the directory structure convention. # docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. diff --git a/examples/sls-apps-monorepo/.ize/env/testnut/ize.toml b/examples/sls-apps-monorepo/.ize/env/testnut/ize.toml index 818133923..bc936c4bb 100644 --- a/examples/sls-apps-monorepo/.ize/env/testnut/ize.toml +++ b/examples/sls-apps-monorepo/.ize/env/testnut/ize.toml @@ -3,7 +3,7 @@ namespace = "testnut" # (required) Namespace of the project ca terraform_version = "1.2.6" # (optional) Terraform version can be set here. 1.1.3 by default # prefer_runtime = "" # (optional) Prefer a specific runtime. (native or docker) (default 'native') # tag = "" # (optional) Tag can be set statically. Normally it is being constructed automatically based on the git revision. -# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text flag. +# plain_text = false # (optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag. # env = "dev" # (optional) Environment name can be specified here. Normally it should be passed via `ENV` variable or --env flag. # env_dir = "" # (optional) Environment directory can be specified here. Normally it's calculated automatically based on the directory structure convention. # docker_registry = "" # (optional) Docker registry can be set here. By default it uses ECR repo with the name of the service. diff --git a/internal/commands/console_test.go b/internal/commands/console_test.go index f710c27c2..e9aa282ce 100644 --- a/internal/commands/console_test.go +++ b/internal/commands/console_test.go @@ -3,6 +3,11 @@ package commands import ( _ "embed" "fmt" + "os" + "path/filepath" + "strings" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ecs" @@ -12,10 +17,6 @@ import ( "github.com/hazelops/ize/pkg/mocks" "github.com/spf13/pflag" "github.com/spf13/viper" - "os" - "path/filepath" - "strings" - "testing" ) //go:generate mockgen -package=mocks -destination ../../pkg/mocks/mock_ecs.go github.com/aws/aws-sdk-go/service/ecs/ecsiface ECSAPI @@ -91,7 +92,7 @@ func TestConsole(t *testing.T) { }, { name: "failed (list tasks cluster not found)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -100,7 +101,7 @@ func TestConsole(t *testing.T) { }, { name: "failed (list tasks any err)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -109,7 +110,7 @@ func TestConsole(t *testing.T) { }, { name: "failed (execute command cluster not found)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -122,7 +123,7 @@ func TestConsole(t *testing.T) { }, { name: "failed (execute command any err)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { diff --git a/internal/commands/exec_test.go b/internal/commands/exec_test.go index 6bb4296d6..7202e8db1 100644 --- a/internal/commands/exec_test.go +++ b/internal/commands/exec_test.go @@ -3,6 +3,11 @@ package commands import ( _ "embed" "fmt" + "os" + "path/filepath" + "strings" + "testing" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ecs" @@ -12,10 +17,6 @@ import ( "github.com/hazelops/ize/pkg/mocks" "github.com/spf13/pflag" "github.com/spf13/viper" - "os" - "path/filepath" - "strings" - "testing" ) //go:generate mockgen -package=mocks -destination ../../pkg/mocks/mock_ecs.go github.com/aws/aws-sdk-go/service/ecs/ecsiface ECSAPI @@ -91,7 +92,7 @@ func TestExec(t *testing.T) { }, { name: "failed (list tasks cluster not found)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -100,7 +101,7 @@ func TestExec(t *testing.T) { }, { name: "failed (list tasks any err)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -109,7 +110,7 @@ func TestExec(t *testing.T) { }, { name: "failed (execute command cluster not found)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { @@ -122,7 +123,7 @@ func TestExec(t *testing.T) { }, { name: "failed (execute command any err)", - args: []string{"console", "goblin", "--plain-text"}, + args: []string{"console", "goblin", "--plain-text-output"}, env: map[string]string{"ENV": "test", "AWS_PROFILE": "test", "NAMESPACE": "dev-testnut", "AWS_REGION": "us-west-2"}, wantErr: true, mockECSClient: func(m *mocks.MockECSAPI) { diff --git a/internal/commands/ize.go b/internal/commands/ize.go index 264a5dc75..fa0aab6a4 100644 --- a/internal/commands/ize.go +++ b/internal/commands/ize.go @@ -3,6 +3,12 @@ package commands import ( "bytes" "fmt" + "os" + "path" + "runtime" + "strings" + "text/template" + "github.com/hazelops/ize/internal/config" "github.com/hazelops/ize/internal/version" "github.com/hazelops/ize/pkg/templates" @@ -12,11 +18,6 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" "golang.org/x/exp/slices" - "os" - "path" - "runtime" - "strings" - "text/template" ) var izeDescTpl = templates.LongDesc(` @@ -60,7 +61,7 @@ func newRootCmd(project *config.Project) *cobra.Command { cmd.CompletionOptions.DisableDefaultCmd = true cmd.PersistentFlags().StringP("log-level", "l", "", "set log level. Possible levels: info, debug, trace, panic, warn, error, fatal(default)") - cmd.PersistentFlags().Bool("plain-text", false, "enable plain text") + cmd.PersistentFlags().Bool("plain-text-output", false, "enable plain text output") cmd.PersistentFlags().StringP("config-file", "c", "", "set config file name") cmd.PersistentFlags().StringP("env", "e", "", "(required) set environment name (overrides value set in IZE_ENV / ENV if any of them are set)") cmd.PersistentFlags().StringP("aws-profile", "p", "", "(required) set AWS profile (overrides value in ize.toml and IZE_AWS_PROFILE / AWS_PROFILE if any of them are set)") diff --git a/internal/config/project.go b/internal/config/project.go index ed2dde163..bc511d227 100644 --- a/internal/config/project.go +++ b/internal/config/project.go @@ -27,7 +27,7 @@ type Project struct { Namespace string `mapstructure:",omitempty"` Env string `mapstructure:",omitempty"` LogLevel string `mapstructure:"log_level,omitempty"` - PlainText bool `mapstructure:"plain_text,omitempty"` + PlainText bool `mapstructure:"plain_text_output,omitempty"` CustomPrompt bool `mapstructure:"custom_prompt,omitempty"` PreferRuntime string `mapstructure:"prefer_runtime,omitempty"` Tag string `mapstructure:",omitempty"` diff --git a/internal/schema/ize-spec.json b/internal/schema/ize-spec.json index cbdf04bfb..413e6578a 100644 --- a/internal/schema/ize-spec.json +++ b/internal/schema/ize-spec.json @@ -39,7 +39,7 @@ "description": "(required) Namespace of the project can be specified here. It is used as a base for all naming. It can be overridden by NAMESPACE env var or --namespace flag." }, "plain_text": { - "description": "(optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text flag.", + "description": "(optional) Plain text output can be enabled here. Default is false. Can be overridden by IZE_PLAIN_TEXT env var or --plain-text-output flag.", "anyOf": [ { "type": "string" diff --git a/test-e2e/ecs_apps_test.go b/test-e2e/ecs_apps_test.go index 2783d1ed2..bcec79daf 100644 --- a/test-e2e/ecs_apps_test.go +++ b/test-e2e/ecs_apps_test.go @@ -323,7 +323,7 @@ func TestIzeExecGoblin(t *testing.T) { ize := NewBinary(t, izeBinary, examplesRootDir) - stdout, stderr, err := ize.RunPty("--plain-text", "exec", "goblin", "--", "sh -c \"echo $APP_NAME\"") + stdout, stderr, err := ize.RunPty("--plain-text-output", "exec", "goblin", "--", "sh -c \"echo $APP_NAME\"") if err != nil { t.Errorf("error: %s", err) @@ -347,7 +347,7 @@ func TestIzeExecSquibby(t *testing.T) { ize := NewBinary(t, izeBinary, examplesRootDir) - stdout, stderr, err := ize.RunPty("--plain-text", "exec", "squibby", "--", "sh -c \"echo $APP_NAME\"") + stdout, stderr, err := ize.RunPty("--plain-text-output", "exec", "squibby", "--", "sh -c \"echo $APP_NAME\"") if err != nil { t.Errorf("error: %s", err)