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

Commit 4161a09

Browse files
committed
Rename env types to workspace
1 parent 9ddbd85 commit 4161a09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+789
-807
lines changed

ci/integration/ssh_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ func TestSSH(t *testing.T) {
1313
run(t, "ssh-coder-cli-tests", func(t *testing.T, ctx context.Context, c *tcli.ContainerRunner) {
1414
headlessLogin(ctx, t, c)
1515

16-
// TODO remove this once we can create an environment if there aren't any
17-
var envs []coder.Environment
16+
// TODO remove this once we can create a workspace if there aren't any
17+
var workspaces []coder.Workspace
1818
c.Run(ctx, "coder envs ls --output json").Assert(t,
1919
tcli.Success(),
20-
tcli.StdoutJSONUnmarshal(&envs),
20+
tcli.StdoutJSONUnmarshal(&workspaces),
2121
)
2222

2323
assert := tcli.Success()
2424

25-
// if we don't have any environments, "coder config-ssh" will fail
26-
if len(envs) == 0 {
25+
// if we don't have any workspaces, "coder config-ssh" will fail
26+
if len(workspaces) == 0 {
2727
assert = tcli.Error()
2828
}
2929
c.Run(ctx, "coder config-ssh").Assert(t,

ci/integration/statictokens_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestStaticAuth(t *testing.T) {
4242
tcli.Success(),
4343
)
4444

45-
// should error when the environment variabels aren't set
45+
// should error when the environment variables aren't set
4646
c.Run(ctx, "coder envs ls").Assert(t,
4747
tcli.Error(),
4848
)

coder-sdk/activity.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import (
66
)
77

88
type activityRequest struct {
9-
Source string `json:"source"`
10-
EnvironmentID string `json:"environment_id"`
9+
Source string `json:"source"`
10+
WorkspaceID string `json:"workspace_id"`
1111
}
1212

1313
// PushActivity pushes CLI activity to Coder.
14-
func (c *DefaultClient) PushActivity(ctx context.Context, source, envID string) error {
14+
func (c *DefaultClient) PushActivity(ctx context.Context, source, workspaceID string) error {
1515
resp, err := c.request(ctx, http.MethodPost, "/api/private/metrics/usage/push", activityRequest{
16-
Source: source,
17-
EnvironmentID: envID,
16+
Source: source,
17+
WorkspaceID: workspaceID,
1818
})
1919
if err != nil {
2020
return err

coder-sdk/activity_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ func TestPushActivity(t *testing.T) {
1717
t.Parallel()
1818

1919
const source = "test"
20-
const envID = "602d377a-e6b8d763cae7561885c5f1b2"
20+
const workspaceID = "602d377a-e6b8d763cae7561885c5f1b2"
2121
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2222
assert.Equal(t, "PushActivity is a POST", http.MethodPost, r.Method)
2323
assert.Equal(t, "URL matches", "/api/private/metrics/usage/push", r.URL.Path)
2424

2525
expected := map[string]interface{}{
26-
"source": source,
27-
"environment_id": envID,
26+
"source": source,
27+
"workspace_id": workspaceID,
2828
}
2929
var request map[string]interface{}
3030
err := json.NewDecoder(r.Body).Decode(&request)
@@ -46,6 +46,6 @@ func TestPushActivity(t *testing.T) {
4646
})
4747
assert.Success(t, "failed to create coder.Client", err)
4848

49-
err = client.PushActivity(context.Background(), source, envID)
49+
err = client.PushActivity(context.Background(), source, workspaceID)
5050
assert.Success(t, "expected successful response from PushActivity", err)
5151
}

coder-sdk/devurl.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,38 @@ type DevURL struct {
1717
}
1818

1919
type delDevURLRequest struct {
20-
EnvID string `json:"environment_id"`
21-
DevURLID string `json:"url_id"`
20+
WorkspaceID string `json:"workspace_id"`
21+
DevURLID string `json:"url_id"`
2222
}
2323

2424
// DeleteDevURL deletes the specified devurl.
25-
func (c *DefaultClient) DeleteDevURL(ctx context.Context, envID, urlID string) error {
26-
reqURL := fmt.Sprintf("/api/v0/environments/%s/devurls/%s", envID, urlID)
25+
func (c *DefaultClient) DeleteDevURL(ctx context.Context, workspaceID, urlID string) error {
26+
reqURL := fmt.Sprintf("/api/v0/workspaces/%s/devurls/%s", workspaceID, urlID)
2727

2828
return c.requestBody(ctx, http.MethodDelete, reqURL, delDevURLRequest{
29-
EnvID: envID,
30-
DevURLID: urlID,
29+
WorkspaceID: workspaceID,
30+
DevURLID: urlID,
3131
}, nil)
3232
}
3333

3434
// CreateDevURLReq defines the request parameters for creating a new DevURL.
3535
type CreateDevURLReq struct {
36-
EnvID string `json:"environment_id"`
37-
Port int `json:"port"`
38-
Access string `json:"access"`
39-
Name string `json:"name"`
40-
Scheme string `json:"scheme"`
36+
WorkspaceID string `json:"workspace_id"`
37+
Port int `json:"port"`
38+
Access string `json:"access"`
39+
Name string `json:"name"`
40+
Scheme string `json:"scheme"`
4141
}
4242

4343
// CreateDevURL inserts a new dev URL for the authenticated user.
44-
func (c *DefaultClient) CreateDevURL(ctx context.Context, envID string, req CreateDevURLReq) error {
45-
return c.requestBody(ctx, http.MethodPost, "/api/v0/environments/"+envID+"/devurls", req, nil)
44+
func (c *DefaultClient) CreateDevURL(ctx context.Context, workspaceID string, req CreateDevURLReq) error {
45+
return c.requestBody(ctx, http.MethodPost, "/api/v0/workspaces/"+workspaceID+"/devurls", req, nil)
4646
}
4747

48-
// DevURLs fetches the Dev URLs for a given environment.
49-
func (c *DefaultClient) DevURLs(ctx context.Context, envID string) ([]DevURL, error) {
48+
// DevURLs fetches the Dev URLs for a given workspace.
49+
func (c *DefaultClient) DevURLs(ctx context.Context, workspaceID string) ([]DevURL, error) {
5050
var devurls []DevURL
51-
if err := c.requestBody(ctx, http.MethodGet, "/api/v0/environments/"+envID+"/devurls", nil, &devurls); err != nil {
51+
if err := c.requestBody(ctx, http.MethodGet, "/api/v0/workspaces/"+workspaceID+"/devurls", nil, &devurls); err != nil {
5252
return nil, err
5353
}
5454
return devurls, nil
@@ -58,6 +58,6 @@ func (c *DefaultClient) DevURLs(ctx context.Context, envID string) ([]DevURL, er
5858
type PutDevURLReq CreateDevURLReq
5959

6060
// PutDevURL updates an existing devurl for the authenticated user.
61-
func (c *DefaultClient) PutDevURL(ctx context.Context, envID, urlID string, req PutDevURLReq) error {
62-
return c.requestBody(ctx, http.MethodPut, "/api/v0/environments/"+envID+"/devurls/"+urlID, req, nil)
61+
func (c *DefaultClient) PutDevURL(ctx context.Context, workspaceID, urlID string, req PutDevURLReq) error {
62+
return c.requestBody(ctx, http.MethodPut, "/api/v0/workspaces/"+workspaceID+"/devurls/"+urlID, req, nil)
6363
}

0 commit comments

Comments
 (0)