Skip to content

Commit 1f9e1be

Browse files
committed
Merge branch 'main' into update-mui
2 parents b3791d9 + 9ee53e5 commit 1f9e1be

File tree

132 files changed

+3188
-3184
lines changed

Some content is hidden

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

132 files changed

+3188
-3184
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,8 @@ jobs:
965965
id: review
966966
uses: actions/dependency-review-action@v4.3.2
967967
with:
968-
allow-licenses: Apache-2.0, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
969-
allow-dependencies-licenses: "pkg:golang/github.com/coder/wgtunnel@0.1.13-0.20240522110300-ade90dfb2da0, pkg:npm/pako@1.0.11"
968+
allow-licenses: Apache-2.0, 0BSD, BSD-2-Clause, BSD-3-Clause, CC0-1.0, ISC, MIT, MIT-0, MPL-2.0
969+
allow-dependencies-licenses: "pkg:golang/github.com/coder/wgtunnel@0.1.13-0.20240522110300-ade90dfb2da0, pkg:npm/pako@1.0.11, pkg:npm/caniuse-lite@1.0.30001639"
970970
license-check: true
971971
vulnerability-check: false
972972
- name: "Report"

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ gen/mark-fresh:
518518
$(DB_GEN_FILES) \
519519
site/src/api/typesGenerated.ts \
520520
coderd/rbac/object_gen.go \
521+
codersdk/rbacresources_gen.go \
521522
docs/admin/prometheus.md \
522523
docs/cli.md \
523524
docs/admin/audit-logs.md \
@@ -616,10 +617,10 @@ site/src/theme/icons.json: $(wildcard scripts/gensite/*) $(wildcard site/static/
616617
examples/examples.gen.json: scripts/examplegen/main.go examples/examples.go $(shell find ./examples/templates)
617618
go run ./scripts/examplegen/main.go > examples/examples.gen.json
618619

619-
coderd/rbac/object_gen.go: scripts/rbacgen/rbacobject.gotmpl scripts/rbacgen/main.go coderd/rbac/object.go
620+
coderd/rbac/object_gen.go: scripts/rbacgen/rbacobject.gotmpl scripts/rbacgen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go
620621
go run scripts/rbacgen/main.go rbac > coderd/rbac/object_gen.go
621622

622-
codersdk/rbacresources_gen.go: scripts/rbacgen/codersdk.gotmpl scripts/rbacgen/main.go coderd/rbac/object.go
623+
codersdk/rbacresources_gen.go: scripts/rbacgen/codersdk.gotmpl scripts/rbacgen/main.go coderd/rbac/object.go coderd/rbac/policy/policy.go
623624
go run scripts/rbacgen/main.go codersdk > codersdk/rbacresources_gen.go
624625

625626
docs/admin/prometheus.md: scripts/metricsdocgen/main.go scripts/metricsdocgen/metrics

cli/create.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func (r *RootCmd) create() *serpent.Command {
2929
parameterFlags workspaceParameterFlags
3030
autoUpdates string
3131
copyParametersFrom string
32+
orgContext = NewOrganizationContext()
3233
)
3334
client := new(codersdk.Client)
3435
cmd := &serpent.Command{
@@ -43,7 +44,7 @@ func (r *RootCmd) create() *serpent.Command {
4344
),
4445
Middleware: serpent.Chain(r.InitClient(client)),
4546
Handler: func(inv *serpent.Invocation) error {
46-
organization, err := CurrentOrganization(r, inv, client)
47+
organization, err := orgContext.Selected(inv, client)
4748
if err != nil {
4849
return err
4950
}
@@ -269,6 +270,7 @@ func (r *RootCmd) create() *serpent.Command {
269270
)
270271
cmd.Options = append(cmd.Options, parameterFlags.cliParameters()...)
271272
cmd.Options = append(cmd.Options, parameterFlags.cliParameterDefaults()...)
273+
orgContext.AttachOptions(cmd)
272274
return cmd
273275
}
274276

cli/list.go

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"strconv"
77
"time"
88

9+
"github.com/google/uuid"
910
"golang.org/x/xerrors"
1011

1112
"github.com/coder/coder/v2/cli/cliui"
@@ -22,19 +23,21 @@ type workspaceListRow struct {
2223
codersdk.Workspace `table:"-"`
2324

2425
// For table format:
25-
Favorite bool `json:"-" table:"favorite"`
26-
WorkspaceName string `json:"-" table:"workspace,default_sort"`
27-
Template string `json:"-" table:"template"`
28-
Status string `json:"-" table:"status"`
29-
Healthy string `json:"-" table:"healthy"`
30-
LastBuilt string `json:"-" table:"last built"`
31-
CurrentVersion string `json:"-" table:"current version"`
32-
Outdated bool `json:"-" table:"outdated"`
33-
StartsAt string `json:"-" table:"starts at"`
34-
StartsNext string `json:"-" table:"starts next"`
35-
StopsAfter string `json:"-" table:"stops after"`
36-
StopsNext string `json:"-" table:"stops next"`
37-
DailyCost string `json:"-" table:"daily cost"`
26+
Favorite bool `json:"-" table:"favorite"`
27+
WorkspaceName string `json:"-" table:"workspace,default_sort"`
28+
OrganizationID uuid.UUID `json:"-" table:"organization id"`
29+
OrganizationName string `json:"-" table:"organization name"`
30+
Template string `json:"-" table:"template"`
31+
Status string `json:"-" table:"status"`
32+
Healthy string `json:"-" table:"healthy"`
33+
LastBuilt string `json:"-" table:"last built"`
34+
CurrentVersion string `json:"-" table:"current version"`
35+
Outdated bool `json:"-" table:"outdated"`
36+
StartsAt string `json:"-" table:"starts at"`
37+
StartsNext string `json:"-" table:"starts next"`
38+
StopsAfter string `json:"-" table:"stops after"`
39+
StopsNext string `json:"-" table:"stops next"`
40+
DailyCost string `json:"-" table:"daily cost"`
3841
}
3942

4043
func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace) workspaceListRow {
@@ -53,20 +56,22 @@ func workspaceListRowFromWorkspace(now time.Time, workspace codersdk.Workspace)
5356
}
5457
workspaceName := favIco + " " + workspace.OwnerName + "/" + workspace.Name
5558
return workspaceListRow{
56-
Favorite: workspace.Favorite,
57-
Workspace: workspace,
58-
WorkspaceName: workspaceName,
59-
Template: workspace.TemplateName,
60-
Status: status,
61-
Healthy: healthy,
62-
LastBuilt: durationDisplay(lastBuilt),
63-
CurrentVersion: workspace.LatestBuild.TemplateVersionName,
64-
Outdated: workspace.Outdated,
65-
StartsAt: schedRow.StartsAt,
66-
StartsNext: schedRow.StartsNext,
67-
StopsAfter: schedRow.StopsAfter,
68-
StopsNext: schedRow.StopsNext,
69-
DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
59+
Favorite: workspace.Favorite,
60+
Workspace: workspace,
61+
WorkspaceName: workspaceName,
62+
OrganizationID: workspace.OrganizationID,
63+
OrganizationName: workspace.OrganizationName,
64+
Template: workspace.TemplateName,
65+
Status: status,
66+
Healthy: healthy,
67+
LastBuilt: durationDisplay(lastBuilt),
68+
CurrentVersion: workspace.LatestBuild.TemplateVersionName,
69+
Outdated: workspace.Outdated,
70+
StartsAt: schedRow.StartsAt,
71+
StartsNext: schedRow.StartsNext,
72+
StopsAfter: schedRow.StopsAfter,
73+
StopsNext: schedRow.StopsNext,
74+
DailyCost: strconv.Itoa(int(workspace.LatestBuild.DailyCost)),
7075
}
7176
}
7277

cli/login.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,6 @@ func (r *RootCmd) login() *serpent.Command {
358358
return xerrors.Errorf("write server url: %w", err)
359359
}
360360

361-
// If the current organization cannot be fetched, then reset the organization context.
362-
// Otherwise, organization cli commands will fail.
363-
_, err = CurrentOrganization(r, inv, client)
364-
if err != nil {
365-
_ = config.Organization().Delete()
366-
}
367-
368361
_, _ = fmt.Fprintf(inv.Stdout, Caret+"Welcome to Coder, %s! You're authenticated.\n", pretty.Sprint(cliui.DefaultStyles.Keyword, resp.Username))
369362
return nil
370363
},

cli/login_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import (
55
"fmt"
66
"net/http"
77
"net/http/httptest"
8-
"os"
98
"runtime"
109
"testing"
1110

12-
"github.com/google/uuid"
1311
"github.com/stretchr/testify/assert"
1412
"github.com/stretchr/testify/require"
1513

@@ -424,29 +422,6 @@ func TestLogin(t *testing.T) {
424422
require.NotEqual(t, client.SessionToken(), sessionFile)
425423
})
426424

427-
// Login should reset the configured organization if the user is not a member
428-
t.Run("ResetOrganization", func(t *testing.T) {
429-
t.Parallel()
430-
client := coderdtest.New(t, nil)
431-
coderdtest.CreateFirstUser(t, client)
432-
root, cfg := clitest.New(t, "login", client.URL.String(), "--token", client.SessionToken())
433-
434-
notRealOrg := uuid.NewString()
435-
err := cfg.Organization().Write(notRealOrg)
436-
require.NoError(t, err, "write bad org to config")
437-
438-
err = root.Run()
439-
require.NoError(t, err)
440-
sessionFile, err := cfg.Session().Read()
441-
require.NoError(t, err)
442-
require.NotEqual(t, client.SessionToken(), sessionFile)
443-
444-
// Organization config should be deleted since the org does not exist
445-
selected, err := cfg.Organization().Read()
446-
require.ErrorIs(t, err, os.ErrNotExist)
447-
require.NotEqual(t, selected, notRealOrg)
448-
})
449-
450425
t.Run("KeepOrganizationContext", func(t *testing.T) {
451426
t.Parallel()
452427
client := coderdtest.New(t, nil)

0 commit comments

Comments
 (0)