Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

fix: rename envs to workspaces #421

Merged
merged 1 commit into from
Aug 24, 2021
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
2 changes: 1 addition & 1 deletion coder-sdk/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type ParseTemplateRequest struct {
Local io.Reader `json:"-"`
}

// TemplateVersion is a Workspaces As Code (WAC) template.
// TemplateVersion is a workspace template.
// For now, let's not interpret it on the CLI level. We just need
// to forward this as part of the create workspace request.
type TemplateVersion struct {
Expand Down
6 changes: 3 additions & 3 deletions docs/coder_workspaces_create-from-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ create a new workspace from a template

### Synopsis

Create a new Coder workspace using a Workspaces As Code template.
Create a new Coder workspace using a workspace template.

```
coder workspaces create-from-config [flags]
Expand All @@ -14,8 +14,8 @@ coder workspaces create-from-config [flags]

```
# create a new workspace from git repository
coder envs create-from-config --name="dev-env" --repo-url https://github.com/cdr/m --ref my-branch
coder envs create-from-config --name="dev-env" -f coder.yaml
coder workspaces create-from-config --name="dev-env" --repo-url https://github.com/cdr/m --ref my-branch
coder workspaces create-from-config --name="dev-env" --filepath coder.yaml
```

### Options
Expand Down
6 changes: 3 additions & 3 deletions docs/coder_workspaces_edit-from-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ change the template a workspace is tracking

### Synopsis

Edit an existing Coder workspace using a Workspaces As Code template.
Edit an existing Coder workspace using a workspace template.

```
coder workspaces edit-from-config [flags]
Expand All @@ -14,8 +14,8 @@ coder workspaces edit-from-config [flags]

```
# edit a new workspace from git repository
coder envs edit-from-config dev-env --repo-url https://github.com/cdr/m --ref my-branch
coder envs edit-from-config dev-env -f coder.yaml
coder workspaces edit-from-config dev-env --repo-url https://github.com/cdr/m --ref my-branch
coder workspaces edit-from-config dev-env --filepath coder.yaml
```

### Options
Expand Down
48 changes: 24 additions & 24 deletions internal/cmd/workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,22 +542,22 @@ func selectOrg(needle string, haystack []coder.Organization) (*coder.Organizatio
// If `update` is true, the update command is returned. If false, the create command.
func workspaceFromConfigCmd(update bool) *cobra.Command {
var (
ref string
repo string
follow bool
filepath string
org string
providerName string
envName string
ref string
repo string
follow bool
filepath string
org string
providerName string
workspaceName string
)

run := func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

// Update requires the env name, and the name should be the first argument.
if update {
envName = args[0]
} else if envName == "" {
workspaceName = args[0]
} else if workspaceName == "" {
// Create takes the name as a flag, and it must be set
return clog.Error("Must provide a workspace name.",
clog.BlankLine,
Expand All @@ -581,17 +581,17 @@ func workspaceFromConfigCmd(update bool) *cobra.Command {
}

// This is the env to be updated/created
var env *coder.Workspace
var workspace *coder.Workspace

// OrgID is the org where the template and env should be created.
// If we are updating an env, use the orgID from the workspace.
var orgID string
if update {
env, err = findWorkspace(ctx, client, envName, coder.Me)
workspace, err = findWorkspace(ctx, client, workspaceName, coder.Me)
if err != nil {
return handleAPIError(err)
}
orgID = env.OrganizationID
orgID = workspace.OrganizationID
} else {
var userOrg *coder.Organization
// Select org in list or use default
Expand Down Expand Up @@ -637,16 +637,16 @@ func workspaceFromConfigCmd(update bool) *cobra.Command {
}

if update {
err = client.EditWorkspace(ctx, env.ID, coder.UpdateWorkspaceReq{
err = client.EditWorkspace(ctx, workspace.ID, coder.UpdateWorkspaceReq{
TemplateID: &version.TemplateID,
})
} else {
env, err = client.CreateWorkspace(ctx, coder.CreateWorkspaceRequest{
workspace, err = client.CreateWorkspace(ctx, coder.CreateWorkspaceRequest{
OrgID: orgID,
TemplateID: version.TemplateID,
ResourcePoolID: provider.ID,
Namespace: provider.DefaultNamespace,
Name: envName,
Name: workspaceName,
})
}
if err != nil {
Expand All @@ -655,15 +655,15 @@ func workspaceFromConfigCmd(update bool) *cobra.Command {

if follow {
clog.LogSuccess("creating workspace...")
if err := trailBuildLogs(ctx, client, env.ID); err != nil {
if err := trailBuildLogs(ctx, client, workspace.ID); err != nil {
return err
}
return nil
}

clog.LogSuccess("creating workspace...",
clog.BlankLine,
clog.Tipf(`run "coder envs watch-build %s" to trail the build logs`, env.Name),
clog.Tipf(`run "coder workspaces watch-build %s" to see build logs`, workspace.Name),
)
return nil
}
Expand All @@ -673,25 +673,25 @@ func workspaceFromConfigCmd(update bool) *cobra.Command {
cmd = &cobra.Command{
Use: "edit-from-config",
Short: "change the template a workspace is tracking",
Long: "Edit an existing Coder workspace using a Workspaces As Code template.",
Long: "Edit an existing Coder workspace using a workspace template.",
Args: cobra.ExactArgs(1),
Example: `# edit a new workspace from git repository
coder envs edit-from-config dev-env --repo-url https://github.com/cdr/m --ref my-branch
coder envs edit-from-config dev-env -f coder.yaml`,
coder workspaces edit-from-config dev-env --repo-url https://github.com/cdr/m --ref my-branch
coder workspaces edit-from-config dev-env --filepath coder.yaml`,
RunE: run,
}
} else {
cmd = &cobra.Command{
Use: "create-from-config",
Short: "create a new workspace from a template",
Long: "Create a new Coder workspace using a Workspaces As Code template.",
Long: "Create a new Coder workspace using a workspace template.",
Example: `# create a new workspace from git repository
coder envs create-from-config --name="dev-env" --repo-url https://github.com/cdr/m --ref my-branch
coder envs create-from-config --name="dev-env" -f coder.yaml`,
coder workspaces create-from-config --name="dev-env" --repo-url https://github.com/cdr/m --ref my-branch
coder workspaces create-from-config --name="dev-env" --filepath coder.yaml`,
RunE: run,
}
cmd.Flags().StringVar(&providerName, "provider", "", "name of Workspace Provider with which to create the workspace")
cmd.Flags().StringVar(&envName, "name", "", "name of the workspace to be created")
cmd.Flags().StringVar(&workspaceName, "name", "", "name of the workspace to be created")
cmd.Flags().StringVarP(&org, "org", "o", "", "name of the organization the workspace should be created under.")
// Ref and repo-url can only be used for create
cmd.Flags().StringVarP(&ref, "ref", "", "master", "git reference to pull template from. May be a branch, tag, or commit hash.")
Expand Down