From 4fd7d530618f8356def7aedc187b0efe4db9d891 Mon Sep 17 00:00:00 2001 From: Ben Jackson Date: Thu, 24 Oct 2024 15:50:53 +1100 Subject: [PATCH] chore: address more linting issues (#394) --- cmd/config.go | 2 +- cmd/root.go | 2 +- cmd/ssh.go | 7 ++++++- cmd/users.go | 1 - cmd/web.go | 2 +- pkg/lagoon/ssh/main.go | 4 ++-- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index dde5bfa4..e012b958 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -215,7 +215,7 @@ var configDeleteCmd = &cobra.Command{ if lagoonConfig.Lagoon == "" { fmt.Println("Missing arguments: Lagoon name is not defined") - cmd.Help() + _ = cmd.Help() os.Exit(1) } if yesNo(fmt.Sprintf("You are attempting to delete config for lagoon '%s', are you sure?", lagoonConfig.Lagoon)) { diff --git a/cmd/root.go b/cmd/root.go index af4711b3..80c2c752 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -106,7 +106,7 @@ var rootCmd = &cobra.Command{ displayVersionInfo() return } - cmd.Help() + _ = cmd.Help() os.Exit(1) }, } diff --git a/cmd/ssh.go b/cmd/ssh.go index 7c585b21..38d9a404 100644 --- a/cmd/ssh.go +++ b/cmd/ssh.go @@ -76,7 +76,12 @@ var sshEnvCmd = &cobra.Command{ HostKeyCallback: hkcb, HostKeyAlgorithms: hkalgo, } - defer closeSSHAgent() + defer func() { + err = closeSSHAgent() + if err != nil { + fmt.Fprintf(os.Stderr, "error closing ssh agent:%v\n", err) + } + }() if sshCommand != "" { err = lagoonssh.RunSSHCommand(sshConfig, sshService, sshContainer, sshCommand, config) } else { diff --git a/cmd/users.go b/cmd/users.go index 646da1cc..129eb18d 100644 --- a/cmd/users.go +++ b/cmd/users.go @@ -311,7 +311,6 @@ var updateUserCmd = &cobra.Command{ return err } if firstName == "" && lastName == "" && emailAddress == "" { - cmd.Help() output.RenderError("Missing arguments: Nothing to update, please provide a field to update", outputOptions) return nil } diff --git a/cmd/web.go b/cmd/web.go index e052a5a0..0e61338a 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -17,7 +17,7 @@ var webCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { if cmdProjectName == "" { fmt.Println("Missing arguments: Project name is not defined") - cmd.Help() + _ = cmd.Help() os.Exit(1) } diff --git a/pkg/lagoon/ssh/main.go b/pkg/lagoon/ssh/main.go index ee938019..64136a8d 100644 --- a/pkg/lagoon/ssh/main.go +++ b/pkg/lagoon/ssh/main.go @@ -43,13 +43,13 @@ func LogStream(config *ssh.ClientConfig, host, port string, argv []string) error func InteractiveSSH(lagoon map[string]string, sshService string, sshContainer string, config *ssh.ClientConfig) error { client, err := ssh.Dial("tcp", lagoon["hostname"]+":"+lagoon["port"], config) if err != nil { - return fmt.Errorf("Failed to dial: " + err.Error() + "\nCheck that the project or environment you are trying to connect to exists") + return fmt.Errorf("failed to dial: %s\nCheck that the project or environment you are trying to connect to exists", err.Error()) } // start the session session, err := client.NewSession() if err != nil { - return fmt.Errorf("Failed to create session: " + err.Error()) + return fmt.Errorf("failed to create session: %s", err.Error()) } defer session.Close() session.Stdout = os.Stdout