Skip to content

Commit cdb64f6

Browse files
committed
refactor: worker gateway
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent bcb4e74 commit cdb64f6

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

pkg/workergateway/service/service.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,20 +161,20 @@ func (s *Service) handleListInstanceTypes(w http.ResponseWriter, r *http.Request
161161

162162
// handleListInstances handles the list instances request.
163163
//
164-
// GET /instances?cluster=cluster1&cluster=cluster2[&organization=foo&watch=true]
164+
// GET /instances?cluster=cluster1&cluster=cluster2[&namespace=foo&watch=true]
165165
func (s *Service) handleListInstances(w http.ResponseWriter, r *http.Request) {
166166
ctx := r.Context()
167167
logger := s.Logger.WithValues("method", r.Method, "path", r.URL.Path).V(2)
168168

169169
var req struct {
170-
Clusters []string `query:"cluster"`
171-
Organization string `query:"organization"`
172-
Watch bool `query:"watch"`
170+
Clusters []string `query:"cluster"`
171+
Namespace string `query:"namespace"`
172+
Watch bool `query:"watch"`
173173
}
174174
_ = httpx.BindWith(r, &req, httpx.BindQuery)
175175

176176
gvk := worker.SchemeGroupVersionKind("Instance")
177-
iterOpts := manager.IteratorOptions{Namespace: req.Organization}
177+
iterOpts := manager.IteratorOptions{Namespace: req.Namespace}
178178

179179
if !req.Watch {
180180
listOp := OpListClusterInstances()
@@ -189,7 +189,7 @@ func (s *Service) handleListInstances(w http.ResponseWriter, r *http.Request) {
189189
return
190190
}
191191

192-
watchOp := OpHandleClusterInstance(req.Organization)
192+
watchOp := OpHandleClusterInstance(req.Namespace)
193193
s.streamResponse(w, r, req.Clusters, gvk, watchOp.Handle)
194194
}
195195

@@ -227,20 +227,20 @@ func (s *Service) handleListInstancePersistentVolumeTypes(w http.ResponseWriter,
227227

228228
// handleListInstancePersistentVolumes handles the list instance persistent volumes request.
229229
//
230-
// GET /instancepersistentvolumes?cluster=cluster1&cluster=cluster2[&organization=foo&watch=true]
230+
// GET /instancepersistentvolumes?cluster=cluster1&cluster=cluster2[&namespace=foo&watch=true]
231231
func (s *Service) handleListInstancePersistentVolumes(w http.ResponseWriter, r *http.Request) {
232232
ctx := r.Context()
233233
logger := s.Logger.WithValues("method", r.Method, "path", r.URL.Path).V(2)
234234

235235
var req struct {
236-
Clusters []string `query:"cluster"`
237-
Organization string `query:"organization"`
238-
Watch bool `query:"watch"`
236+
Clusters []string `query:"cluster"`
237+
Namespace string `query:"namespace"`
238+
Watch bool `query:"watch"`
239239
}
240240
_ = httpx.BindWith(r, &req, httpx.BindQuery)
241241

242242
gvk := worker.SchemeGroupVersionKind("InstancePersistentVolume")
243-
iterOpts := manager.IteratorOptions{Namespace: req.Organization}
243+
iterOpts := manager.IteratorOptions{Namespace: req.Namespace}
244244

245245
if !req.Watch {
246246
listOp := OpListClusterInstancePersistentVolumes()
@@ -255,26 +255,26 @@ func (s *Service) handleListInstancePersistentVolumes(w http.ResponseWriter, r *
255255
return
256256
}
257257

258-
watchOp := OpHandleClusterInstancePersistentVolume(req.Organization)
258+
watchOp := OpHandleClusterInstancePersistentVolume(req.Namespace)
259259
s.streamResponse(w, r, req.Clusters, gvk, watchOp.Handle)
260260
}
261261

262262
// handleListInstanceImagePullSecrets handles the list instance image pull secrets request.
263263
//
264-
// GET /instanceimagepullsecrets?cluster=cluster1&cluster=cluster2[&organization=foo&watch=true]
264+
// GET /instanceimagepullsecrets?cluster=cluster1&cluster=cluster2[&namespace=foo&watch=true]
265265
func (s *Service) handleListInstanceImagePullSecrets(w http.ResponseWriter, r *http.Request) {
266266
ctx := r.Context()
267267
logger := s.Logger.WithValues("method", r.Method, "path", r.URL.Path).V(2)
268268

269269
var req struct {
270-
Clusters []string `query:"cluster"`
271-
Organization string `query:"organization"`
272-
Watch bool `query:"watch"`
270+
Clusters []string `query:"cluster"`
271+
Namespace string `query:"namespace"`
272+
Watch bool `query:"watch"`
273273
}
274274
_ = httpx.BindWith(r, &req, httpx.BindQuery)
275275

276276
gvk := worker.SchemeGroupVersionKind("InstanceImagePullSecret")
277-
iterOpts := manager.IteratorOptions{Namespace: req.Organization}
277+
iterOpts := manager.IteratorOptions{Namespace: req.Namespace}
278278

279279
if !req.Watch {
280280
listOp := OpListClusterInstanceImagePullSecrets()
@@ -289,26 +289,26 @@ func (s *Service) handleListInstanceImagePullSecrets(w http.ResponseWriter, r *h
289289
return
290290
}
291291

292-
watchOp := OpHandleClusterInstanceImagePullSecret(req.Organization)
292+
watchOp := OpHandleClusterInstanceImagePullSecret(req.Namespace)
293293
s.streamResponse(w, r, req.Clusters, gvk, watchOp.Handle)
294294
}
295295

296296
// handleListInstanceSSHPublicKeys handles the list instance SSH public keys request.
297297
//
298-
// GET /instancesshpublickeys?cluster=cluster1&cluster=cluster2[&organization=foo&watch=true]
298+
// GET /instancesshpublickeys?cluster=cluster1&cluster=cluster2[&namespace=foo&watch=true]
299299
func (s *Service) handleListInstanceSSHPublicKeys(w http.ResponseWriter, r *http.Request) {
300300
ctx := r.Context()
301301
logger := s.Logger.WithValues("method", r.Method, "path", r.URL.Path).V(2)
302302

303303
var req struct {
304-
Clusters []string `query:"cluster"`
305-
Organization string `query:"organization"`
306-
Watch bool `query:"watch"`
304+
Clusters []string `query:"cluster"`
305+
Namespace string `query:"namespace"`
306+
Watch bool `query:"watch"`
307307
}
308308
_ = httpx.BindWith(r, &req, httpx.BindQuery)
309309

310310
gvk := worker.SchemeGroupVersionKind("InstanceSSHPublicKey")
311-
iterOpts := manager.IteratorOptions{Namespace: req.Organization}
311+
iterOpts := manager.IteratorOptions{Namespace: req.Namespace}
312312

313313
if !req.Watch {
314314
listOp := OpListClusterInstanceSSHPublicKeys()
@@ -323,7 +323,7 @@ func (s *Service) handleListInstanceSSHPublicKeys(w http.ResponseWriter, r *http
323323
return
324324
}
325325

326-
watchOp := OpHandleClusterInstanceSSHPublicKey(req.Organization)
326+
watchOp := OpHandleClusterInstanceSSHPublicKey(req.Namespace)
327327
s.streamResponse(w, r, req.Clusters, gvk, watchOp.Handle)
328328
}
329329

0 commit comments

Comments
 (0)