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

Skip to content

Commit 47da214

Browse files
committed
require_promoted_version -> require_active_version
1 parent 4b3194d commit 47da214

File tree

17 files changed

+84
-28
lines changed

17 files changed

+84
-28
lines changed

coderd/autobuild/lifecycle_executor.go

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

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

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
@@ -5729,7 +5729,7 @@ func (q *FakeQuerier) UpdateTemplateScheduleByID(_ context.Context, arg database
57295729
tpl.FailureTTL = arg.FailureTTL
57305730
tpl.TimeTilDormant = arg.TimeTilDormant
57315731
tpl.TimeTilDormantAutoDelete = arg.TimeTilDormantAutoDelete
5732-
tpl.RequirePromotedVersion = arg.RequirePromotedVersion
5732+
tpl.RequireActiveVersion = arg.RequireActiveVersion
57335733
q.templates[idx] = tpl
57345734
return nil
57355735
}

coderd/database/dump.sql

Lines changed: 8 additions & 0 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: 8 additions & 0 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: 38 additions & 2 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
@@ -124,7 +124,7 @@ SET
124124
failure_ttl = $10,
125125
time_til_dormant = $11,
126126
time_til_dormant_autodelete = $12,
127-
require_promoted_version = $13
127+
require_active_version = $13
128128
WHERE
129129
id = $1
130130
;

coderd/schedule/template.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,9 @@ type TemplateScheduleOptions struct {
151151
// workspaces whose dormant_at field violates the new template time_til_dormant_autodelete
152152
// threshold.
153153
UpdateWorkspaceDormantAt bool `json:"update_workspace_dormant_at"`
154-
RequirePromotedVersion bool `json:"require_promoted_version"`
154+
// RequireActiveVersion requires that a starting a workspace uses the active
155+
// version for a template.
156+
RequireActiveVersion bool `json:"require_promoted_version"`
155157
}
156158

157159
// TemplateScheduleStore provides an interface for retrieving template
@@ -201,7 +203,7 @@ func (*agplTemplateScheduleStore) Get(ctx context.Context, db database.Store, te
201203
FailureTTL: 0,
202204
TimeTilDormant: 0,
203205
TimeTilDormantAutoDelete: 0,
204-
RequirePromotedVersion: false,
206+
RequireActiveVersion: false,
205207
}, nil
206208
}
207209

@@ -234,7 +236,7 @@ func (*agplTemplateScheduleStore) Set(ctx context.Context, db database.Store, tp
234236
FailureTTL: tpl.FailureTTL,
235237
TimeTilDormant: tpl.TimeTilDormant,
236238
TimeTilDormantAutoDelete: tpl.TimeTilDormantAutoDelete,
237-
RequirePromotedVersion: tpl.RequirePromotedVersion,
239+
RequireActiveVersion: tpl.RequireActiveVersion,
238240
})
239241
if err != nil {
240242
return xerrors.Errorf("update template schedule: %w", err)

0 commit comments

Comments
 (0)