Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4df3f35

Browse files
committed
feat: Add trial property to licenses
This allows the frontend to display whether the user is ona trial license of Coder. This is useful for advertisingEnterprise functionality.
1 parent504cd46 commit4df3f35

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

‎codersdk/features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type Entitlements struct {
4242
Warnings []string`json:"warnings"`
4343
HasLicensebool`json:"has_license"`
4444
Experimentalbool`json:"experimental"`
45+
Trialbool`json:"trial"`
4546
}
4647

4748
func (c*Client)Entitlements(ctx context.Context) (Entitlements,error) {

‎enterprise/coderd/coderd.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ type API struct {
122122

123123
typeentitlementsstruct {
124124
hasLicensebool
125+
trialbool
125126
activeUsers codersdk.Feature
126127
auditLogs codersdk.Entitlement
127128
browserOnly codersdk.Entitlement
@@ -154,6 +155,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
154155
scim:codersdk.EntitlementNotEntitled,
155156
browserOnly:codersdk.EntitlementNotEntitled,
156157
workspaceQuota:codersdk.EntitlementNotEntitled,
158+
trial:true,
157159
}
158160

159161
// Here we loop through licenses to detect enabled features.
@@ -195,6 +197,9 @@ func (api *API) updateEntitlements(ctx context.Context) error {
195197
ifclaims.Features.WorkspaceQuota>0 {
196198
entitlements.workspaceQuota=entitlement
197199
}
200+
if!claims.Trial {
201+
entitlements.trial=claims.Trial
202+
}
198203
}
199204

200205
ifentitlements.auditLogs!=api.entitlements.auditLogs {
@@ -240,6 +245,7 @@ func (api *API) serveEntitlements(rw http.ResponseWriter, r *http.Request) {
240245
Features:make(map[string]codersdk.Feature),
241246
Warnings:make([]string,0),
242247
HasLicense:entitlements.hasLicense,
248+
Trial:entitlements.trial,
243249
Experimental:api.Experimental,
244250
}
245251

‎enterprise/coderd/coderdenttest/coderdenttest.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, io.Closer, *c
8484
typeLicenseOptionsstruct {
8585
AccountTypestring
8686
AccountIDstring
87+
Trialbool
8788
GraceAt time.Time
8889
ExpiresAt time.Time
8990
UserLimitint64
@@ -137,6 +138,7 @@ func GenerateLicense(t *testing.T, options LicenseOptions) string {
137138
LicenseExpires:jwt.NewNumericDate(options.GraceAt),
138139
AccountType:options.AccountType,
139140
AccountID:options.AccountID,
141+
Trial:options.Trial,
140142
Version:coderd.CurrentVersion,
141143
Features: coderd.Features{
142144
UserLimit:options.UserLimit,

‎enterprise/coderd/licenses.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ type Claims struct {
6262
LicenseExpires*jwt.NumericDate`json:"license_expires,omitempty"`
6363
AccountTypestring`json:"account_type,omitempty"`
6464
AccountIDstring`json:"account_id,omitempty"`
65+
Trialbool`json:"trial"`
6566
Versionuint64`json:"version"`
6667
FeaturesFeatures`json:"features"`
6768
}

‎enterprise/coderd/licenses_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func TestGetLicense(t *testing.T) {
8989
AuditLog:true,
9090
SCIM:true,
9191
BrowserOnly:true,
92+
Trial:true,
9293
UserLimit:200,
9394
})
9495

@@ -106,6 +107,7 @@ func TestGetLicense(t *testing.T) {
106107
},licenses[0].Claims["features"])
107108
assert.Equal(t,int32(2),licenses[1].ID)
108109
assert.Equal(t,"testing2",licenses[1].Claims["account_id"])
110+
assert.Equal(t,true,licenses[1].Claims["trial"])
109111
assert.Equal(t,map[string]interface{}{
110112
codersdk.FeatureUserLimit:json.Number("200"),
111113
codersdk.FeatureAuditLog:json.Number("1"),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp