Skip to content

Commit edc7f15

Browse files
committed
feat: add locked TTL field to template meta
1 parent 977e9ef commit edc7f15

File tree

19 files changed

+163
-85
lines changed

19 files changed

+163
-85
lines changed

coderd/apidoc/docs.go

Lines changed: 9 additions & 2 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: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
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+
BEGIN;
2+
ALTER TABLE templates DROP COLUMN locked_ttl;
3+
COMMIT;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BEGIN;
2+
ALTER TABLE templates ADD COLUMN locked_ttl BIGINT NOT NULL DEFAULT 0;
3+
COMMIT;

coderd/database/models.go

Lines changed: 1 addition & 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: 20 additions & 9 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ SET
120120
default_ttl = $5,
121121
max_ttl = $6,
122122
failure_ttl = $7,
123-
inactivity_ttl = $8
123+
inactivity_ttl = $8,
124+
locked_ttl = $9
124125
WHERE
125126
id = $1
126127
RETURNING

coderd/database/sqlc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ overrides:
5555
uuid: UUID
5656
failure_ttl: FailureTTL
5757
inactivity_ttl: InactivityTTL
58+
locked_ttl: LockedTTL
5859

5960
sql:
6061
- schema: "./dump.sql"

coderd/schedule/template.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ type TemplateScheduleOptions struct {
1818
//
1919
// If set, users cannot disable automatic workspace shutdown.
2020
MaxTTL time.Duration `json:"max_ttl"`
21-
// If FailureTTL is set, all failed workspaces will be stopped automatically after this time has elapsed.
21+
// FailureTTL dictates the duration after which failed workspaces will be stopped automatically.
2222
FailureTTL time.Duration `json:"failure_ttl"`
23-
// If InactivityTTL is set, all inactive workspaces will be deleted automatically after this time has elapsed.
23+
// InactivityTTL dictates the duration after which inactive workspaces will be locked.
2424
InactivityTTL time.Duration `json:"inactivity_ttl"`
25+
// LockedTTL dictates the duration after which locked workspaces will be permanently deleted.
26+
LockedTTL time.Duration `json:"locked_ttl"`
2527
}
2628

2729
// TemplateScheduleStore provides an interface for retrieving template
@@ -51,11 +53,12 @@ func (*agplTemplateScheduleStore) GetTemplateScheduleOptions(ctx context.Context
5153
UserAutostartEnabled: true,
5254
UserAutostopEnabled: true,
5355
DefaultTTL: time.Duration(tpl.DefaultTTL),
54-
// Disregard the values in the database, since MaxTTL, FailureTTL, and InactivityTTL are enterprise
56+
// Disregard the values in the database, since MaxTTL, FailureTTL, InactivityTTL, and LockedTTL are enterprise
5557
// features.
5658
MaxTTL: 0,
5759
FailureTTL: 0,
5860
InactivityTTL: 0,
61+
LockedTTL: 0,
5962
}, nil
6063
}
6164

@@ -76,5 +79,6 @@ func (*agplTemplateScheduleStore) SetTemplateScheduleOptions(ctx context.Context
7679
MaxTTL: tpl.MaxTTL,
7780
FailureTTL: tpl.FailureTTL,
7881
InactivityTTL: tpl.InactivityTTL,
82+
LockedTTL: tpl.LockedTTL,
7983
})
8084
}

0 commit comments

Comments
 (0)