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

Skip to content

Commit 5509824

Browse files
committed
feat: add template max_ttl
1 parent d60ec3e commit 5509824

9 files changed

+118
-32
lines changed

coderd/activitybump.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ func activityBumpWorkspace(log slog.Logger, db database.Store, workspaceID uuid.
7070
}
7171

7272
newDeadline := database.Now().Add(bumpAmount)
73+
if !build.MaxDeadline.IsZero() && newDeadline.After(build.MaxDeadline) {
74+
newDeadline = build.MaxDeadline
75+
}
7376

7477
if _, err := s.UpdateWorkspaceBuildByID(ctx, database.UpdateWorkspaceBuildByIDParams{
7578
ID: build.ID,
7679
UpdatedAt: database.Now(),
7780
ProvisionerState: build.ProvisionerState,
7881
Deadline: newDeadline,
82+
MaxDeadline: build.MaxDeadline,
7983
}); err != nil {
8084
return xerrors.Errorf("update workspace build: %w", err)
8185
}

coderd/database/dump.sql

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE "workspace_builds" DROP COLUMN "max_deadline";
2+
3+
ALTER TABLE "templates" DROP COLUMN "max_ttl";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE "templates" ADD COLUMN "max_ttl" bigint DEFAULT '0'::bigint NOT NULL;
2+
3+
ALTER TABLE "workspace_builds" ADD COLUMN "max_deadline" timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL;

coderd/database/models.go

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

0 commit comments

Comments
 (0)