Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IZE-514 allowed to view the text as is #508

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/bastion-tunnel-monorepo/.ize/env/testnut/ize.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/ecs-apps-monorepo/.ize/env/testnut/ize.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/multistate-monorepo/.ize/env/testnut/ize.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/sls-apps-monorepo/.ize/env/testnut/ize.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 9 additions & 8 deletions internal/commands/console_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
17 changes: 9 additions & 8 deletions internal/commands/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down
13 changes: 7 additions & 6 deletions internal/commands/ize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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(`
Expand Down Expand Up @@ -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)")
Expand Down
11 changes: 6 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package config

import (
"fmt"
"github.com/hazelops/ize/internal/schema"
"github.com/mitchellh/mapstructure"
"github.com/spf13/cobra"
"os"
"os/exec"
"path/filepath"
"reflect"
"strings"
"text/template"

"github.com/hazelops/ize/internal/schema"
"github.com/mitchellh/mapstructure"
"github.com/spf13/cobra"

"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/hazelops/ize/internal/aws/utils"
Expand Down Expand Up @@ -240,7 +241,7 @@ func InitConfig() {
viper.SetDefault("TERRAFORM_VERSION", "1.1.3")
viper.SetDefault("PREFER_RUNTIME", "native")
viper.SetDefault("CUSTOM_PROMPT", false)
viper.SetDefault("PLAIN_TEXT", false)
viper.SetDefault("PLAIN_TEXT_OUTPUT", false)

home, err := os.UserHomeDir()
if err != nil {
Expand Down Expand Up @@ -541,7 +542,7 @@ func structToMap(item interface{}) map[string]interface{} {
return res
}

//GetApps returns a list of application names in the directory for shell completions
// GetApps returns a list of application names in the directory for shell completions
func GetApps(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
var apps []string

Expand Down
2 changes: 1 addition & 1 deletion internal/config/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
4 changes: 2 additions & 2 deletions internal/schema/ize-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"type": "string",
"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.",
"plain_text_output": {
"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"
Expand Down
5 changes: 1 addition & 4 deletions pkg/terminal/noninteractive.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"io"
"os"
"regexp"
"strings"
"sync"
"text/tabwriter"
Expand Down Expand Up @@ -268,7 +267,5 @@ type stripAnsiWriter struct {
}

func (w *stripAnsiWriter) Write(p []byte) (n int, err error) {
return w.Next.Write(reAnsi.ReplaceAll(p, []byte{}))
return w.Next.Write(p)
}

var reAnsi = regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))")
4 changes: 2 additions & 2 deletions test-e2e/ecs_apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down