diff --git a/go.mod b/go.mod index d880d282..79e27415 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/brevdev/brev-cli -go 1.22.6 +go 1.24.0 require ( github.com/alessio/shellescape v1.4.1 @@ -142,7 +142,7 @@ require ( github.com/xlab/treeprint v1.2.0 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect golang.org/x/net v0.34.0 // indirect - golang.org/x/oauth2 v0.21.0 // indirect + golang.org/x/oauth2 v0.34.0 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/term v0.28.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index 0baa56c5..0441ead5 100644 --- a/go.sum +++ b/go.sum @@ -545,8 +545,8 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/pkg/cmd/configureenvvars/configureenvvars_test.go b/pkg/cmd/configureenvvars/configureenvvars_test.go index 01272f04..3831db12 100644 --- a/pkg/cmd/configureenvvars/configureenvvars_test.go +++ b/pkg/cmd/configureenvvars/configureenvvars_test.go @@ -148,7 +148,7 @@ export ` + BrevManagedEnvVarsKey + "=foo", got := generateExportString(tt.args.brevEnvsString, tt.args.envFileContents) diff := cmp.Diff(tt.want, got) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%v", diff) } }) } @@ -234,7 +234,7 @@ func Test_addUnsetEntriesToOutput(t *testing.T) { got := addUnsetEntriesToOutput(tt.args.currentEnvs, tt.args.newEnvs, tt.args.output) diff := cmp.Diff(tt.want, got) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%v", diff) } }) } diff --git a/pkg/cmd/configureenvvars/lex_test.go b/pkg/cmd/configureenvvars/lex_test.go index 56cc3a7a..e8fca030 100644 --- a/pkg/cmd/configureenvvars/lex_test.go +++ b/pkg/cmd/configureenvvars/lex_test.go @@ -703,7 +703,7 @@ alice=bob`, } diff := cmp.Diff(out, tt.want, cmp.AllowUnexported(item{})) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%v", diff) } }) } diff --git a/pkg/cmd/connect/connect.go b/pkg/cmd/connect/connect.go index dbb26346..776b0886 100644 --- a/pkg/cmd/connect/connect.go +++ b/pkg/cmd/connect/connect.go @@ -35,7 +35,7 @@ func NewCmdConnect(t *terminal.Terminal, store connectStore) *cobra.Command { func RunConnect(t *terminal.Terminal, _ []string, _ connectStore) error { t.Vprintf("Connect the AWS IAM user to create instances in your AWS account.\n") - t.Vprintf(t.Yellow("\tFollow the guide here: %s", "https://onboarding.brev.dev/connect-aws\n\n")) + t.Vprintf("%v", t.Yellow("\tFollow the guide here: %s", "https://onboarding.brev.dev/connect-aws\n\n")) // t.Vprintf(t.Yellow("Connect the AWS IAM user to create dev environments in your AWS account.\n\n")) AccessKeyID := terminal.PromptGetInput(terminal.PromptContent{ @@ -50,8 +50,8 @@ func RunConnect(t *terminal.Terminal, _ []string, _ connectStore) error { }) t.Vprintf("\n") - t.Vprintf(AccessKeyID) - t.Vprintf(SecretAccessKey) + t.Vprintf("%v", AccessKeyID) + t.Vprintf("%v", SecretAccessKey) return nil } diff --git a/pkg/cmd/copy/copy.go b/pkg/cmd/copy/copy.go index f919de49..e0abb17e 100644 --- a/pkg/cmd/copy/copy.go +++ b/pkg/cmd/copy/copy.go @@ -275,7 +275,7 @@ func startWorkspaceIfStopped(t *terminal.Terminal, s *spinner.Spinner, tstore Co if err != nil { return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) + t.Vprintf("%s", t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) err = pollUntil(s, workspace.ID, entity.Running, tstore, " hang tight 🤙") if err != nil { return breverrors.WrapAndTrace(err) diff --git a/pkg/cmd/create/create.go b/pkg/cmd/create/create.go index 8a82f266..185d26aa 100644 --- a/pkg/cmd/create/create.go +++ b/pkg/cmd/create/create.go @@ -175,9 +175,9 @@ func resolveWorkspaceUserOptions(options *store.CreateWorkspacesOptions, user *e } func displayConnectBreadCrumb(t *terminal.Terminal, workspace *entity.Workspace) { - t.Vprintf(t.Green("Connect to the instance:\n")) - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open -> open instance in VS Code\n", workspace.Name))) - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell -> ssh into instance (shortcut)\n", workspace.Name))) + t.Vprintf("%v",t.Green("Connect to the instance:\n")) + t.Vprintf("%v", t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open -> open instance in VS Code\n", workspace.Name))) + t.Vprintf("%v", t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell -> ssh into instance (shortcut)\n", workspace.Name))) // t.Vprintf(t.Yellow(fmt.Sprintf("\tssh %s\t# ssh -> ssh directly to dev environment\n", workspace.GetLocalIdentifier()))) } diff --git a/pkg/cmd/fu/fu.go b/pkg/cmd/fu/fu.go index 30c9513a..74091c32 100644 --- a/pkg/cmd/fu/fu.go +++ b/pkg/cmd/fu/fu.go @@ -88,8 +88,8 @@ func fuUser(userID string, t *terminal.Terminal, fuStore FuStore) error { for _, workspace := range allWorkspaces { _, err2 := fuStore.DeleteWorkspace(workspace.ID) if err2 != nil { - t.Vprintf(t.Red("Failed to delete workspace with ID: %s\n", workspace.ID)) - t.Vprintf(t.Red("Error: %s\n", err.Error())) + t.Vprintf("%s", t.Red("Failed to delete workspace with ID: %s\n", workspace.ID)) + t.Vprintf("%s", t.Red("Error: %s\n", err.Error())) continue } t.Vprintf("✅ Deleted workspace %s\n", workspace.Name) @@ -97,8 +97,8 @@ func fuUser(userID string, t *terminal.Terminal, fuStore FuStore) error { err = fuStore.BanUser(userID) if err != nil { - t.Vprintf(t.Red("Failed to ban user with ID: %s\n", userID)) - t.Vprintf(t.Red("Error: %s\n", err.Error())) + t.Vprintf("%s", t.Red("Failed to ban user with ID: %s\n", userID)) + t.Vprintf("%s", t.Red("Error: %s\n", err.Error())) } t.Vprint("\n") t.Vprintf("🖕 Banned user %s\n", userID) diff --git a/pkg/cmd/login/login.go b/pkg/cmd/login/login.go index 8755ebd3..792a0c6b 100644 --- a/pkg/cmd/login/login.go +++ b/pkg/cmd/login/login.go @@ -310,26 +310,26 @@ func (o LoginOptions) showBreadCrumbs(t *terminal.Terminal, org *entity.Organiza } } - t.Vprintf(t.Green("current organization: ") + t.Yellow(fmt.Sprintf("%s\n", org.Name))) + t.Vprintf("%s", t.Green("current organization: ") + t.Yellow(fmt.Sprintf("%s\n", org.Name))) if len(orgs) > 1 { otherOrg := getOtherOrg(org, orgs) - t.Vprintf(t.Green("switch organizations:\n")) - t.Vprintf(t.Yellow("\tbrev set %s\n", otherOrg.Name)) + t.Vprintf("%s", t.Green("switch organizations:\n")) + t.Vprintf("%s", t.Yellow("\tbrev set %s\n", otherOrg.Name)) } if len(allWorkspaces) == 0 { - t.Vprintf(t.Green("create an instance:\n")) + t.Vprintf("%s", t.Green("create an instance:\n")) } if len(userWorkspaces) == 0 && len(allWorkspaces) > 1 { - t.Vprintf(t.Green("list teammates instances:\n")) - t.Vprintf(t.Yellow("\tbrev ls --all\n")) + t.Vprintf("%s", t.Green("list teammates instances:\n")) + t.Vprintf("%s", t.Yellow("\tbrev ls --all\n")) - t.Vprintf(t.Green("clone a teammate's instance:\n")) - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev start %s\n", allWorkspaces[0].Name))) + t.Vprintf("%s", t.Green("clone a teammate's instance:\n")) + t.Vprintf("%s", t.Yellow(fmt.Sprintf("\tbrev start %s\n", allWorkspaces[0].Name))) } if len(userWorkspaces) > 0 { - t.Vprintf(t.Green("list your instances:\n")) - t.Vprintf(t.Yellow("\tbrev ls\n")) + t.Vprintf("%s", t.Green("list your instances:\n")) + t.Vprintf("%s", t.Yellow("\tbrev ls\n")) } return nil diff --git a/pkg/cmd/ls/ls.go b/pkg/cmd/ls/ls.go index 8c272d80..85806589 100644 --- a/pkg/cmd/ls/ls.go +++ b/pkg/cmd/ls/ls.go @@ -248,10 +248,10 @@ func (ls Ls) RunOrgs() error { displayOrgTable(ls.terminal, orgs, defaultOrg) if len(orgs) > 1 { fmt.Print("\n") - ls.terminal.Vprintf(ls.terminal.Green("Switch orgs:\n")) + ls.terminal.Vprintf("%s", ls.terminal.Green("Switch orgs:\n")) notDefaultOrg := getOtherOrg(orgs, *defaultOrg) // TODO suggest org with max workspaces - ls.terminal.Vprintf(ls.terminal.Yellow("\tbrev set ex: brev set %s\n", notDefaultOrg.Name)) + ls.terminal.Vprintf("%s", ls.terminal.Yellow("\tbrev set ex: brev set %s\n", notDefaultOrg.Name)) } return nil @@ -307,15 +307,15 @@ func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []enti if len(userWorkspaces) == 0 { ls.terminal.Vprint(ls.terminal.Yellow("No instances in org %s\n", org.Name)) if len(allWorkspaces) > 0 { - ls.terminal.Vprintf(ls.terminal.Green("See teammates' instances:\n")) - ls.terminal.Vprintf(ls.terminal.Yellow("\tbrev ls --all\n")) + ls.terminal.Vprintf("%s", ls.terminal.Green("See teammates' instances:\n")) + ls.terminal.Vprintf("%s", ls.terminal.Yellow("\tbrev ls --all\n")) } else { - ls.terminal.Vprintf(ls.terminal.Green("Start a new instance:\n")) + ls.terminal.Vprintf("%s", ls.terminal.Green("Start a new instance:\n")) } if len(otherOrgs) > 1 { - ls.terminal.Vprintf(ls.terminal.Green("Switch to another org:\n")) + ls.terminal.Vprintf("%s", ls.terminal.Green("Switch to another org:\n")) // TODO suggest org with max workspaces - ls.terminal.Vprintf(ls.terminal.Yellow(fmt.Sprintf("\tbrev set %s\n", getOtherOrg(otherOrgs, *org).Name))) + ls.terminal.Vprintf("%s", ls.terminal.Yellow(fmt.Sprintf("\tbrev set %s\n", getOtherOrg(otherOrgs, *org).Name))) } } else { ls.terminal.Vprintf("You have %d instances in Org "+ls.terminal.Yellow(org.Name)+"\n", len(userWorkspaces)) @@ -333,14 +333,14 @@ func displayLsResetBreadCrumb(t *terminal.Terminal, workspaces []entity.Workspac for _, w := range workspaces { if w.Status == entity.Failure || getWorkspaceDisplayStatus(w) == entity.Unhealthy { if !foundAResettableWorkspace { - t.Vprintf(t.Red("Reset unhealthy or failed instance:\n")) + t.Vprintf("%s", t.Red("Reset unhealthy or failed instance:\n")) } - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev reset %s\n", w.Name))) + t.Vprintf("%s", t.Yellow(fmt.Sprintf("\tbrev reset %s\n", w.Name))) foundAResettableWorkspace = true } } if foundAResettableWorkspace { - t.Vprintf(t.Yellow("If this problem persists, run the command again with the --hard flag (warning: the --hard flag will not preserve uncommitted files!) \n\n")) + t.Vprintf("%s", t.Yellow("If this problem persists, run the command again with the --hard flag (warning: the --hard flag will not preserve uncommitted files!) \n\n")) } } @@ -386,12 +386,12 @@ func displayProjects(t *terminal.Terminal, orgName string, projects []virtualpro displayProjectsTable(projects) fmt.Print("\n") - t.Vprintf(t.Green("Join a project:\n") + + t.Vprint(t.Green("Join a project:\n") + t.Yellow(fmt.Sprintf("\tbrev start %s\n", projects[0].Name))) } else { t.Vprintf("no other projects in Org "+t.Yellow(orgName)+"\n", len(projects)) fmt.Print("\n") - t.Vprintf(t.Green("Invite a teamate:\n") + + t.Vprint(t.Green("Invite a teamate:\n") + t.Yellow("\tbrev invite")) } } diff --git a/pkg/cmd/ollama/ollama.go b/pkg/cmd/ollama/ollama.go index d02bbdc1..c65fd7e3 100644 --- a/pkg/cmd/ollama/ollama.go +++ b/pkg/cmd/ollama/ollama.go @@ -255,8 +255,8 @@ func runOllamaWorkspace(t *terminal.Terminal, opts RunOptions, ollamaStore Ollam } func displayOllamaConnectBreadCrumb(t *terminal.Terminal, link string, model string) { - t.Vprintf(t.Green("Query the Ollama API with the following command:\n")) - t.Vprintf(t.Yellow(fmt.Sprintf("curl %s/api/chat -d '{\n \"model\": \"%s\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"why is the sky blue?\"\n }\n ]\n}'\n", link, model))) + t.Vprintf("%s", t.Green("Query the Ollama API with the following command:\n")) + t.Vprintf("%s", t.Yellow(fmt.Sprintf("curl %s/api/chat -d '{\n \"model\": \"%s\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"why is the sky blue?\"\n }\n ]\n}'\n", link, model))) } func pollInstanceUntilVMReady(workspace *entity.Workspace, interval time.Duration, timeout time.Duration, ollamaStore OllamaStore) (bool, error) { diff --git a/pkg/cmd/open/open.go b/pkg/cmd/open/open.go index 3b51e42f..f0691ece 100644 --- a/pkg/cmd/open/open.go +++ b/pkg/cmd/open/open.go @@ -275,7 +275,7 @@ func startWorkspaceIfStopped(t *terminal.Terminal, tstore OpenStore, wsIDOrName if err != nil { return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) + t.Vprintf("%s", t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) workspace, err = util.GetUserWorkspaceByNameOrIDErr(tstore, wsIDOrName) if err != nil { return breverrors.WrapAndTrace(err) diff --git a/pkg/cmd/org/org.go b/pkg/cmd/org/org.go index 36eb3de4..7e0a8dfb 100644 --- a/pkg/cmd/org/org.go +++ b/pkg/cmd/org/org.go @@ -121,10 +121,10 @@ func RunOrgs(t *terminal.Terminal, store OrgCmdStore) error { displayOrgTable(t, orgs, defaultOrg) if len(orgs) > 1 { fmt.Print("\n") - t.Vprintf(t.Green("Switch orgs:\n")) + t.Vprintf("%s", t.Green("Switch orgs:\n")) notDefaultOrg := getOtherOrg(orgs, *defaultOrg) // TODO suggest org with max workspaces - t.Vprintf(t.Yellow("\tbrev org set ex: brev org set %s\n", notDefaultOrg.Name)) + t.Vprintf("%s", t.Yellow("\tbrev org set ex: brev org set %s\n", notDefaultOrg.Name)) } return nil diff --git a/pkg/cmd/portforward/portforward.go b/pkg/cmd/portforward/portforward.go index e4b117b3..70bfbd26 100644 --- a/pkg/cmd/portforward/portforward.go +++ b/pkg/cmd/portforward/portforward.go @@ -155,7 +155,7 @@ func startInput(t *terminal.Terminal) string { port := localInput + ":" + remoteInput - t.Vprintf(t.Green("\n-p " + port + "\n")) + t.Vprintf("%s", t.Green("\n-p "+port+"\n")) return port } diff --git a/pkg/cmd/recreate/recreate.go b/pkg/cmd/recreate/recreate.go index aa0e0a01..f9a481b3 100644 --- a/pkg/cmd/recreate/recreate.go +++ b/pkg/cmd/recreate/recreate.go @@ -129,7 +129,7 @@ func hardResetCreateWorkspaceFromRepo(t *terminal.Terminal, recreateStore recrea } t.Vprint(t.Green("\nYour instance is ready!")) - t.Vprintf(t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) + t.Vprintf("%s", t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) return nil } @@ -178,7 +178,7 @@ func hardResetCreateEmptyWorkspace(t *terminal.Terminal, recreateStore recreateS } t.Vprint(t.Green("\nYour instance is ready!")) - t.Vprintf(t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) + t.Vprintf("%s", t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) return nil } diff --git a/pkg/cmd/refresh/refresh.go b/pkg/cmd/refresh/refresh.go index 3ec9c3eb..8499156a 100644 --- a/pkg/cmd/refresh/refresh.go +++ b/pkg/cmd/refresh/refresh.go @@ -49,7 +49,7 @@ func NewCmdRefresh(t *terminal.Terminal, store RefreshStore) *cobra.Command { if err != nil { return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Green("brev has been refreshed\n")) + t.Vprintf("%s", t.Green("brev has been refreshed\n")) return nil }, } diff --git a/pkg/cmd/reset/reset.go b/pkg/cmd/reset/reset.go index 9e8afb26..b2ff61c0 100644 --- a/pkg/cmd/reset/reset.go +++ b/pkg/cmd/reset/reset.go @@ -138,7 +138,7 @@ func hardResetCreateWorkspaceFromRepo(t *terminal.Terminal, resetStore ResetStor } t.Vprint(t.Green("\nYour instance is ready!")) - t.Vprintf(t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) + t.Vprintf("%s", t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) return nil } @@ -187,7 +187,7 @@ func hardResetCreateEmptyWorkspace(t *terminal.Terminal, resetStore ResetStore, } t.Vprint(t.Green("\nYour instance is ready!")) - t.Vprintf(t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) + t.Vprintf("%s", t.Green("\nSSH into your machine:\n\tssh %s\n", w.GetLocalIdentifier())) return nil } @@ -245,7 +245,7 @@ func resetWorkspace(workspaceName string, t *terminal.Terminal, resetStore Reset return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Yellow("Instance %s is resetting.\n", startedWorkspace.Name)) + t.Vprintf("%s", t.Yellow("Instance %s is resetting.\n", startedWorkspace.Name)) t.Vprintf("Note: this can take a few seconds. Run 'brev ls' to check status\n") return nil diff --git a/pkg/cmd/secret/secret.go b/pkg/cmd/secret/secret.go index 703ebfd4..50e8ae38 100644 --- a/pkg/cmd/secret/secret.go +++ b/pkg/cmd/secret/secret.go @@ -83,7 +83,7 @@ func NewCmdSecret(secretStore SecretStore, t *terminal.Terminal) *cobra.Command func addSecret(secretStore SecretStore, t *terminal.Terminal, envtype string, name string, value string, path string, scope string) error { //nolint:funlen, gocyclo // todo simplify me if name == "" || envtype == "" || value == "" || path == "" { - t.Vprintf(t.Yellow("\nSome flags omitted, running interactive mode!\n")) + t.Vprintf("%s", t.Yellow("\nSome flags omitted, running interactive mode!\n")) } if name == "" { @@ -191,14 +191,14 @@ func addSecret(secretStore SecretStore, t *terminal.Terminal, envtype string, na secret, err := secretStore.CreateSecret(b) if err != nil { s.Stop() - t.Vprintf(t.Red(err.Error())) + t.Vprintf("%s", t.Red(err.Error())) return breverrors.WrapAndTrace(err) } - t.Vprintf(secret.Name) + t.Vprint(secret.Name) s.Suffix = " environment secret added" s.Stop() - t.Vprintf(t.Green("\nEnvironment %s added\n", iType) + t.Yellow("\tNote: It might take up to 2 minutes to load into your environment.")) + t.Vprintf("%s", t.Green("\nEnvironment %s added\n", iType)+t.Yellow("\tNote: It might take up to 2 minutes to load into your environment.")) return nil } diff --git a/pkg/cmd/shell/shell.go b/pkg/cmd/shell/shell.go index b49bb6de..49474ad3 100644 --- a/pkg/cmd/shell/shell.go +++ b/pkg/cmd/shell/shell.go @@ -196,7 +196,7 @@ func startWorkspaceIfStopped(t *terminal.Terminal, s *spinner.Spinner, tstore Sh if err != nil { return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) + t.Vprintf("%s", t.Yellow("Instance %s is starting. \n\n", startedWorkspace.Name)) err = pollUntil(s, workspace.ID, entity.Running, tstore, " hang tight 🤙") if err != nil { return breverrors.WrapAndTrace(err) diff --git a/pkg/cmd/sshkeys/sshkeys.go b/pkg/cmd/sshkeys/sshkeys.go index a0c18987..a31e8603 100644 --- a/pkg/cmd/sshkeys/sshkeys.go +++ b/pkg/cmd/sshkeys/sshkeys.go @@ -44,11 +44,11 @@ func NewCmdSSHKeys(t *terminal.Terminal, sshKeyStore SSHKeyStore) *cobra.Command } func DisplaySSHKeys(t *terminal.Terminal, publicKey string) { - t.Vprintf(publicKey) + t.Vprintf("%s", publicKey) t.Print("\n") - t.Eprintf(t.Yellow("Copy 👆 and add it to your git provider:\n")) - t.Eprintf(t.Yellow("\tGithub: https://github.com/settings/keys\n")) - t.Eprintf(t.Yellow("\tGitlab: https://gitlab.com/-/profile/keys\n")) - t.Eprintf(t.Yellow("Check authentication by starting a new instance\n")) - t.Eprintf(t.Yellow("\tbrev start --empty --name test-ssh && brev delete test-ssh\n")) + t.Eprintf("%s", t.Yellow("Copy 👆 and add it to your git provider:\n")) + t.Eprintf("%s", t.Yellow("\tGithub: https://github.com/settings/keys\n")) + t.Eprintf("%s", t.Yellow("\tGitlab: https://gitlab.com/-/profile/keys\n")) + t.Eprintf("%s", t.Yellow("Check authentication by starting a new instance\n")) + t.Eprintf("%s", t.Yellow("\tbrev start --empty --name test-ssh && brev delete test-ssh\n")) } diff --git a/pkg/cmd/start/start.go b/pkg/cmd/start/start.go index 77437dd2..4fa9c770 100644 --- a/pkg/cmd/start/start.go +++ b/pkg/cmd/start/start.go @@ -250,7 +250,7 @@ func maybeStartEmpty(t *terminal.Terminal, user *entity.User, options StartOptio func startWorkspaceFromPath(user *entity.User, t *terminal.Terminal, options StartOptions, startStore StartStore) error { pathExists := allutil.DoesPathExist(options.RepoOrPathOrNameOrID) if !pathExists { - return fmt.Errorf(strings.Join([]string{"Path:", options.RepoOrPathOrNameOrID, "does not exist."}, " ")) + return fmt.Errorf("%s", strings.Join([]string{"Path:", options.RepoOrPathOrNameOrID, "does not exist."}, " ")) } var gitpath string if options.RepoOrPathOrNameOrID == "." { @@ -260,7 +260,7 @@ func startWorkspaceFromPath(user *entity.User, t *terminal.Terminal, options Sta } file, error := startStore.GetFileAsString(gitpath) if error != nil { - return fmt.Errorf(strings.Join([]string{"Could not read .git/config at", options.RepoOrPathOrNameOrID}, " ")) + return fmt.Errorf("%s", strings.Join([]string{"Could not read .git/config at", options.RepoOrPathOrNameOrID}, " ")) } // Get GitUrl var gitURL string @@ -333,7 +333,7 @@ func createEmptyWorkspace(user *entity.User, t *terminal.Terminal, options Start setupScriptContents += "\n" + contents if err1 != nil { - t.Vprintf(t.Red("Couldn't fetch setup script from %s\n", options.SetupScript) + t.Yellow("Continuing with default setup script 👍")) + t.Vprint(t.Red("Couldn't fetch setup script from %s\n", options.SetupScript) + t.Yellow("Continuing with default setup script 👍")) return breverrors.WrapAndTrace(err1) } } @@ -424,7 +424,7 @@ func startStopppedWorkspace(workspace *entity.Workspace, startStore StartStore, return breverrors.WrapAndTrace(err) } - t.Vprintf(t.Yellow("Instance %s is starting. \nNote: this can take about a minute. Run 'brev ls' to check status\n\n", startedWorkspace.Name)) + t.Vprintf("%s", t.Yellow("Instance %s is starting. \nNote: this can take about a minute. Run 'brev ls' to check status\n\n", startedWorkspace.Name)) // Don't poll and block the shell if detached flag is set if startOptions.Detached { @@ -507,7 +507,7 @@ func createNewWorkspaceFromGit(user *entity.User, t *terminal.Terminal, setupScr if IsURL(setupScriptURLOrPath) { contents, err1 := startStore.GetSetupScriptContentsByURL(setupScriptURLOrPath) if err1 != nil { - t.Vprintf(t.Red("Couldn't fetch setup script from %s\n", setupScriptURLOrPath) + t.Yellow("Continuing with default setup script 👍")) + t.Vprint(t.Red("Couldn't fetch setup script from %s\n", setupScriptURLOrPath) + t.Yellow("Continuing with default setup script 👍")) return breverrors.WrapAndTrace(err1) } setupScriptContents += "\n" + contents @@ -660,9 +660,9 @@ func createWorkspace(user *entity.User, t *terminal.Terminal, workspace NewWorks } func displayConnectBreadCrumb(t *terminal.Terminal, workspace *entity.Workspace) { - t.Vprintf(t.Green("Connect to the instance:\n")) - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open -> open instance in VS Code\n", workspace.Name))) - t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell -> ssh into instance (shortcut)\n", workspace.Name))) + t.Vprintf("%s", t.Green("Connect to the instance:\n")) + t.Vprintf("%s", t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open -> open instance in VS Code\n", workspace.Name))) + t.Vprintf("%s", t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell -> ssh into instance (shortcut)\n", workspace.Name))) // t.Vprintf(t.Yellow(fmt.Sprintf("\tssh %s\t# ssh -> ssh directly to instance\n", workspace.GetLocalIdentifier()))) } diff --git a/pkg/cmd/stop/stop.go b/pkg/cmd/stop/stop.go index a1c7711b..3f6ab086 100644 --- a/pkg/cmd/stop/stop.go +++ b/pkg/cmd/stop/stop.go @@ -88,7 +88,7 @@ func stopAllWorkspaces(t *terminal.Terminal, stopStore StopStore) error { if err != nil { return breverrors.WrapAndTrace(err) } else { - t.Vprintf(t.Green("\n%s stopped ✓", v.Name)) + t.Vprintf("%s", t.Green("\n%s stopped ✓", v.Name)) } } } @@ -135,10 +135,10 @@ func stopWorkspace(workspaceName string, t *terminal.Terminal, stopStore StopSto return breverrors.WrapAndTrace(err) } else { if workspaceName == "self" { - t.Vprintf(t.Green("Stopping this instance\n") + + t.Vprint(t.Green("Stopping this instance\n") + "Note: this can take a few seconds. Run 'brev ls' to check status\n") } else { - t.Vprintf(t.Green("Stopping instance "+workspaceName+".\n") + + t.Vprint(t.Green("Stopping instance "+workspaceName+".\n") + "Note: this can take a few seconds. Run 'brev ls' to check status\n") } } diff --git a/pkg/setupscript/setupscript_test.go b/pkg/setupscript/setupscript_test.go index 5f15d0e5..2dc4a52c 100644 --- a/pkg/setupscript/setupscript_test.go +++ b/pkg/setupscript/setupscript_test.go @@ -38,7 +38,7 @@ rm go.tar.gz } diff := cmp.Diff(tc.want, got) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } }) } diff --git a/pkg/ssh/sshconfigurer_test.go b/pkg/ssh/sshconfigurer_test.go index deca76c5..f38d16af 100644 --- a/pkg/ssh/sshconfigurer_test.go +++ b/pkg/ssh/sshconfigurer_test.go @@ -553,7 +553,7 @@ Host testName2-host } diff := cmp.Diff(tt.want, got) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } }) } @@ -785,7 +785,7 @@ Host testName1-host } diff := cmp.Diff(tt.linuxSSHConfig, linuxConfig) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } linuxBrevSSHConfig, err := s.store.GetFileAsString("/home/test/.brev/ssh_config") @@ -794,7 +794,7 @@ Host testName1-host } diff = cmp.Diff(tt.linuxBrevSSHConfig, linuxBrevSSHConfig) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } if tt.windowsSSHConfigExists { @@ -805,7 +805,7 @@ Host testName1-host } diff = cmp.Diff(tt.windowsSSHConfig, windowsConfig) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } windowsBrevSSHConfig, err := s.store.GetFileAsString("/mnt/c/Users/15854/.brev/ssh_config") @@ -814,7 +814,7 @@ Host testName1-host } diff = cmp.Diff(tt.windowsBrevSSHConfig, windowsBrevSSHConfig) if diff != "" { - t.Fatalf(diff) + t.Fatalf("%s", diff) } } }) diff --git a/pkg/workspacemanagerv2/containermanager.go b/pkg/workspacemanagerv2/containermanager.go index 5a563aaf..4db0548d 100644 --- a/pkg/workspacemanagerv2/containermanager.go +++ b/pkg/workspacemanagerv2/containermanager.go @@ -29,7 +29,7 @@ func (c DockerContainerManager) GetContainer(ctx context.Context, containerIdent cmd := exec.CommandContext(ctx, "docker", "container", "inspect", containerIdentifier) out, err := cmd.CombinedOutput() if err != nil { - return nil, breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return nil, breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } res := inspectResults{} @@ -57,7 +57,7 @@ func (c DockerContainerManager) StopContainer(ctx context.Context, containerIden cmd := exec.CommandContext(ctx, "docker", "container", "stop", containerIdentifier) out, err := cmd.CombinedOutput() if err != nil { - return breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } return nil } @@ -66,7 +66,7 @@ func (c DockerContainerManager) DeleteContainer(ctx context.Context, containerId cmd := exec.CommandContext(ctx, "docker", "container", "rm", containerIdentifier) out, err := cmd.CombinedOutput() if err != nil { - return breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } return nil } @@ -75,7 +75,7 @@ func (c DockerContainerManager) StartContainer(ctx context.Context, containerIde cmd := exec.CommandContext(ctx, "docker", "container", "start", containerIdentifier) out, err := cmd.CombinedOutput() if err != nil { - return breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } return nil } @@ -84,7 +84,7 @@ func (c DockerContainerManager) DeleteVolume(ctx context.Context, volumeName str cmd := exec.CommandContext(ctx, "docker", "volume", "rm", volumeName) out, err := cmd.CombinedOutput() if err != nil { - return breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } return nil } @@ -111,7 +111,7 @@ func (c DockerContainerManager) CreateContainer(ctx context.Context, options Cre cmd := exec.CommandContext(ctx, "docker", dockerArgs...) //nolint:gosec // in sandboxed env out, err := cmd.CombinedOutput() if err != nil { - return "", breverrors.WrapAndTrace(fmt.Errorf(string(out))) + return "", breverrors.WrapAndTrace(fmt.Errorf("%s", string(out))) } res := strings.Fields(string(out)) if len(res) == 0 {