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

refectoring: replacing deprecated packages #1027

Merged
merged 1 commit into from
Jul 3, 2024
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
6 changes: 3 additions & 3 deletions cli/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type Cli struct {
rootCmd *cobra.Command
}

//NewCli returns the cli instance used to register and execute command
// NewCli returns the cli instance used to register and execute command
func NewCli() *Cli {
cli := &Cli{
rootCmd: &cobra.Command{
Expand All @@ -36,7 +36,7 @@ func NewCli() *Cli {
Long: "An easy to use and powerful chaos engineering experiment toolkit",
},
}
cli.rootCmd.SetOutput(os.Stdout)
cli.rootCmd.SetOut(os.Stdout)
cli.setFlags()
return cli
}
Expand All @@ -48,7 +48,7 @@ func (cli *Cli) setFlags() {
//flags.StringVarP(&util.LogLevel, "log-level", "l", "info", "level of logging wanted. 1=DEBUG, 0=INFO, -1=WARN, A higher verbosity level means a log message is less important.")
}

//Run command
// Run command
func (cli *Cli) Run() error {
return cli.rootCmd.Execute()
}
2 changes: 1 addition & 1 deletion cli/cmd/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

func TestCli_Run(t *testing.T) {
cli := NewCli()
cli.rootCmd.SetOutput(&bytes.Buffer{})
cli.rootCmd.SetOut(&bytes.Buffer{})

err := cli.Run()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/cmd/prepare_jvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
func TestPrepareJvmCommand_Run(t *testing.T) {
jvmCommand := &PrepareJvmCommand{}
jvmCommand.Init()
jvmCommand.command.SetOutput(&bytes.Buffer{})
jvmCommand.command.SetOut(&bytes.Buffer{})
jvmCommand.command.RunE = func(cmd *cobra.Command, args []string) error {
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/query_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestQueryDiskCommand_queryDiskInfo(t *testing.T) {

func testQueryDiskUnknownArg(t *testing.T, command *cobra.Command, qdc *QueryDiskCommand) {
buffer := &bytes.Buffer{}
command.SetOutput(buffer)
command.SetOut(buffer)

arg := "unknown"
expectedErr := fmt.Errorf("the %s argument not found", arg)
Expand All @@ -50,7 +50,7 @@ func testQueryDiskUnknownArg(t *testing.T, command *cobra.Command, qdc *QueryDis

func testQueryDiskDevice(t *testing.T, command *cobra.Command, qdc *QueryDiskCommand) {
buffer := &bytes.Buffer{}
command.SetOutput(buffer)
command.SetOut(buffer)

arg := "mount-point"
err := qdc.queryDiskInfo(command, arg)
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/query_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestQueryNetworkCommand_queryNetworkInfo(t *testing.T) {

func testQueryNetworkUnknownArg(t *testing.T, command *cobra.Command, qnc *QueryNetworkCommand) {
buffer := &bytes.Buffer{}
command.SetOutput(buffer)
command.SetOut(buffer)

arg := "unknown"
expectedErr := fmt.Errorf("the %s argument not found", arg)
Expand All @@ -50,7 +50,7 @@ func testQueryNetworkUnknownArg(t *testing.T, command *cobra.Command, qnc *Query

func testQueryNetworkInterface(t *testing.T, command *cobra.Command, qnc *QueryNetworkCommand) {
buffer := &bytes.Buffer{}
command.SetOutput(buffer)
command.SetOut(buffer)

arg := "interface"
err := qnc.queryNetworkInfo(command, arg)
Expand Down
4 changes: 2 additions & 2 deletions cli/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/chaosblade-io/chaosblade-spec-go/spec"
"github.com/chaosblade-io/chaosblade-spec-go/util"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

const (
Expand Down Expand Up @@ -107,7 +107,7 @@ func (sc *StatusCommand) runStatus(command *cobra.Command, args []string) error
}
response := spec.ReturnSuccess(result)

if terminal.IsTerminal(int(os.Stdout.Fd())) {
if term.IsTerminal(int(os.Stdout.Fd())) {
bytes, err := json.MarshalIndent(response, "", "\t")
if err != nil {
return response
Expand Down