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

Commita5a5c4d

Browse files
authored
chore: Add workspace proxy enterprise cli commands (#7176)
* feat: Add workspace proxy enterprise cli commands* chore: Handle custom workspace proxy options. Remove excess* chore: Add endpoint to register workspace proxies
1 parent8926c10 commita5a5c4d

30 files changed

+1558
-107
lines changed

‎cli/clibase/option.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ func (s *OptionSet) Add(opts ...Option) {
8080
*s=append(*s,opts...)
8181
}
8282

83+
// Filter will only return options that match the given filter. (return true)
84+
func (sOptionSet)Filter(filterfunc(optOption)bool)OptionSet {
85+
cpy:=make(OptionSet,0)
86+
for_,opt:=ranges {
87+
iffilter(opt) {
88+
cpy=append(cpy,opt)
89+
}
90+
}
91+
returncpy
92+
}
93+
8394
// FlagSet returns a pflag.FlagSet for the OptionSet.
8495
func (s*OptionSet)FlagSet()*pflag.FlagSet {
8596
ifs==nil {

‎cli/cliui/output.go‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,35 @@ func (textFormat) AttachOptions(_ *clibase.OptionSet) {}
192192
func (textFormat)Format(_ context.Context,dataany) (string,error) {
193193
returnfmt.Sprintf("%s",data),nil
194194
}
195+
196+
// DataChangeFormat allows manipulating the data passed to an output format.
197+
// This is because sometimes the data needs to be manipulated before it can be
198+
// passed to the output format.
199+
// For example, you may want to pass something different to the text formatter
200+
// than what you pass to the json formatter.
201+
typeDataChangeFormatstruct {
202+
formatOutputFormat
203+
changefunc(dataany) (any,error)
204+
}
205+
206+
// ChangeFormatterData allows manipulating the data passed to an output
207+
// format.
208+
funcChangeFormatterData(formatOutputFormat,changefunc(dataany) (any,error))*DataChangeFormat {
209+
return&DataChangeFormat{format:format,change:change}
210+
}
211+
212+
func (d*DataChangeFormat)ID()string {
213+
returnd.format.ID()
214+
}
215+
216+
func (d*DataChangeFormat)AttachOptions(opts*clibase.OptionSet) {
217+
d.format.AttachOptions(opts)
218+
}
219+
220+
func (d*DataChangeFormat)Format(ctx context.Context,dataany) (string,error) {
221+
newData,err:=d.change(data)
222+
iferr!=nil {
223+
return"",err
224+
}
225+
returnd.format.Format(ctx,newData)
226+
}

‎coderd/apidoc/docs.go‎

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

‎coderd/apidoc/swagger.json‎

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

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ var (
181181
rbac.ResourceUserData.Type: {rbac.ActionCreate,rbac.ActionUpdate},
182182
rbac.ResourceWorkspace.Type: {rbac.ActionUpdate},
183183
rbac.ResourceWorkspaceExecution.Type: {rbac.ActionCreate},
184+
rbac.ResourceWorkspaceProxy.Type: {rbac.ActionCreate,rbac.ActionUpdate,rbac.ActionDelete},
184185
}),
185186
Org:map[string][]rbac.Permission{},
186187
User: []rbac.Permission{},

‎coderd/database/dbauthz/querier.go‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,10 @@ func (q *querier) GetWorkspaceProxyByID(ctx context.Context, id uuid.UUID) (data
16971697
returnfetch(q.log,q.auth,q.db.GetWorkspaceProxyByID)(ctx,id)
16981698
}
16991699

1700+
func (q*querier)GetWorkspaceProxyByName(ctx context.Context,namestring) (database.WorkspaceProxy,error) {
1701+
returnfetch(q.log,q.auth,q.db.GetWorkspaceProxyByName)(ctx,name)
1702+
}
1703+
17001704
func (q*querier)GetWorkspaceProxyByHostname(ctx context.Context,hostnamestring) (database.WorkspaceProxy,error) {
17011705
returnfetch(q.log,q.auth,q.db.GetWorkspaceProxyByHostname)(ctx,hostname)
17021706
}
@@ -1705,11 +1709,11 @@ func (q *querier) InsertWorkspaceProxy(ctx context.Context, arg database.InsertW
17051709
returninsert(q.log,q.auth,rbac.ResourceWorkspaceProxy,q.db.InsertWorkspaceProxy)(ctx,arg)
17061710
}
17071711

1708-
func (q*querier)UpdateWorkspaceProxy(ctx context.Context,arg database.UpdateWorkspaceProxyParams) (database.WorkspaceProxy,error) {
1709-
fetch:=func(ctx context.Context,arg database.UpdateWorkspaceProxyParams) (database.WorkspaceProxy,error) {
1712+
func (q*querier)RegisterWorkspaceProxy(ctx context.Context,arg database.RegisterWorkspaceProxyParams) (database.WorkspaceProxy,error) {
1713+
fetch:=func(ctx context.Context,arg database.RegisterWorkspaceProxyParams) (database.WorkspaceProxy,error) {
17101714
returnq.db.GetWorkspaceProxyByID(ctx,arg.ID)
17111715
}
1712-
returnupdateWithReturn(q.log,q.auth,fetch,q.db.UpdateWorkspaceProxy)(ctx,arg)
1716+
returnupdateWithReturn(q.log,q.auth,fetch,q.db.RegisterWorkspaceProxy)(ctx,arg)
17131717
}
17141718

17151719
func (q*querier)UpdateWorkspaceProxyDeleted(ctx context.Context,arg database.UpdateWorkspaceProxyDeletedParams)error {

‎coderd/database/dbauthz/querier_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ func (s *MethodTestSuite) TestWorkspaceProxy() {
444444
ID:uuid.New(),
445445
}).Asserts(rbac.ResourceWorkspaceProxy,rbac.ActionCreate)
446446
}))
447-
s.Run("UpdateWorkspaceProxy",s.Subtest(func(db database.Store,check*expects) {
447+
s.Run("RegisterWorkspaceProxy",s.Subtest(func(db database.Store,check*expects) {
448448
p,_:=dbgen.WorkspaceProxy(s.T(),db, database.WorkspaceProxy{})
449-
check.Args(database.UpdateWorkspaceProxyParams{
449+
check.Args(database.RegisterWorkspaceProxyParams{
450450
ID:p.ID,
451451
}).Asserts(p,rbac.ActionUpdate)
452452
}))

‎coderd/database/dbfake/databasefake.go‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5127,6 +5127,21 @@ func (q *fakeQuerier) GetWorkspaceProxyByID(_ context.Context, id uuid.UUID) (da
51275127
return database.WorkspaceProxy{},sql.ErrNoRows
51285128
}
51295129

5130+
func (q*fakeQuerier)GetWorkspaceProxyByName(_ context.Context,namestring) (database.WorkspaceProxy,error) {
5131+
q.mutex.Lock()
5132+
deferq.mutex.Unlock()
5133+
5134+
for_,proxy:=rangeq.workspaceProxies {
5135+
ifproxy.Deleted {
5136+
continue
5137+
}
5138+
ifproxy.Name==name {
5139+
returnproxy,nil
5140+
}
5141+
}
5142+
return database.WorkspaceProxy{},sql.ErrNoRows
5143+
}
5144+
51305145
func (q*fakeQuerier)GetWorkspaceProxyByHostname(_ context.Context,hostnamestring) (database.WorkspaceProxy,error) {
51315146
q.mutex.RLock()
51325147
deferq.mutex.RUnlock()
@@ -5187,14 +5202,12 @@ func (q *fakeQuerier) InsertWorkspaceProxy(_ context.Context, arg database.Inser
51875202
returnp,nil
51885203
}
51895204

5190-
func (q*fakeQuerier)UpdateWorkspaceProxy(_ context.Context,arg database.UpdateWorkspaceProxyParams) (database.WorkspaceProxy,error) {
5205+
func (q*fakeQuerier)RegisterWorkspaceProxy(_ context.Context,arg database.RegisterWorkspaceProxyParams) (database.WorkspaceProxy,error) {
51915206
q.mutex.Lock()
51925207
deferq.mutex.Unlock()
51935208

51945209
fori,p:=rangeq.workspaceProxies {
51955210
ifp.ID==arg.ID {
5196-
p.Name=arg.Name
5197-
p.Icon=arg.Icon
51985211
p.Url=arg.Url
51995212
p.WildcardHostname=arg.WildcardHostname
52005213
p.UpdatedAt=database.Now()

‎coderd/database/querier.go‎

Lines changed: 2 additions & 1 deletion
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