mirror of
https://github.com/coder/coder.git
synced 2025-04-04 18:28:14 +00:00
fix: Unnest workspaces command to the top-level (#1241)
This changes all "coder workspace *" commands to root. A few of these were already at the root, like SSH. The inconsistency made for a confusing experience.
This commit is contained in:
@ -16,31 +16,30 @@ When enabling autostart, provide the minute, hour, and day(s) of week.
|
||||
The default schedule is at 09:00 in your local timezone (TZ env, UTC by default).
|
||||
`
|
||||
|
||||
func workspaceAutostart() *cobra.Command {
|
||||
func autostart() *cobra.Command {
|
||||
autostartCmd := &cobra.Command{
|
||||
Use: "autostart enable <workspace>",
|
||||
Short: "schedule a workspace to automatically start at a regular time",
|
||||
Long: autostartDescriptionLong,
|
||||
Example: "coder workspaces autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
|
||||
Example: "coder autostart enable my-workspace --minute 30 --hour 9 --days 1-5 --tz Europe/Dublin",
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
autostartCmd.AddCommand(workspaceAutostartEnable())
|
||||
autostartCmd.AddCommand(workspaceAutostartDisable())
|
||||
autostartCmd.AddCommand(autostartEnable())
|
||||
autostartCmd.AddCommand(autostartDisable())
|
||||
|
||||
return autostartCmd
|
||||
}
|
||||
|
||||
func workspaceAutostartEnable() *cobra.Command {
|
||||
func autostartEnable() *cobra.Command {
|
||||
// yes some of these are technically numbers but the cron library will do that work
|
||||
var autostartMinute string
|
||||
var autostartHour string
|
||||
var autostartDayOfWeek string
|
||||
var autostartTimezone string
|
||||
cmd := &cobra.Command{
|
||||
Use: "enable <workspace_name> <schedule>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "enable <workspace_name> <schedule>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
||||
@ -86,11 +85,10 @@ func workspaceAutostartEnable() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func workspaceAutostartDisable() *cobra.Command {
|
||||
func autostartDisable() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "disable <workspace_name>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "disable <workspace_name>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/coder/coder/coderd/coderdtest"
|
||||
)
|
||||
|
||||
func TestWorkspaceAutostart(t *testing.T) {
|
||||
func TestAutostart(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("EnableDisableOK", func(t *testing.T) {
|
||||
@ -29,7 +29,7 @@ func TestWorkspaceAutostart(t *testing.T) {
|
||||
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
|
||||
tz = "Europe/Dublin"
|
||||
cmdArgs = []string{"workspaces", "autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz}
|
||||
cmdArgs = []string{"autostart", "enable", workspace.Name, "--minute", "30", "--hour", "9", "--days", "1-5", "--tz", tz}
|
||||
sched = "CRON_TZ=Europe/Dublin 30 9 * * 1-5"
|
||||
stdoutBuf = &bytes.Buffer{}
|
||||
)
|
||||
@ -48,7 +48,7 @@ func TestWorkspaceAutostart(t *testing.T) {
|
||||
require.Equal(t, sched, updated.AutostartSchedule, "expected autostart schedule to be set")
|
||||
|
||||
// Disable schedule
|
||||
cmd, root = clitest.New(t, "workspaces", "autostart", "disable", workspace.Name)
|
||||
cmd, root = clitest.New(t, "autostart", "disable", workspace.Name)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
cmd.SetOut(stdoutBuf)
|
||||
|
||||
@ -73,7 +73,7 @@ func TestWorkspaceAutostart(t *testing.T) {
|
||||
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
)
|
||||
|
||||
cmd, root := clitest.New(t, "workspaces", "autostart", "enable", "doesnotexist")
|
||||
cmd, root := clitest.New(t, "autostart", "enable", "doesnotexist")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
||||
@ -91,7 +91,7 @@ func TestWorkspaceAutostart(t *testing.T) {
|
||||
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
)
|
||||
|
||||
cmd, root := clitest.New(t, "workspaces", "autostart", "disable", "doesnotexist")
|
||||
cmd, root := clitest.New(t, "autostart", "disable", "doesnotexist")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
||||
@ -118,7 +118,7 @@ func TestWorkspaceAutostart(t *testing.T) {
|
||||
currTz = "UTC"
|
||||
}
|
||||
expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 9 * * 1-5", currTz)
|
||||
cmd, root := clitest.New(t, "workspaces", "autostart", "enable", workspace.Name)
|
||||
cmd, root := clitest.New(t, "autostart", "enable", workspace.Name)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
@ -16,31 +16,30 @@ When enabling autostop, provide the minute, hour, and day(s) of week.
|
||||
The default autostop schedule is at 18:00 in your local timezone (TZ env, UTC by default).
|
||||
`
|
||||
|
||||
func workspaceAutostop() *cobra.Command {
|
||||
func autostop() *cobra.Command {
|
||||
autostopCmd := &cobra.Command{
|
||||
Use: "autostop enable <workspace>",
|
||||
Short: "schedule a workspace to automatically stop at a regular time",
|
||||
Long: autostopDescriptionLong,
|
||||
Example: "coder workspaces autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin",
|
||||
Example: "coder autostop enable my-workspace --minute 0 --hour 18 --days 1-5 -tz Europe/Dublin",
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
autostopCmd.AddCommand(workspaceAutostopEnable())
|
||||
autostopCmd.AddCommand(workspaceAutostopDisable())
|
||||
autostopCmd.AddCommand(autostopEnable())
|
||||
autostopCmd.AddCommand(autostopDisable())
|
||||
|
||||
return autostopCmd
|
||||
}
|
||||
|
||||
func workspaceAutostopEnable() *cobra.Command {
|
||||
func autostopEnable() *cobra.Command {
|
||||
// yes some of these are technically numbers but the cron library will do that work
|
||||
var autostopMinute string
|
||||
var autostopHour string
|
||||
var autostopDayOfWeek string
|
||||
var autostopTimezone string
|
||||
cmd := &cobra.Command{
|
||||
Use: "enable <workspace_name> <schedule>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "enable <workspace_name> <schedule>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
||||
@ -86,11 +85,10 @@ func workspaceAutostopEnable() *cobra.Command {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func workspaceAutostopDisable() *cobra.Command {
|
||||
func autostopDisable() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "disable <workspace_name>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "disable <workspace_name>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
@ -13,7 +13,7 @@ import (
|
||||
"github.com/coder/coder/coderd/coderdtest"
|
||||
)
|
||||
|
||||
func TestWorkspaceAutostop(t *testing.T) {
|
||||
func TestAutostop(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("EnableDisableOK", func(t *testing.T) {
|
||||
@ -28,7 +28,7 @@ func TestWorkspaceAutostop(t *testing.T) {
|
||||
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
project = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
workspace = coderdtest.CreateWorkspace(t, client, user.OrganizationID, project.ID)
|
||||
cmdArgs = []string{"workspaces", "autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"}
|
||||
cmdArgs = []string{"autostop", "enable", workspace.Name, "--minute", "30", "--hour", "17", "--days", "1-5", "--tz", "Europe/Dublin"}
|
||||
sched = "CRON_TZ=Europe/Dublin 30 17 * * 1-5"
|
||||
stdoutBuf = &bytes.Buffer{}
|
||||
)
|
||||
@ -47,7 +47,7 @@ func TestWorkspaceAutostop(t *testing.T) {
|
||||
require.Equal(t, sched, updated.AutostopSchedule, "expected autostop schedule to be set")
|
||||
|
||||
// Disable schedule
|
||||
cmd, root = clitest.New(t, "workspaces", "autostop", "disable", workspace.Name)
|
||||
cmd, root = clitest.New(t, "autostop", "disable", workspace.Name)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
cmd.SetOut(stdoutBuf)
|
||||
|
||||
@ -72,7 +72,7 @@ func TestWorkspaceAutostop(t *testing.T) {
|
||||
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
)
|
||||
|
||||
cmd, root := clitest.New(t, "workspaces", "autostop", "enable", "doesnotexist")
|
||||
cmd, root := clitest.New(t, "autostop", "enable", "doesnotexist")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
||||
@ -90,7 +90,7 @@ func TestWorkspaceAutostop(t *testing.T) {
|
||||
_ = coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
)
|
||||
|
||||
cmd, root := clitest.New(t, "workspaces", "autostop", "disable", "doesnotexist")
|
||||
cmd, root := clitest.New(t, "autostop", "disable", "doesnotexist")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
||||
@ -118,7 +118,7 @@ func TestWorkspaceAutostop(t *testing.T) {
|
||||
}
|
||||
expectedSchedule := fmt.Sprintf("CRON_TZ=%s 0 18 * * 1-5", currTz)
|
||||
|
||||
cmd, root := clitest.New(t, "workspaces", "autostop", "enable", workspace.Name)
|
||||
cmd, root := clitest.New(t, "autostop", "enable", workspace.Name)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
|
||||
err := cmd.Execute()
|
@ -60,7 +60,7 @@ func Agent(ctx context.Context, writer io.Writer, opts AgentOptions) error {
|
||||
defer resourceMutex.Unlock()
|
||||
message := "Don't panic, your workspace is booting up!"
|
||||
if agent.Status == codersdk.WorkspaceAgentDisconnected {
|
||||
message = "The workspace agent lost connection! Wait for it to reconnect or run: " + Styles.Code.Render("coder workspaces rebuild "+opts.WorkspaceName)
|
||||
message = "The workspace agent lost connection! Wait for it to reconnect or run: " + Styles.Code.Render("coder rebuild "+opts.WorkspaceName)
|
||||
}
|
||||
// This saves the cursor position, then defers clearing from the cursor
|
||||
// position to the end of the screen.
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceCreate() *cobra.Command {
|
||||
func create() *cobra.Command {
|
||||
var (
|
||||
workspaceName string
|
||||
templateName string
|
@ -12,7 +12,7 @@ import (
|
||||
"github.com/coder/coder/pty/ptytest"
|
||||
)
|
||||
|
||||
func TestWorkspaceCreate(t *testing.T) {
|
||||
func TestCreate(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Create", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
@ -22,7 +22,7 @@ func TestWorkspaceCreate(t *testing.T) {
|
||||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
|
||||
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
cmd, root := clitest.New(t, "workspaces", "create", "my-workspace", "--template", template.Name)
|
||||
cmd, root := clitest.New(t, "create", "my-workspace", "--template", template.Name)
|
||||
clitest.SetupConfig(t, client, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t)
|
||||
@ -52,7 +52,7 @@ func TestWorkspaceCreate(t *testing.T) {
|
||||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
|
||||
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
cmd, root := clitest.New(t, "workspaces", "create", "my-workspace")
|
||||
cmd, root := clitest.New(t, "create", "my-workspace")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t)
|
||||
@ -82,7 +82,7 @@ func TestWorkspaceCreate(t *testing.T) {
|
||||
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
|
||||
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
cmd, root := clitest.New(t, "workspaces", "create", "")
|
||||
cmd, root := clitest.New(t, "create", "")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t)
|
||||
@ -134,7 +134,7 @@ func TestWorkspaceCreate(t *testing.T) {
|
||||
})
|
||||
coderdtest.AwaitTemplateVersionJob(t, client, version.ID)
|
||||
_ = coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
|
||||
cmd, root := clitest.New(t, "workspaces", "create", "")
|
||||
cmd, root := clitest.New(t, "create", "")
|
||||
clitest.SetupConfig(t, client, root)
|
||||
doneChan := make(chan struct{})
|
||||
pty := ptytest.New(t)
|
@ -10,12 +10,12 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceDelete() *cobra.Command {
|
||||
// nolint
|
||||
func delete() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "delete <workspace>",
|
||||
Aliases: []string{"rm"},
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "delete <workspace>",
|
||||
Aliases: []string{"rm"},
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
@ -11,7 +11,7 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceList() *cobra.Command {
|
||||
func list() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "list",
|
||||
Aliases: []string{"ls"},
|
||||
@ -31,7 +31,7 @@ func workspaceList() *cobra.Command {
|
||||
if len(workspaces) == 0 {
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout(), cliui.Styles.Prompt.String()+"No workspaces found! Create one:")
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout())
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render("coder workspaces create <name>"))
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render("coder create <name>"))
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout())
|
||||
return nil
|
||||
}
|
22
cli/root.go
22
cli/root.go
@ -67,17 +67,25 @@ func Root() *cobra.Command {
|
||||
cmd.SetVersionTemplate(versionTemplate())
|
||||
|
||||
cmd.AddCommand(
|
||||
autostart(),
|
||||
autostop(),
|
||||
configSSH(),
|
||||
server(),
|
||||
create(),
|
||||
delete(),
|
||||
gitssh(),
|
||||
list(),
|
||||
login(),
|
||||
parameters(),
|
||||
templates(),
|
||||
users(),
|
||||
workspaces(),
|
||||
ssh(),
|
||||
workspaceTunnel(),
|
||||
gitssh(),
|
||||
publickey(),
|
||||
server(),
|
||||
show(),
|
||||
start(),
|
||||
stop(),
|
||||
ssh(),
|
||||
templates(),
|
||||
update(),
|
||||
users(),
|
||||
tunnel(),
|
||||
workspaceAgent(),
|
||||
)
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceShow() *cobra.Command {
|
||||
func show() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "show",
|
||||
Args: cobra.ExactArgs(1),
|
@ -10,11 +10,10 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceStart() *cobra.Command {
|
||||
func start() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "start <workspace>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "start <workspace>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
@ -10,11 +10,10 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceStop() *cobra.Command {
|
||||
func stop() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "stop <workspace>",
|
||||
ValidArgsFunction: validArgsWorkspaceName,
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "stop <workspace>",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
@ -115,7 +115,7 @@ func templateCreate() *cobra.Command {
|
||||
"The "+cliui.Styles.Keyword.Render(templateName)+" template has been created! "+
|
||||
"Developers can provision a workspace with this template using:")+"\n")
|
||||
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder workspaces create --template=%q [workspace name]", templateName)))
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout(), " "+cliui.Styles.Code.Render(fmt.Sprintf("coder create --template=%q [workspace name]", templateName)))
|
||||
_, _ = fmt.Fprintln(cmd.OutOrStdout())
|
||||
|
||||
return nil
|
||||
|
@ -2,7 +2,7 @@ package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func workspaceTunnel() *cobra.Command {
|
||||
func tunnel() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "tunnel",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaceUpdate() *cobra.Command {
|
||||
func update() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "update",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
@ -79,7 +79,7 @@ Run `+cliui.Styles.Code.Render("coder login "+client.URL.String())+` to authenti
|
||||
Your email is: `+cliui.Styles.Field.Render(email)+`
|
||||
Your password is: `+cliui.Styles.Field.Render(password)+`
|
||||
|
||||
Create a workspace `+cliui.Styles.Code.Render("coder workspaces create")+`!`)
|
||||
Create a workspace `+cliui.Styles.Code.Render("coder create")+`!`)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
func workspaces() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "workspaces",
|
||||
Aliases: []string{"ws"},
|
||||
}
|
||||
cmd.AddCommand(workspaceCreate())
|
||||
cmd.AddCommand(workspaceDelete())
|
||||
cmd.AddCommand(workspaceList())
|
||||
cmd.AddCommand(workspaceShow())
|
||||
cmd.AddCommand(workspaceStop())
|
||||
cmd.AddCommand(workspaceStart())
|
||||
cmd.AddCommand(ssh())
|
||||
cmd.AddCommand(workspaceUpdate())
|
||||
cmd.AddCommand(workspaceAutostart())
|
||||
cmd.AddCommand(workspaceAutostop())
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func validArgsWorkspaceName(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
client, err := createClient(cmd)
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveError
|
||||
}
|
||||
organization, err := currentOrganization(cmd, client)
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveError
|
||||
}
|
||||
workspaces, err := client.WorkspacesByOwner(cmd.Context(), organization.ID, codersdk.Me)
|
||||
if err != nil {
|
||||
return nil, cobra.ShellCompDirectiveError
|
||||
}
|
||||
names := make([]string, 0)
|
||||
for _, workspace := range workspaces {
|
||||
if !strings.HasPrefix(workspace.Name, toComplete) {
|
||||
continue
|
||||
}
|
||||
names = append(names, workspace.Name)
|
||||
}
|
||||
return names, cobra.ShellCompDirectiveDefault
|
||||
}
|
@ -59,7 +59,7 @@ coder templates create
|
||||
Create a workspace and connect to it via SSH:
|
||||
|
||||
```bash
|
||||
coder workspaces create my-first-workspace
|
||||
coder create my-first-workspace
|
||||
coder ssh my-first-workspace
|
||||
```
|
||||
|
||||
|
@ -10,10 +10,10 @@ templates](./templates.md):
|
||||
|
||||
```sh
|
||||
# create a workspace from the template; specify any variables
|
||||
coder workspaces create <workspace-name>
|
||||
coder create <workspace-name>
|
||||
|
||||
# show the resources behind the workspace, and how to connect
|
||||
coder workspaces show <workspace-name>
|
||||
coder show <workspace-name>
|
||||
```
|
||||
|
||||
## Connect with SSH
|
||||
@ -72,5 +72,5 @@ Use the following command to update a workspace to the latest template version.
|
||||
The workspace will be stopped and started:
|
||||
|
||||
```sh
|
||||
coder workspaces update <workspace-name>
|
||||
coder update <workspace-name>
|
||||
```
|
||||
|
Reference in New Issue
Block a user