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
This repository was archived by the owner on Nov 16, 2020. It is now read-only.

Commit5b13c41

Browse files
authored
Remove more dead code (#786)
Remove calls to ParseTags which retrieved application from tags.Application concept has been removed previously.Also convert local only tests to always run using mocks.
1 parenta793116 commit5b13c41

File tree

14 files changed

+123
-452
lines changed

14 files changed

+123
-452
lines changed

‎pkg/api-manager/handlers.go‎

Lines changed: 6 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -168,20 +168,10 @@ func (h *Handlers) deleteAPI(params endpoint.DeleteAPIParams, principal interfac
168168

169169
name:=params.API
170170

171-
varerrerror
172-
173171
opts:= entitystore.Options{
174172
Filter:entitystore.FilterExists(),
175173
}
176-
opts.Filter,err=utils.ParseTags(opts.Filter,params.Tags)
177-
iferr!=nil {
178-
log.Errorf(err.Error())
179-
returnendpoint.NewUpdateAPIBadRequest().WithPayload(
180-
&v1.Error{
181-
Code:http.StatusBadRequest,
182-
Message:utils.ErrorMsgBadRequest("API",name,err),
183-
})
184-
}
174+
185175
vareAPI
186176
iferr:=h.Store.Get(ctx,params.XDispatchOrg,name,opts,&e);err!=nil {
187177
log.Errorf("store error when getting api: %+v",err)
@@ -211,22 +201,14 @@ func (h *Handlers) getAPI(params endpoint.GetAPIParams, principal interface{}) m
211201
span,ctx:=trace.Trace(params.HTTPRequest.Context(),"")
212202
deferspan.Finish()
213203
log.Debugf("Trying to get api with params: %+v",params)
214-
varerrerror
204+
215205
opts:= entitystore.Options{
216206
Filter:entitystore.FilterExists(),
217207
}
218-
opts.Filter,err=utils.ParseTags(opts.Filter,params.Tags)
219-
iferr!=nil {
220-
log.Errorf(err.Error())
221-
returnendpoint.NewUpdateAPIBadRequest().WithPayload(
222-
&v1.Error{
223-
Code:http.StatusBadRequest,
224-
Message:utils.ErrorMsgBadRequest("API",params.API,err),
225-
})
226-
}
208+
227209
vareAPI
228210
log.Debugln("Getting from store")
229-
err=h.Store.Get(ctx,params.XDispatchOrg,params.API,opts,&e)
211+
err:=h.Store.Get(ctx,params.XDispatchOrg,params.API,opts,&e)
230212
iferr!=nil {
231213
log.Errorf("store error when getting api: %+v",err)
232214
returnendpoint.NewGetAPINotFound().WithPayload(
@@ -245,21 +227,11 @@ func (h *Handlers) getAPIs(params endpoint.GetApisParams, principal interface{})
245227

246228
varapis []*API
247229

248-
varerrerror
249230
opts:= entitystore.Options{
250231
Filter:entitystore.FilterExists(),
251232
}
252-
opts.Filter,err=utils.ParseTags(opts.Filter,params.Tags)
253-
iferr!=nil {
254-
log.Errorf(err.Error())
255-
returnendpoint.NewGetAPIBadRequest().WithPayload(
256-
&v1.Error{
257-
Code:http.StatusBadRequest,
258-
Message:swag.String(err.Error()),
259-
})
260-
}
261233

262-
err=h.Store.List(ctx,params.XDispatchOrg,opts,&apis)
234+
err:=h.Store.List(ctx,params.XDispatchOrg,opts,&apis)
263235
iferr!=nil {
264236
log.Errorf("store error when listing apis: %+v",err)
265237
returnendpoint.NewGetApisDefault(http.StatusInternalServerError).WithPayload(
@@ -287,15 +259,7 @@ func (h *Handlers) updateAPI(params endpoint.UpdateAPIParams, principal interfac
287259
opts:= entitystore.Options{
288260
Filter:entitystore.FilterExists(),
289261
}
290-
opts.Filter,err=utils.ParseTags(opts.Filter,params.Tags)
291-
iferr!=nil {
292-
log.Errorf(err.Error())
293-
returnendpoint.NewUpdateAPIBadRequest().WithPayload(
294-
&v1.Error{
295-
Code:http.StatusBadRequest,
296-
Message:swag.String(err.Error()),
297-
})
298-
}
262+
299263
vareAPI
300264
err=h.Store.Get(ctx,params.XDispatchOrg,name,opts,&e)
301265
log.Infof("Got api: %+v",e)

‎pkg/entity-store/store_test.go‎

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/stretchr/testify/assert"
1818
"github.com/stretchr/testify/require"
19-
"github.com/vmware/dispatch/pkg/testing/dev"
2019
)
2120

2221
var (
@@ -56,24 +55,6 @@ func (e *otherEntity) getOther() string {
5655
returne.Other
5756
}
5857

59-
funcTestPostgresEntityStore(t*testing.T) {
60-
61-
dev.EnsureLocal(t)
62-
63-
es,err:=NewFromBackend(postgresConfig)
64-
assert.NoError(t,err,"Cannot connect to postgres DB")
65-
66-
testGet(t,es)
67-
testAdd(t,es)
68-
testPut(t,es)
69-
testList(t,es)
70-
testListWithFilter(t,es)
71-
testListWithFilterOnTags(t,es)
72-
testDelete(t,es)
73-
testInvalidNames(t,es)
74-
testMixedTypes(t,es)
75-
}
76-
7758
funcTestLibkvEntityStore(t*testing.T) {
7859

7960
file,err:=ioutil.TempFile(os.TempDir(),"test")

‎pkg/event-manager/drivers/http_handlers.go‎

Lines changed: 13 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,7 @@ func (h *Handlers) getDriver(params driverapi.GetDriverParams, principal interfa
113113

114114
d:=&entities.Driver{}
115115

116-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
117-
iferr!=nil {
118-
log.Errorf(err.Error())
119-
returndriverapi.NewDeleteDriverBadRequest().WithPayload(
120-
&v1.Error{
121-
Code:http.StatusBadRequest,
122-
Message:utils.ErrorMsgBadRequest("event driver",params.DriverName,err),
123-
})
124-
}
125-
opts:= entitystore.Options{Filter:filter}
126-
127-
err=h.store.Get(ctx,params.XDispatchOrg,params.DriverName,opts,d)
116+
err:=h.store.Get(ctx,params.XDispatchOrg,params.DriverName, entitystore.Options{},d)
128117
iferr!=nil {
129118
log.Warnf("Received GET for non-existent driver %s",params.DriverName)
130119
log.Debugf("store error when getting driver: %+v",err)
@@ -143,19 +132,8 @@ func (h *Handlers) getDrivers(params driverapi.GetDriversParams, principal inter
143132

144133
vardrivers []*entities.Driver
145134

146-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
147-
iferr!=nil {
148-
log.Errorf(err.Error())
149-
returndriverapi.NewDeleteDriverBadRequest().WithPayload(
150-
&v1.Error{
151-
Code:http.StatusBadRequest,
152-
Message:swag.String(err.Error()),
153-
})
154-
}
155-
opts:= entitystore.Options{Filter:filter}
156-
157135
// delete filter
158-
err=h.store.List(ctx,params.XDispatchOrg,opts,&drivers)
136+
err:=h.store.List(ctx,params.XDispatchOrg,entitystore.Options{},&drivers)
159137
iferr!=nil {
160138
log.Errorf("store error when listing drivers: %+v",err)
161139
returndriverapi.NewGetDriverDefault(http.StatusInternalServerError).WithPayload(
@@ -177,20 +155,9 @@ func (h *Handlers) updateDriver(params driverapi.UpdateDriverParams, principal i
177155

178156
name:=params.DriverName
179157

180-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
181-
iferr!=nil {
182-
log.Errorf(err.Error())
183-
returndriverapi.NewUpdateDriverBadRequest().WithPayload(
184-
&v1.Error{
185-
Code:http.StatusBadRequest,
186-
Message:utils.ErrorMsgBadRequest("event driver",name,err),
187-
})
188-
}
189-
opts:= entitystore.Options{Filter:filter}
190-
191158
d:=&entities.Driver{}
192159

193-
iferr=h.store.Get(ctx,params.XDispatchOrg,name,opts,d);err!=nil {
160+
iferr:=h.store.Get(ctx,params.XDispatchOrg,name,entitystore.Options{},d);err!=nil {
194161
log.Errorf("store error when getting driver: %+v",err)
195162
returndriverapi.NewUpdateDriverNotFound().WithPayload(
196163
&v1.Error{
@@ -200,7 +167,7 @@ func (h *Handlers) updateDriver(params driverapi.UpdateDriverParams, principal i
200167
}
201168
d.FromModel(params.Body,d.OrganizationID)
202169
d.Status=entitystore.StatusUPDATING
203-
if_,err=h.store.Update(ctx,d.Revision,d);err!=nil {
170+
if_,err:=h.store.Update(ctx,d.Revision,d);err!=nil {
204171
log.Errorf("store error when updating the event driver %s: %+v",d.Name,err)
205172
returndriverapi.NewUpdateDriverDefault(500).WithPayload(
206173
&v1.Error{
@@ -224,20 +191,9 @@ func (h *Handlers) deleteDriver(params driverapi.DeleteDriverParams, principal i
224191

225192
name:=params.DriverName
226193

227-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
228-
iferr!=nil {
229-
log.Errorf(err.Error())
230-
returndriverapi.NewDeleteDriverBadRequest().WithPayload(
231-
&v1.Error{
232-
Code:http.StatusBadRequest,
233-
Message:utils.ErrorMsgBadRequest("event driver",name,err),
234-
})
235-
}
236-
opts:= entitystore.Options{Filter:filter}
237-
238194
d:=&entities.Driver{}
239195

240-
iferr=h.store.Get(ctx,params.XDispatchOrg,name,opts,d);err!=nil {
196+
iferr:=h.store.Get(ctx,params.XDispatchOrg,name,entitystore.Options{},d);err!=nil {
241197
log.Errorf("store error when getting driver: %+v",err)
242198
returndriverapi.NewDeleteDriverNotFound().WithPayload(
243199
&v1.Error{
@@ -247,7 +203,7 @@ func (h *Handlers) deleteDriver(params driverapi.DeleteDriverParams, principal i
247203
}
248204
d.Status=entitystore.StatusDELETING
249205
d.SetDelete(true)
250-
if_,err=h.store.Update(ctx,d.Revision,d);err!=nil {
206+
if_,err:=h.store.Update(ctx,d.Revision,d);err!=nil {
251207
log.Errorf("store error when deleting the event driver %s: %+v",d.Name,err)
252208
returndriverapi.NewDeleteDriverDefault(500).WithPayload(&v1.Error{
253209
Code:http.StatusInternalServerError,
@@ -263,13 +219,9 @@ func (h *Handlers) deleteDriver(params driverapi.DeleteDriverParams, principal i
263219
}
264220

265221
func (h*Handlers)getDT(ctx context.Context,orgIDstring,driverTypeNamestring)*entities.DriverType {
266-
opts:= entitystore.Options{
267-
Filter:entitystore.FilterEverything(),
268-
}
269-
270222
t:= entities.DriverType{}
271223

272-
err:=h.store.Get(ctx,orgID,driverTypeName,opts,&t)
224+
err:=h.store.Get(ctx,orgID,driverTypeName,entitystore.Options{},&t)
273225
iferr!=nil {
274226
log.Debugf("store error when getting driver type %s: %+v",driverTypeName,err)
275227
returnnil
@@ -315,18 +267,7 @@ func (h *Handlers) getDriverType(params driverapi.GetDriverTypeParams, principal
315267

316268
dt:=&entities.DriverType{}
317269

318-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
319-
iferr!=nil {
320-
log.Errorf(err.Error())
321-
returndriverapi.NewGetDriverTypeBadRequest().WithPayload(
322-
&v1.Error{
323-
Code:http.StatusBadRequest,
324-
Message:swag.String(err.Error()),
325-
})
326-
}
327-
opts:= entitystore.Options{Filter:filter}
328-
329-
iferr=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName,opts,dt);err!=nil {
270+
iferr:=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName, entitystore.Options{},dt);err!=nil {
330271
log.Warnf("Received GET for non-existent driver type %s",params.DriverTypeName)
331272
log.Debugf("store error when getting driver type: %+v",err)
332273
returndriverapi.NewGetDriverNotFound().WithPayload(
@@ -344,19 +285,8 @@ func (h *Handlers) getDriverTypes(params driverapi.GetDriverTypesParams, princip
344285

345286
vardriverTypes []*entities.DriverType
346287

347-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
348-
iferr!=nil {
349-
log.Errorf(err.Error())
350-
returndriverapi.NewGetDriverTypeBadRequest().WithPayload(
351-
&v1.Error{
352-
Code:http.StatusBadRequest,
353-
Message:swag.String(err.Error()),
354-
})
355-
}
356-
opts:= entitystore.Options{Filter:filter}
357-
358288
// delete filter
359-
err=h.store.List(ctx,params.XDispatchOrg,opts,&driverTypes)
289+
err:=h.store.List(ctx,params.XDispatchOrg,entitystore.Options{},&driverTypes)
360290
iferr!=nil {
361291
log.Errorf("store error when listing driver types: %+v",err)
362292
returndriverapi.NewGetDriverTypesDefault(http.StatusInternalServerError).WithPayload(
@@ -377,20 +307,9 @@ func (h *Handlers) updateDriverType(params driverapi.UpdateDriverTypeParams, pri
377307
span,ctx:=trace.Trace(params.HTTPRequest.Context(),"")
378308
deferspan.Finish()
379309

380-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
381-
iferr!=nil {
382-
log.Errorf(err.Error())
383-
returndriverapi.NewUpdateDriverTypeBadRequest().WithPayload(
384-
&v1.Error{
385-
Code:http.StatusBadRequest,
386-
Message:swag.String(err.Error()),
387-
})
388-
}
389-
opts:= entitystore.Options{Filter:filter}
390-
391310
dt:=&entities.DriverType{}
392311

393-
iferr=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName,opts,dt);err!=nil {
312+
iferr:=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName,entitystore.Options{},dt);err!=nil {
394313
log.Errorf("store error when getting driver type: %+v",err)
395314
returndriverapi.NewUpdateDriverTypeNotFound().WithPayload(
396315
&v1.Error{
@@ -401,7 +320,7 @@ func (h *Handlers) updateDriverType(params driverapi.UpdateDriverTypeParams, pri
401320

402321
dt.FromModel(params.Body,params.XDispatchOrg)
403322

404-
if_,err=h.store.Update(ctx,dt.Revision,dt);err!=nil {
323+
if_,err:=h.store.Update(ctx,dt.Revision,dt);err!=nil {
405324
log.Errorf("store error when updating the event driver type %s: %+v",dt.Name,err)
406325
returndriverapi.NewUpdateDriverTypeDefault(500).WithPayload(
407326
&v1.Error{
@@ -417,28 +336,17 @@ func (h *Handlers) deleteDriverType(params driverapi.DeleteDriverTypeParams, pri
417336
span,ctx:=trace.Trace(params.HTTPRequest.Context(),"")
418337
deferspan.Finish()
419338

420-
filter,err:=utils.ParseTags(entitystore.FilterEverything(),params.Tags)
421-
iferr!=nil {
422-
log.Errorf(err.Error())
423-
returndriverapi.NewDeleteDriverTypeBadRequest().WithPayload(
424-
&v1.Error{
425-
Code:http.StatusBadRequest,
426-
Message:swag.String(err.Error()),
427-
})
428-
}
429-
opts:= entitystore.Options{Filter:filter}
430-
431339
dt:=&entities.DriverType{}
432340

433-
iferr=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName,opts,dt);err!=nil {
341+
iferr:=h.store.Get(ctx,params.XDispatchOrg,params.DriverTypeName,entitystore.Options{},dt);err!=nil {
434342
log.Errorf("store error when getting driver type: %+v",err)
435343
returndriverapi.NewDeleteDriverTypeNotFound().WithPayload(
436344
&v1.Error{
437345
Code:http.StatusNotFound,
438346
Message:utils.ErrorMsgNotFound("event driver type",params.DriverTypeName),
439347
})
440348
}
441-
iferr=h.store.Delete(ctx,params.XDispatchOrg,dt.Name,dt);err!=nil {
349+
iferr:=h.store.Delete(ctx,params.XDispatchOrg,dt.Name,dt);err!=nil {
442350
log.Errorf("store error when deleting the event driver type %s: %+v",dt.Name,err)
443351
returndriverapi.NewDeleteDriverTypeDefault(500).WithPayload(&v1.Error{
444352
Code:http.StatusInternalServerError,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp