Skip to content

Commit

Permalink
Merge pull request #181 from brevdev/environments-to-instances
Browse files Browse the repository at this point in the history
cli dev envs to instances
  • Loading branch information
savrajs authored Jul 4, 2023
2 parents b6b86d6 + d9f651e commit 3b131e2
Show file tree
Hide file tree
Showing 30 changed files with 138 additions and 138 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![](https://uohmivykqgnnbiouffke.supabase.co/storage/v1/object/public/landingpage/createdevenv1.svg)](https://console.brev.dev/environment/new?repo=https://github.com/brevdev/brev-cli&instance=2x8)

[Brev.dev](https://brev.dev) makes it easy to develop on remote machines. Use Brev.dev to start a project and share your development environment.
[Brev.dev](https://brev.dev) makes it easy to develop on remote machines. Use Brev.dev to start a project and share your intance.

## Install the cli

Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ start a workspace using this repo as a base
brev start https://github.com/brevdev/brev-cli -n bcli-runner-0
```

open a shell in your environment
open a shell in your instance

```sh
brev shell bcli-runner-0
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
description = "golang development environment ";
description = "golang instance ";

inputs = {
flake-utils.url = "github:numtide/flake-utils";
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/clipboard/clipboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func SendToClipboard(t *terminal.Terminal, clipboardStore ClipboardStore) *cobra
Annotations: map[string]string{"clipboard": ""},
Use: "clipboard",
DisableFlagsInUseLine: true,
Short: "Copies clipboard from remote environment to local clipboard",
Long: "Copies clipboard from remote environment to local clipboard",
Short: "Copies clipboard from remote instance to local clipboard",
Long: "Copies clipboard from remote instance to local clipboard",
Example: "clipboard",
Args: cmderrors.TransformToValidationError(cobra.ExactArgs(0)),
ValidArgsFunction: completions.GetAllWorkspaceNameCompletionHandler(clipboardStore, t),
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ func NewBrevCommand() *cobra.Command { //nolint:funlen // define brev command
SilenceErrors: true,
SilenceUsage: true,
Use: "brev",
Short: "brev client for managing dev environments",
Short: "brev client for managing instances",
Long: `
brev client for managing dev environment
brev client for managing instances
Find more information at:
https://brev.dev`,
Expand Down Expand Up @@ -413,7 +413,7 @@ Examples:
{{- if hasWorkspaceCommands . }}
Dev Environment Commands:
Instance Commands:
{{- range workspaceCommands . }}
{{rpad .Name .NamePadding }} {{.Short}}
{{- end}}{{- end}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/connect/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,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 dev environments in your AWS account.\n")
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(t.Yellow("Connect the AWS IAM user to create dev environments in your AWS account.\n\n"))

Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewCmdCreate(t *terminal.Terminal, createStore CreateStore) *cobra.Command
InstanceType: gpu,
}, createStore)
if err != nil {
if strings.Contains(err.Error(), "duplicate environment with name") {
if strings.Contains(err.Error(), "duplicate instance with name") {
t.Vprint(t.Yellow("try running:"))
t.Vprint(t.Yellow("\tbrev start --name [different name] [repo] # or"))
t.Vprint(t.Yellow("\tbrev delete [name]"))
Expand Down Expand Up @@ -122,7 +122,7 @@ func createEmptyWorkspace(user *entity.User, t *terminal.Terminal, options Creat
cwOptions.WithInstanceType(options.InstanceType)
}

t.Vprintf("Creating environment %s in org %s\n", t.Green(cwOptions.Name), t.Green(orgID))
t.Vprintf("Creating instane %s in org %s\n", t.Green(cwOptions.Name), t.Green(orgID))
t.Vprintf("\tname %s\n", t.Green(cwOptions.Name))
if options.InstanceType != "" {
t.Vprintf("\tGPU instance %s\n", t.Green(options.InstanceType))
Expand All @@ -149,7 +149,7 @@ func createEmptyWorkspace(user *entity.User, t *terminal.Terminal, options Creat
}

fmt.Print("\n")
t.Vprint(t.Green("Your dev environment is ready!\n"))
t.Vprint(t.Green("Your instance is ready!\n"))
displayConnectBreadCrumb(t, w)

return nil
Expand All @@ -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 dev environment:\n"))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open <NAME> -> open dev environment in VS Code\n", workspace.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell <NAME> -> ssh into dev environment (shortcut)\n", workspace.Name)))
t.Vprintf(t.Green("Connect to the instance:\n"))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open <NAME> -> open instance in VS Code\n", workspace.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell <NAME> -> ssh into instance (shortcut)\n", workspace.Name)))
// t.Vprintf(t.Yellow(fmt.Sprintf("\tssh %s\t# ssh <SSH-NAME> -> ssh directly to dev environment\n", workspace.GetLocalIdentifier())))
}

Expand All @@ -195,9 +195,9 @@ func pollUntil(t *terminal.Terminal, wsid string, state string, createStore Crea
if err != nil {
return breverrors.WrapAndTrace(err)
}
s.Suffix = " environment is " + strings.ToLower(ws.Status)
s.Suffix = " instance is " + strings.ToLower(ws.Status)
if ws.Status == state {
s.Suffix = "Environment is ready!"
s.Suffix = "Instance is ready!"
s.Stop()
isReady = true
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewCmdDelete(t *terminal.Terminal, loginDeleteStore DeleteStore, noLoginDel
Annotations: map[string]string{"workspace": ""},
Use: "delete",
DisableFlagsInUseLine: true,
Short: "Delete a Brev dev environment",
Short: "Delete a Brev instance",
Long: stripmd.Strip(deleteLong),
Example: deleteExample,
ValidArgsFunction: completions.GetAllWorkspaceNameCompletionHandler(noLoginDeleteStore, t),
Expand Down Expand Up @@ -75,7 +75,7 @@ func deleteWorkspace(workspaceName string, t *terminal.Terminal, deleteStore Del
return breverrors.WrapAndTrace(err)
}

t.Vprintf("Deleting dev environment %s. This can take a few minutes. Run 'brev ls' to check status\n", deletedWorkspace.Name)
t.Vprintf("Deleting instance %s. This can take a few minutes. Run 'brev ls' to check status\n", deletedWorkspace.Name)

return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/envsetup/envsetup.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func RunEnvSetup(
if err != nil {
return breverrors.WrapAndTrace(err)
}
fmt.Println("setting up dev environment")
fmt.Println("setting up instance")

params, err := store.GetEnvSetupParams(workspaceid)
if err != nil {
Expand Down Expand Up @@ -184,7 +184,7 @@ func RunEnvSetup(
return breverrors.WrapAndTrace(err)
}

fmt.Println("done setting up dev environment")
fmt.Println("done setting up instance")
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ func RunOnboarding(t *terminal.Terminal, user *entity.User, store HelloStore) er
s += "\nbtw, text me or call me if you need anything"
s += ". My cell is " + t.Yellow("(415) 237-2247")

s += "\n\nBrev is a dev tool for creating and sharing dev environments"
s += "\nRun " + t.Green("brev ls") + " to see your dev environments 👇\n"
s += "\n\nBrev is a dev tool for creating and sharing instances"
s += "\nRun " + t.Green("brev ls") + " to see your instances 👇\n"

wg.Add(2)
go finishOutput(t, s)
Expand Down
36 changes: 18 additions & 18 deletions pkg/cmd/hello/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@ func GetTextBasedONStatus(status string, t *terminal.Terminal) string {
switch status {
case "RUNNING":
case "DEPLOYING":
s += t.Yellow("Your dev environment is deploying.")
s += "\nPlease wait for it to finish deploying then run " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += t.Yellow("Your instance is deploying.")
s += "\nPlease wait for it to finish deploying then run " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
case "UNHEALTHY":
s += t.Red("Your dev environment seems stuck. Can you reach out to support?")
s += t.Red("Your instance seems stuck. Can you reach out to support?")
s += "\nMessage us "
s += "\n\t in discord 👉 " + t.Yellow("https://discord.gg/RpszWaJFRA")
s += "\n\t via text or call 👉 " + t.Yellow("(415) 237-2247\n")
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
case "STOPPED":
s += t.Yellow("Your dev environment is stopped.")
s += t.Yellow("Your instance is stopped.")
s += "\nRun this in your terminal to start it 👉 " + t.Yellow("brev start %s", DefaultDevEnvName)
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"

case "STOPPING":
s += t.Yellow("Your dev environment is stopped.")
s += t.Yellow("Your instance is stopped.")
s += "\nRun this in your terminal to start it 👉 " + t.Yellow("brev start %s", DefaultDevEnvName)
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
default:
s += t.Red("Please create a running dev environment for this walk through. ")
s += t.Red("Please create a running instance for this walk through. ")
s += "\n\tYou can do that here: " + t.Yellow("https://console.brev.dev/environments/new")
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += "\n\nRun " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
}
return s
}
Expand All @@ -60,9 +60,9 @@ func GetDevEnvOrStall(t *terminal.Terminal, workspaces []entity.Workspace) *enti
}

if noneFound {
s := t.Red("Please create a running dev environment for this walk through. ")
s := t.Red("Please create a running instance for this walk through. ")
s += "\n\tYou can do that here: " + t.Yellow("https://console.brev.dev/environments/new")
s += "\n\nRun: " + t.Yellow("brev hello") + " to resume this walk through when your dev env is ready\n"
s += "\n\nRun: " + t.Yellow("brev hello") + " to resume this walk through when your instance is ready\n"
TypeItToMe(s)
return nil
}
Expand All @@ -74,13 +74,13 @@ func GetDevEnvOrStall(t *terminal.Terminal, workspaces []entity.Workspace) *enti
}

func printLsIntroText(t *terminal.Terminal, _ entity.Workspace) {
s := "\nThe command " + t.Yellow("brev ls") + " shows your dev environments"
s += "\nIf the dev environment is " + t.Green("RUNNING") + ", you can open it."
s := "\nThe command " + t.Yellow("brev ls") + " shows your instances"
s += "\nIf the instance is " + t.Green("RUNNING") + ", you can open it."
TypeItToMe(s)
}

func printBrevShellOnboarding(t *terminal.Terminal, firstWorkspace *entity.Workspace) {
s := "\n\nTry opening a terminal SSHed in your dev environment"
s := "\n\nTry opening a terminal SSHed in your instance"
s += "\nIn a new terminal, run " + t.Green("brev shell %s", firstWorkspace.Name) + "\n"
TypeItToMe(s)
}
Expand All @@ -95,14 +95,14 @@ func printAskInstallVsCode(t *terminal.Terminal) {
}

func printBrevOpen(t *terminal.Terminal, firstWorkspace entity.Workspace) {
s := "\n\nTry opening VS Code in your dev environment"
s := "\n\nTry opening VS Code in your instance"
s += "\nIn a new terminal, run " + t.Green("brev open %s", firstWorkspace.Name) + "\n"
TypeItToMe(s)
}

func printCompletedOnboarding(t *terminal.Terminal) {
s := "\n\nI think I'm done here. Now you know how to open a dev environment and start coding."
s += "\n\nUse the console " + t.Yellow("(https://console.brev.dev)") + " to create a new dev environment or share it with people"
s := "\n\nI think I'm done here. Now you know how to open an instance and start coding."
s += "\n\nUse the console " + t.Yellow("(https://console.brev.dev)") + " to create a new instance or share it with people"
s += "\nand use this CLI to code the way you would normally 🤙"
s += "\n\nCheck out the docs at " + t.Yellow("https://brev.dev") + " and let us know if we can help!\n"
s += "\n\nIn case you missed it, my cell is " + t.Yellow("(415) 237-2247") + "\n\t-Nader\n"
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/login/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (o LoginOptions) checkIfInWorkspace() error {
return breverrors.WrapAndTrace(err)
}
if workspaceID != "" {
fmt.Println("can not login to dev environment")
return breverrors.NewValidationError("can not login to dev environment")
fmt.Println("can not login to instance")
return breverrors.NewValidationError("can not login to instance")
}

return nil
Expand Down Expand Up @@ -378,7 +378,7 @@ func OnboardUserWithEditors(t *terminal.Terminal, _ LoginStore, ide string) (str
}
}
} else {
t.Print("To use " + ide + " for your environment. Use the following command to remote into your machine")
t.Print("To use " + ide + " for your instance. Use the following command to remote into your machine")
t.Print(t.Green("Brev Shell"))
}
return ide, nil
Expand Down Expand Up @@ -410,18 +410,18 @@ func (o LoginOptions) showBreadCrumbs(t *terminal.Terminal, org *entity.Organiza
}

if len(allWorkspaces) == 0 {
t.Vprintf(t.Green("create a dev environment:\n"))
t.Vprintf(t.Green("create an instance:\n"))
t.Vprintf(t.Yellow("\tbrev start https://github.com/brevdev/hello-react\n"))
}
if len(userWorkspaces) == 0 && len(allWorkspaces) > 1 {
t.Vprintf(t.Green("list teammates dev environments:\n"))
t.Vprintf(t.Green("list teammates instances:\n"))
t.Vprintf(t.Yellow("\tbrev ls --all\n"))

t.Vprintf(t.Green("clone a teammate's dev environment:\n"))
t.Vprintf(t.Green("clone a teammate's instance:\n"))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev start %s\n", allWorkspaces[0].Name)))
}
if len(userWorkspaces) > 0 {
t.Vprintf(t.Green("list your dev environments:\n"))
t.Vprintf(t.Green("list your instances:\n"))
t.Vprintf(t.Yellow("\tbrev ls\n"))
}

Expand Down
26 changes: 13 additions & 13 deletions pkg/cmd/ls/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ func NewCmdLs(t *terminal.Terminal, loginLsStore LsStore, noLoginLsStore LsStore
cmd := &cobra.Command{
Annotations: map[string]string{"context": ""},
Use: "ls",
Short: "List dev environments within active org",
Long: "List dev environments within your active org. List all dev environments if no active org is set.",
Short: "List instances within active org",
Long: "List instances within your active org. List all instances if no active org is set.",
Example: `
brev ls
brev ls orgs
Expand Down Expand Up @@ -303,12 +303,12 @@ func (ls Ls) ShowUserWorkspaces(org *entity.Organization, otherOrgs []entity.Org

func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []entity.Organization, userWorkspaces []entity.Workspace, allWorkspaces []entity.Workspace) {
if len(userWorkspaces) == 0 {
ls.terminal.Vprint(ls.terminal.Yellow("No dev environments in org %s\n", org.Name))
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' dev environments:\n"))
ls.terminal.Vprintf(ls.terminal.Green("See teammates' instances:\n"))
ls.terminal.Vprintf(ls.terminal.Yellow("\tbrev ls --all\n"))
} else {
ls.terminal.Vprintf(ls.terminal.Green("Start a new dev environment:\n"))
ls.terminal.Vprintf(ls.terminal.Green("Start a new instance:\n"))
ls.terminal.Vprintf(ls.terminal.Yellow("\tbrev start https://github.com/brevdev/hello-react\n"))
}
if len(otherOrgs) > 1 {
Expand All @@ -317,7 +317,7 @@ func (ls Ls) displayWorkspacesAndHelp(org *entity.Organization, otherOrgs []enti
ls.terminal.Vprintf(ls.terminal.Yellow(fmt.Sprintf("\tbrev set %s\n", getOtherOrg(otherOrgs, *org).Name)))
}
} else {
ls.terminal.Vprintf("You have %d dev environments in Org "+ls.terminal.Yellow(org.Name)+"\n", len(userWorkspaces))
ls.terminal.Vprintf("You have %d instances in Org "+ls.terminal.Yellow(org.Name)+"\n", len(userWorkspaces))
displayWorkspacesTable(ls.terminal, userWorkspaces)

fmt.Print("\n")
Expand All @@ -341,19 +341,19 @@ func displayLsConnectBreadCrumb(t *terminal.Terminal, workspaces []entity.Worksp
for _, w := range workspaces {
if w.Status == entity.Running {
foundRunning = true
t.Vprintf(t.Green("Connect to running dev environment:\n"))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open <NAME> -> open dev environment in preferred editor\n", w.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell <NAME> -> ssh into dev environment (shortcut)\n", w.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tssh %s\t# ssh <SSH-NAME> -> ssh directly to dev environment\n", w.GetLocalIdentifier())))
t.Vprintf(t.Green("Connect to running instance:\n"))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev open %s\t# brev open <NAME> -> open instance in preferred editor\n", w.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev shell %s\t# brev shell <NAME> -> ssh into instance (shortcut)\n", w.Name)))
t.Vprintf(t.Yellow(fmt.Sprintf("\tssh %s\t# ssh <SSH-NAME> -> ssh directly to instance\n", w.GetLocalIdentifier())))
if enableSSHCol {
t.Vprintf(t.Yellow("\tssh <SSH> ex: ssh %s\n", w.GetLocalIdentifier()))
}
break
}
}
if !foundRunning && len(workspaces) > 0 {
t.Vprintf(t.Green("Start a stopped dev environment:\n"))
t.Vprintf(t.Yellow("\tbrev start %s # brev start <NAME> -> start stopped dev environment\n", workspaces[0].Name))
t.Vprintf(t.Green("Start a stopped instance:\n"))
t.Vprintf(t.Yellow("\tbrev start %s # brev start <NAME> -> start stopped instance\n", workspaces[0].Name))
}
}

Expand All @@ -362,7 +362,7 @@ 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 dev environment:\n"))
t.Vprintf(t.Red("Reset unhealthy or failed instance:\n"))
}
t.Vprintf(t.Yellow(fmt.Sprintf("\tbrev reset %s\n", w.Name)))
foundAResettableWorkspace = true
Expand Down
Loading

0 comments on commit 3b131e2

Please sign in to comment.