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

Commit0b3e816

Browse files
committed
chore: add enterprise feature for aibridge
1 parente5ccb57 commit0b3e816

File tree

7 files changed

+86
-1
lines changed

7 files changed

+86
-1
lines changed

‎codersdk/deployment.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ const (
9090
// enterprise/coderd/license/license.go for the license format.
9191
FeatureManagedAgentLimitFeatureName="managed_agent_limit"
9292
FeatureWorkspaceExternalAgentFeatureName="workspace_external_agent"
93+
FeatureAIBridgeFeatureName="aibridge"
9394
)
9495

9596
var (
@@ -117,6 +118,7 @@ var (
117118
FeatureWorkspacePrebuilds,
118119
FeatureManagedAgentLimit,
119120
FeatureWorkspaceExternalAgent,
121+
FeatureAIBridge,
120122
}
121123

122124
// FeatureNamesMap is a map of all feature names for quick lookups.
@@ -136,6 +138,8 @@ func (n FeatureName) Humanize() string {
136138
return"Template RBAC"
137139
caseFeatureSCIM:
138140
return"SCIM"
141+
caseFeatureAIBridge:
142+
return"AI Bridge"
139143
default:
140144
returnstrings.Title(strings.ReplaceAll(string(n),"_"," "))
141145
}

‎enterprise/cli/exp_aibridge_test.go‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/coder/coder/v2/coderd/database/dbtime"
1717
"github.com/coder/coder/v2/codersdk"
1818
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
19+
"github.com/coder/coder/v2/enterprise/coderd/license"
1920
"github.com/coder/coder/v2/testutil"
2021
)
2122

@@ -31,6 +32,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
3132
Options:&coderdtest.Options{
3233
DeploymentValues:dv,
3334
},
35+
LicenseOptions:&coderdenttest.LicenseOptions{
36+
Features: license.Features{
37+
codersdk.FeatureAIBridge:1,
38+
},
39+
},
3440
})
3541
memberClient,member:=coderdtest.CreateAnotherUser(t,client,owner.OrganizationID)
3642
now:=dbtime.Now()
@@ -76,6 +82,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
7682
Options:&coderdtest.Options{
7783
DeploymentValues:dv,
7884
},
85+
LicenseOptions:&coderdenttest.LicenseOptions{
86+
Features: license.Features{
87+
codersdk.FeatureAIBridge:1,
88+
},
89+
},
7990
})
8091
memberClient,member:=coderdtest.CreateAnotherUser(t,client,owner.OrganizationID)
8192

@@ -156,6 +167,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
156167
Options:&coderdtest.Options{
157168
DeploymentValues:dv,
158169
},
170+
LicenseOptions:&coderdenttest.LicenseOptions{
171+
Features: license.Features{
172+
codersdk.FeatureAIBridge:1,
173+
},
174+
},
159175
})
160176
memberClient,member:=coderdtest.CreateAnotherUser(t,client,owner.OrganizationID)
161177

‎enterprise/cli/server.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,12 @@ func (r *RootCmd) Server(_ func()) *serpent.Command {
148148

149149
experiments:=agplcoderd.ReadExperiments(options.Logger,options.DeploymentValues.Experiments.Value())
150150

151-
varaibridgeDaemon*aibridged.Server
152151
// In-memory aibridge daemon.
152+
// TODO(@deansheather): the lifecycle of the aibridged server is
153+
// probably better managed by the enterprise API type itself. Managing
154+
// it in the API type means we can avoid starting it up when the license
155+
// is not entitled to the feature.
156+
varaibridgeDaemon*aibridged.Server
153157
ifoptions.DeploymentValues.AI.BridgeConfig.Enabled {
154158
ifexperiments.Enabled(codersdk.ExperimentAIBridge) {
155159
aibridgeDaemon,err=newAIBridgeDaemon(api)

‎enterprise/coderd/aibridge_test.go‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package coderd_test
22

33
import (
4+
"net/http"
45
"testing"
56
"time"
67

@@ -15,12 +16,37 @@ import (
1516
"github.com/coder/coder/v2/codersdk"
1617
"github.com/coder/coder/v2/cryptorand"
1718
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
19+
"github.com/coder/coder/v2/enterprise/coderd/license"
1820
"github.com/coder/coder/v2/testutil"
1921
)
2022

2123
funcTestAIBridgeListInterceptions(t*testing.T) {
2224
t.Parallel()
2325

26+
t.Run("RequiresLicenseFeature",func(t*testing.T) {
27+
t.Parallel()
28+
29+
dv:=coderdtest.DeploymentValues(t)
30+
dv.Experiments= []string{string(codersdk.ExperimentAIBridge)}
31+
client,_:=coderdenttest.New(t,&coderdenttest.Options{
32+
Options:&coderdtest.Options{
33+
DeploymentValues:dv,
34+
},
35+
LicenseOptions:&coderdenttest.LicenseOptions{
36+
// No aibridge feature
37+
Features: license.Features{},
38+
},
39+
})
40+
experimentalClient:=codersdk.NewExperimentalClient(client)
41+
42+
ctx:=testutil.Context(t,testutil.WaitLong)
43+
_,err:=experimentalClient.AIBridgeListInterceptions(ctx, codersdk.AIBridgeListInterceptionsFilter{})
44+
varsdkErr*codersdk.Error
45+
require.ErrorAs(t,err,&sdkErr)
46+
require.Equal(t,http.StatusForbidden,sdkErr.StatusCode())
47+
require.Equal(t,"AI Bridge is a Premium feature. Contact sales!",sdkErr.Message)
48+
})
49+
2450
t.Run("EmptyDB",func(t*testing.T) {
2551
t.Parallel()
2652
dv:=coderdtest.DeploymentValues(t)
@@ -29,6 +55,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
2955
Options:&coderdtest.Options{
3056
DeploymentValues:dv,
3157
},
58+
LicenseOptions:&coderdenttest.LicenseOptions{
59+
Features: license.Features{
60+
codersdk.FeatureAIBridge:1,
61+
},
62+
},
3263
})
3364
experimentalClient:=codersdk.NewExperimentalClient(client)
3465
ctx:=testutil.Context(t,testutil.WaitLong)
@@ -45,6 +76,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
4576
Options:&coderdtest.Options{
4677
DeploymentValues:dv,
4778
},
79+
LicenseOptions:&coderdenttest.LicenseOptions{
80+
Features: license.Features{
81+
codersdk.FeatureAIBridge:1,
82+
},
83+
},
4884
})
4985
experimentalClient:=codersdk.NewExperimentalClient(client)
5086
ctx:=testutil.Context(t,testutil.WaitLong)
@@ -126,6 +162,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
126162
Options:&coderdtest.Options{
127163
DeploymentValues:dv,
128164
},
165+
LicenseOptions:&coderdenttest.LicenseOptions{
166+
Features: license.Features{
167+
codersdk.FeatureAIBridge:1,
168+
},
169+
},
129170
})
130171
experimentalClient:=codersdk.NewExperimentalClient(client)
131172
ctx:=testutil.Context(t,testutil.WaitLong)
@@ -210,6 +251,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
210251
Options:&coderdtest.Options{
211252
DeploymentValues:dv,
212253
},
254+
LicenseOptions:&coderdenttest.LicenseOptions{
255+
Features: license.Features{
256+
codersdk.FeatureAIBridge:1,
257+
},
258+
},
213259
})
214260
adminExperimentalClient:=codersdk.NewExperimentalClient(adminClient)
215261
ctx:=testutil.Context(t,testutil.WaitLong)
@@ -249,6 +295,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
249295
Options:&coderdtest.Options{
250296
DeploymentValues:dv,
251297
},
298+
LicenseOptions:&coderdenttest.LicenseOptions{
299+
Features: license.Features{
300+
codersdk.FeatureAIBridge:1,
301+
},
302+
},
252303
})
253304
experimentalClient:=codersdk.NewExperimentalClient(client)
254305
_,secondUser:=coderdtest.CreateAnotherUser(t,client,firstUser.OrganizationID)
@@ -407,6 +458,11 @@ func TestAIBridgeListInterceptions(t *testing.T) {
407458
Options:&coderdtest.Options{
408459
DeploymentValues:dv,
409460
},
461+
LicenseOptions:&coderdenttest.LicenseOptions{
462+
Features: license.Features{
463+
codersdk.FeatureAIBridge:1,
464+
},
465+
},
410466
})
411467
experimentalClient:=codersdk.NewExperimentalClient(client)
412468

‎enterprise/coderd/coderd.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
229229
api.AGPL.ExperimentalHandler.Group(func(r chi.Router) {
230230
r.Route("/aibridge",func(r chi.Router) {
231231
r.Use(
232+
api.RequireFeatureMW(codersdk.FeatureAIBridge),
232233
httpmw.RequireExperimentWithDevBypass(api.AGPL.Experiments,codersdk.ExperimentAIBridge),
233234
)
234235
r.Group(func(r chi.Router) {
@@ -770,6 +771,7 @@ func (api *API) updateEntitlements(ctx context.Context) error {
770771
codersdk.FeatureUserRoleManagement:true,
771772
codersdk.FeatureAccessControl:true,
772773
codersdk.FeatureControlSharedPorts:true,
774+
codersdk.FeatureAIBridge:true,
773775
})
774776
iferr!=nil {
775777
return codersdk.Entitlements{},err

‎enterprise/coderd/license/license_test.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,7 @@ func TestLicenseEntitlements(t *testing.T) {
890890
codersdk.FeatureAccessControl:true,
891891
codersdk.FeatureControlSharedPorts:true,
892892
codersdk.FeatureWorkspaceExternalAgent:true,
893+
codersdk.FeatureAIBridge:true,
893894
}
894895

895896
legacyLicense:=func()*coderdenttest.LicenseOptions {

‎site/src/api/typesGenerated.ts‎

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp