Skip to content

Commit 6586b6f

Browse files
committed
require_promoted_version -> require_active_version
1 parent 5180fc3 commit 6586b6f

File tree

17 files changed

+45
-41
lines changed

17 files changed

+45
-41
lines changed

coderd/autobuild/lifecycle_executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,5 +460,5 @@ func auditBuild(ctx context.Context, log slog.Logger, auditor audit.Auditor, par
460460
}
461461

462462
func useActiveVersion(opts schedule.TemplateScheduleOptions, ws database.Workspace) bool {
463-
return opts.RequirePromotedVersion || ws.AutomaticUpdates == database.AutomaticUpdatesAlways
463+
return opts.RequireActiveVersion || ws.AutomaticUpdates == database.AutomaticUpdatesAlways
464464
}

coderd/database/dbauthz/dbauthz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2224,7 +2224,7 @@ func (q *querier) InsertWorkspaceBuild(ctx context.Context, arg database.InsertW
22242224
// If the template requires the promoted version we need to check if
22252225
// the user is a template admin. If they aren't and are attempting
22262226
// to use a non-promoted version then we must fail the request.
2227-
if t.RequirePromotedVersion {
2227+
if t.RequireActiveVersion {
22282228
if arg.TemplateVersionID != t.ActiveVersionID {
22292229
if err = q.authorizeContext(ctx, rbac.ActionUpdate, t); err != nil {
22302230
return xerrors.Errorf("cannot use non-active version: %w", err)

coderd/database/dbfake/dbfake.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5703,7 +5703,7 @@ func (q *FakeQuerier) UpdateTemplateScheduleByID(_ context.Context, arg database
57035703
tpl.FailureTTL = arg.FailureTTL
57045704
tpl.TimeTilDormant = arg.TimeTilDormant
57055705
tpl.TimeTilDormantAutoDelete = arg.TimeTilDormantAutoDelete
5706-
tpl.RequirePromotedVersion = arg.RequirePromotedVersion
5706+
tpl.RequireActiveVersion = arg.RequireActiveVersion
57075707
q.templates[idx] = tpl
57085708
return nil
57095709
}

coderd/database/dump.sql

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

coderd/database/migrations/000165_template_promotion.down.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BEGIN;
22

3-
ALTER TABLE templates DROP COLUMN require_promoted_version;
3+
ALTER TABLE templates DROP COLUMN require_active_version;
44

55
-- Update the template_with_users view;
66
DROP VIEW template_with_users;

coderd/database/migrations/000165_template_promotion.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ BEGIN;
22

33
DROP VIEW template_with_users;
44

5-
ALTER TABLE templates ADD COLUMN require_promoted_version boolean NOT NULL DEFAULT 'f';
5+
ALTER TABLE templates ADD COLUMN require_active_version boolean NOT NULL DEFAULT 'f';
66

77
CREATE VIEW
88
template_with_users

coderd/database/models.go

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

coderd/database/queries.sql.go

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

coderd/database/queries/templates.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ SET
123123
failure_ttl = $9,
124124
time_til_dormant = $10,
125125
time_til_dormant_autodelete = $11,
126-
require_promoted_version = $12
126+
require_active_version = $12
127127
WHERE
128128
id = $1
129129
;

coderd/schedule/template.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ type TemplateScheduleOptions struct {
118118
// workspaces whose dormant_at field violates the new template time_til_dormant_autodelete
119119
// threshold.
120120
UpdateWorkspaceDormantAt bool `json:"update_workspace_dormant_at"`
121-
RequirePromotedVersion bool `json:"require_promoted_version"`
121+
// RequireActiveVersion requires that a starting a workspace uses the active
122+
// version for a template.
123+
RequireActiveVersion bool `json:"require_promoted_version"`
122124
}
123125

124126
// TemplateScheduleStore provides an interface for retrieving template
@@ -164,7 +166,7 @@ func (*agplTemplateScheduleStore) Get(ctx context.Context, db database.Store, te
164166
FailureTTL: 0,
165167
TimeTilDormant: 0,
166168
TimeTilDormantAutoDelete: 0,
167-
RequirePromotedVersion: false,
169+
RequireActiveVersion: false,
168170
}, nil
169171
}
170172

@@ -196,7 +198,7 @@ func (*agplTemplateScheduleStore) Set(ctx context.Context, db database.Store, tp
196198
FailureTTL: tpl.FailureTTL,
197199
TimeTilDormant: tpl.TimeTilDormant,
198200
TimeTilDormantAutoDelete: tpl.TimeTilDormantAutoDelete,
199-
RequirePromotedVersion: tpl.RequirePromotedVersion,
201+
RequireActiveVersion: tpl.RequireActiveVersion,
200202
})
201203
if err != nil {
202204
return xerrors.Errorf("update template schedule: %w", err)

0 commit comments

Comments
 (0)