Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 950a903

Browse files
committed
Merge branch 'main' of https://github.com/coder/coder into bq/feat-increase-group-name-length
2 parents 64d2a75 + 18c2386 commit 950a903

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

+1254
-391
lines changed

.github/workflows/mlc_config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
{
2222
"pattern": "support.google.com"
2323
},
24+
{
25+
"pattern": "mailto:"
26+
},
2427
{
2528
"pattern": "tailscale.com"
2629
},

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[https://coder.com/docs/coder-oss/latest/contributing/CODE_OF_CONDUCT](https://coder.com/docs/contributing/CODE_OF_CONDUCT)

coderd/apidoc/docs.go

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ func New(options *Options) *API {
10471047
r.Use(httpmw.RateLimit(options.LoginRateLimit, time.Minute))
10481048
r.Post("/login", api.postLogin)
10491049
r.Post("/otp/request", api.postRequestOneTimePasscode)
1050+
r.Post("/validate-password", api.validateUserPassword)
10501051
r.Post("/otp/change-password", api.postChangePasswordWithOneTimePasscode)
10511052
r.Route("/oauth2", func(r chi.Router) {
10521053
r.Route("/github", func(r chi.Router) {

coderd/database/dbgen/dbgen.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,15 @@ func WorkspaceBuild(t testing.TB, db database.Store, orig database.WorkspaceBuil
288288
if err != nil {
289289
return err
290290
}
291+
292+
if orig.DailyCost > 0 {
293+
err = db.UpdateWorkspaceBuildCostByID(genCtx, database.UpdateWorkspaceBuildCostByIDParams{
294+
ID: buildID,
295+
DailyCost: orig.DailyCost,
296+
})
297+
require.NoError(t, err)
298+
}
299+
291300
build, err = db.GetWorkspaceBuildByID(genCtx, buildID)
292301
if err != nil {
293302
return err

coderd/database/dbmem/dbmem.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,19 @@ func (q *FakeQuerier) getOrganizationByIDNoLock(id uuid.UUID) (database.Organiza
11041104
return database.Organization{}, sql.ErrNoRows
11051105
}
11061106

1107+
func (q *FakeQuerier) getWorkspaceAgentScriptsByAgentIDsNoLock(ids []uuid.UUID) ([]database.WorkspaceAgentScript, error) {
1108+
scripts := make([]database.WorkspaceAgentScript, 0)
1109+
for _, script := range q.workspaceAgentScripts {
1110+
for _, id := range ids {
1111+
if script.WorkspaceAgentID == id {
1112+
scripts = append(scripts, script)
1113+
break
1114+
}
1115+
}
1116+
}
1117+
return scripts, nil
1118+
}
1119+
11071120
func (*FakeQuerier) AcquireLock(_ context.Context, _ int64) error {
11081121
return xerrors.New("AcquireLock must only be called within a transaction")
11091122
}
@@ -5854,12 +5867,12 @@ func (q *FakeQuerier) GetWorkspaceAgentScriptTimingsByBuildID(ctx context.Contex
58545867
q.mutex.RLock()
58555868
defer q.mutex.RUnlock()
58565869

5857-
build, err := q.GetWorkspaceBuildByID(ctx, id)
5870+
build, err := q.getWorkspaceBuildByIDNoLock(ctx, id)
58585871
if err != nil {
58595872
return nil, xerrors.Errorf("get build: %w", err)
58605873
}
58615874

5862-
resources, err := q.GetWorkspaceResourcesByJobID(ctx, build.JobID)
5875+
resources, err := q.getWorkspaceResourcesByJobIDNoLock(ctx, build.JobID)
58635876
if err != nil {
58645877
return nil, xerrors.Errorf("get resources: %w", err)
58655878
}
@@ -5868,7 +5881,7 @@ func (q *FakeQuerier) GetWorkspaceAgentScriptTimingsByBuildID(ctx context.Contex
58685881
resourceIDs = append(resourceIDs, res.ID)
58695882
}
58705883

5871-
agents, err := q.GetWorkspaceAgentsByResourceIDs(ctx, resourceIDs)
5884+
agents, err := q.getWorkspaceAgentsByResourceIDsNoLock(ctx, resourceIDs)
58725885
if err != nil {
58735886
return nil, xerrors.Errorf("get agents: %w", err)
58745887
}
@@ -5877,7 +5890,7 @@ func (q *FakeQuerier) GetWorkspaceAgentScriptTimingsByBuildID(ctx context.Contex
58775890
agentIDs = append(agentIDs, agent.ID)
58785891
}
58795892

5880-
scripts, err := q.GetWorkspaceAgentScriptsByAgentIDs(ctx, agentIDs)
5893+
scripts, err := q.getWorkspaceAgentScriptsByAgentIDsNoLock(agentIDs)
58815894
if err != nil {
58825895
return nil, xerrors.Errorf("get scripts: %w", err)
58835896
}
@@ -5933,16 +5946,7 @@ func (q *FakeQuerier) GetWorkspaceAgentScriptsByAgentIDs(_ context.Context, ids
59335946
q.mutex.RLock()
59345947
defer q.mutex.RUnlock()
59355948

5936-
scripts := make([]database.WorkspaceAgentScript, 0)
5937-
for _, script := range q.workspaceAgentScripts {
5938-
for _, id := range ids {
5939-
if script.WorkspaceAgentID == id {
5940-
scripts = append(scripts, script)
5941-
break
5942-
}
5943-
}
5944-
}
5945-
return scripts, nil
5949+
return q.getWorkspaceAgentScriptsByAgentIDsNoLock(ids)
59465950
}
59475951

59485952
func (q *FakeQuerier) GetWorkspaceAgentStats(_ context.Context, createdAfter time.Time) ([]database.GetWorkspaceAgentStatsRow, error) {

coderd/database/queries.sql.go

Lines changed: 5 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/quotas.sql

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,17 @@ FROM
2828
INNER JOIN
2929
workspaces on wb.workspace_id = workspaces.id
3030
WHERE
31+
-- Only return workspaces that match the user + organization.
32+
-- Quotas are calculated per user per organization.
33+
NOT workspaces.deleted AND
3134
workspaces.owner_id = @owner_id AND
3235
workspaces.organization_id = @organization_id
3336
ORDER BY
3437
wb.workspace_id,
35-
wb.created_at DESC
38+
wb.build_number DESC
3639
)
3740
SELECT
3841
coalesce(SUM(daily_cost), 0)::BIGINT
3942
FROM
40-
workspaces
41-
INNER JOIN latest_builds ON
42-
latest_builds.workspace_id = workspaces.id
43-
WHERE
44-
NOT deleted AND
45-
-- We can likely remove these conditions since we check above.
46-
-- But it does not hurt to be defensive and make sure future query changes
47-
-- do not break anything.
48-
workspaces.owner_id = @owner_id AND
49-
workspaces.organization_id = @organization_id
43+
latest_builds
5044
;

coderd/rbac/object_gen.go

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)