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

Commit202ff13

Browse files
committed
dean changes
1 parentf188ebc commit202ff13

File tree

7 files changed

+395
-162
lines changed

7 files changed

+395
-162
lines changed

‎cli/aibridge.go‎

Lines changed: 0 additions & 133 deletions
This file was deleted.

‎cli/exp.go‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎cli/root.go‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,53 @@ func (r *RootCmd) CoreSubcommands() []*serpent.Command {
128128

129129
// Hidden
130130
r.connectCmd(),
131-
r.expCmd(),
132131
gitssh(),
133132
r.support(),
134133
r.vpnDaemon(),
135134
r.vscodeSSH(),
136135
workspaceAgent(),
137-
r.aibridge(),
138136
}
139137
}
140138

139+
// AGPLExperimental returns all AGPL experimental subcommands.
140+
func (r*RootCmd)AGPLExperimental() []*serpent.Command {
141+
return []*serpent.Command{
142+
r.scaletestCmd(),
143+
r.errorExample(),
144+
r.mcpCommand(),
145+
r.promptExample(),
146+
r.rptyCommand(),
147+
r.tasksCommand(),
148+
}
149+
}
150+
151+
// AGPL returns all AGPL commands including any non-core commands that are
152+
// duplicated in the Enterprise CLI.
141153
func (r*RootCmd)AGPL() []*serpent.Command {
142154
all:=append(
143155
r.CoreSubcommands(),
144156
r.Server(/* Do not import coderd here. */nil),
145157
r.Provisioners(),
158+
ExperimentalCommand(r.AGPLExperimental()),
146159
)
147160
returnall
148161
}
149162

163+
// ExperimentalCommand creates an experimental command that is hidden and has
164+
// the given subcommands.
165+
funcExperimentalCommand(subcommands []*serpent.Command)*serpent.Command {
166+
cmd:=&serpent.Command{
167+
Use:"exp",
168+
Short:"Internal commands for testing and experimentation. These are prone to breaking changes with no notice.",
169+
Handler:func(i*serpent.Invocation)error {
170+
returni.Command.HelpHandler(i)
171+
},
172+
Hidden:true,
173+
Children:subcommands,
174+
}
175+
returncmd
176+
}
177+
150178
// RunWithSubcommands runs the root command with the given subcommands.
151179
// It is abstracted to enable the Enterprise code to add commands.
152180
func (r*RootCmd)RunWithSubcommands(subcommands []*serpent.Command) {

‎docs/reference/cli/index.md‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎enterprise/cli/exp_aibridge.go‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
package cli
2+
3+
import (
4+
"encoding/json"
5+
"math"
6+
"time"
7+
8+
"golang.org/x/xerrors"
9+
10+
"github.com/coder/coder/v2/codersdk"
11+
"github.com/coder/serpent"
12+
)
13+
14+
func (r*RootCmd)aibridge()*serpent.Command {
15+
cmd:=&serpent.Command{
16+
Use:"aibridge",
17+
Short:"Manage AIBridge.",
18+
Handler:func(inv*serpent.Invocation)error {
19+
returninv.Command.HelpHandler(inv)
20+
},
21+
Children: []*serpent.Command{
22+
r.listInterceptions(),
23+
},
24+
}
25+
returncmd
26+
}
27+
28+
func (r*RootCmd)listInterceptions()*serpent.Command {
29+
var (
30+
initiatorstring
31+
startedBeforeRawstring
32+
startedAfterRawstring
33+
providerstring
34+
modelstring
35+
limitint64
36+
offsetint64
37+
)
38+
39+
return&serpent.Command{
40+
Use:"list-interceptions",
41+
Short:"List AIBridge interceptions as JSON.",
42+
Options: serpent.OptionSet{
43+
{
44+
Flag:"initiator",
45+
Description:`Only return interceptions initiated by this user. Accepts a user ID, username, or "me".`,
46+
Default:"",
47+
Value:serpent.StringOf(&initiator),
48+
},
49+
{
50+
Flag:"started-before",
51+
Description:`Only return interceptions started before this time. Accepts a time in the format "2021-01-01T00:00:00Z".`,
52+
Default:"",
53+
Value:serpent.StringOf(&startedBeforeRaw),
54+
},
55+
{
56+
Flag:"started-after",
57+
Description:`Only return interceptions started after this time. Accepts a time in the format "2021-01-01T00:00:00Z".`,
58+
Default:"",
59+
Value:serpent.StringOf(&startedAfterRaw),
60+
},
61+
{
62+
Flag:"provider",
63+
Description:`Only return interceptions from this provider.`,
64+
Default:"",
65+
Value:serpent.StringOf(&provider),
66+
},
67+
{
68+
Flag:"model",
69+
Description:`Only return interceptions from this model.`,
70+
Default:"",
71+
Value:serpent.StringOf(&model),
72+
},
73+
{
74+
Flag:"limit",
75+
Description:`The limit of results to return.`,
76+
Default:"100",
77+
Value:serpent.Int64Of(&limit),
78+
},
79+
{
80+
Flag:"offset",
81+
Description:`The offset of results to return.`,
82+
Default:"0",
83+
Value:serpent.Int64Of(&offset),
84+
},
85+
},
86+
Handler:func(inv*serpent.Invocation)error {
87+
client,err:=r.InitClient(inv)
88+
iferr!=nil {
89+
returnerr
90+
}
91+
92+
startedBefore:= time.Time{}
93+
ifstartedBeforeRaw!="" {
94+
startedBefore,err=time.Parse(time.RFC3339,startedBeforeRaw)
95+
iferr!=nil {
96+
returnxerrors.Errorf("parse started before filter value %q: %w",startedBeforeRaw,err)
97+
}
98+
}
99+
100+
startedAfter:= time.Time{}
101+
ifstartedAfterRaw!="" {
102+
startedAfter,err=time.Parse(time.RFC3339,startedAfterRaw)
103+
iferr!=nil {
104+
returnxerrors.Errorf("parse started after filter value %q: %w",startedAfterRaw,err)
105+
}
106+
}
107+
108+
iflimit>math.MaxInt32 {
109+
returnxerrors.Errorf("limit value to high")
110+
}
111+
iflimit<0 {
112+
returnxerrors.Errorf("limit value negative")
113+
}
114+
115+
exCli:=codersdk.NewExperimentalClient(client)
116+
resp,err:=exCli.AIBridgeListInterceptions(inv.Context(), codersdk.AIBridgeListInterceptionsFilter{
117+
Pagination: codersdk.Pagination{
118+
// #nosec G115 - Safe conversion for pagination limit which is expected to be within int32 range
119+
Limit:int(limit),
120+
// #nosec G115 - Safe conversion for pagination offset which is expected to be within int32 range
121+
Offset:int(offset),
122+
},
123+
Initiator:initiator,
124+
StartedBefore:startedBefore,
125+
StartedAfter:startedAfter,
126+
Provider:provider,
127+
Model:model,
128+
})
129+
iferr!=nil {
130+
returnxerrors.Errorf("list interceptions: %w",err)
131+
}
132+
133+
// We currently only support JSON output, so we don't use a
134+
// formatter.
135+
enc:=json.NewEncoder(inv.Stdout)
136+
enc.SetIndent(""," ")
137+
err=enc.Encode(resp.Results)
138+
iferr!=nil {
139+
returnerr
140+
}
141+
142+
returnerr
143+
},
144+
}
145+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp