Skip to content

Commit 101edc2

Browse files
committed
remove client dependency on modeldb
1 parent fbf8dca commit 101edc2

File tree

1 file changed

+39
-35
lines changed

1 file changed

+39
-35
lines changed

client/contivModelClient.go

+39-35
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import (
1111
"io/ioutil"
1212
"net/http"
1313

14-
"github.com/contiv/objdb/modeldb"
15-
1614
log "github.com/Sirupsen/logrus"
1715
)
1816

17+
// Link is a one way relattion between two objects
18+
type Link struct {
19+
ObjType string `json:"type,omitempty"`
20+
ObjKey string `json:"key,omitempty"`
21+
}
22+
1923
func httpGet(url string, jdata interface{}) error {
2024

2125
r, err := http.Get(url)
@@ -157,12 +161,12 @@ type AppProfile struct {
157161
}
158162

159163
type AppProfileLinkSets struct {
160-
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
164+
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
161165
}
162166

163167
type AppProfileLinks struct {
164-
Network modeldb.Link `json:"Network,omitempty"`
165-
Tenant modeldb.Link `json:"Tenant,omitempty"`
168+
Network Link `json:"Network,omitempty"`
169+
Tenant Link `json:"Tenant,omitempty"`
166170
}
167171

168172
type EndpointGroup struct {
@@ -181,14 +185,14 @@ type EndpointGroup struct {
181185
}
182186

183187
type EndpointGroupLinkSets struct {
184-
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
185-
Services map[string]modeldb.Link `json:"Services,omitempty"`
188+
Policies map[string]Link `json:"Policies,omitempty"`
189+
Services map[string]Link `json:"Services,omitempty"`
186190
}
187191

188192
type EndpointGroupLinks struct {
189-
AppProfile modeldb.Link `json:"AppProfile,omitempty"`
190-
Network modeldb.Link `json:"Network,omitempty"`
191-
Tenant modeldb.Link `json:"Tenant,omitempty"`
193+
AppProfile Link `json:"AppProfile,omitempty"`
194+
Network Link `json:"Network,omitempty"`
195+
Tenant Link `json:"Tenant,omitempty"`
192196
}
193197

194198
type Global struct {
@@ -231,13 +235,13 @@ type Network struct {
231235
}
232236

233237
type NetworkLinkSets struct {
234-
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
235-
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
236-
Services map[string]modeldb.Link `json:"Services,omitempty"`
238+
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
239+
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
240+
Services map[string]Link `json:"Services,omitempty"`
237241
}
238242

239243
type NetworkLinks struct {
240-
Tenant modeldb.Link `json:"Tenant,omitempty"`
244+
Tenant Link `json:"Tenant,omitempty"`
241245
}
242246

243247
type Policy struct {
@@ -253,12 +257,12 @@ type Policy struct {
253257
}
254258

255259
type PolicyLinkSets struct {
256-
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
257-
Rules map[string]modeldb.Link `json:"Rules,omitempty"`
260+
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
261+
Rules map[string]Link `json:"Rules,omitempty"`
258262
}
259263

260264
type PolicyLinks struct {
261-
Tenant modeldb.Link `json:"Tenant,omitempty"`
265+
Tenant Link `json:"Tenant,omitempty"`
262266
}
263267

264268
type Rule struct {
@@ -285,7 +289,7 @@ type Rule struct {
285289
}
286290

287291
type RuleLinkSets struct {
288-
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
292+
Policies map[string]Link `json:"Policies,omitempty"`
289293
}
290294

291295
type Service struct {
@@ -311,14 +315,14 @@ type Service struct {
311315
}
312316

313317
type ServiceLinkSets struct {
314-
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
315-
Instances map[string]modeldb.Link `json:"Instances,omitempty"`
316-
Networks map[string]modeldb.Link `json:"Networks,omitempty"`
318+
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
319+
Instances map[string]Link `json:"Instances,omitempty"`
320+
Networks map[string]Link `json:"Networks,omitempty"`
317321
}
318322

319323
type ServiceLinks struct {
320-
App modeldb.Link `json:"App,omitempty"`
321-
VolumeProfile modeldb.Link `json:"VolumeProfile,omitempty"`
324+
App Link `json:"App,omitempty"`
325+
VolumeProfile Link `json:"VolumeProfile,omitempty"`
322326
}
323327

324328
type ServiceInstance struct {
@@ -337,11 +341,11 @@ type ServiceInstance struct {
337341
}
338342

339343
type ServiceInstanceLinkSets struct {
340-
Volumes map[string]modeldb.Link `json:"Volumes,omitempty"`
344+
Volumes map[string]Link `json:"Volumes,omitempty"`
341345
}
342346

343347
type ServiceInstanceLinks struct {
344-
Service modeldb.Link `json:"Service,omitempty"`
348+
Service Link `json:"Service,omitempty"`
345349
}
346350

347351
type Tenant struct {
@@ -356,12 +360,12 @@ type Tenant struct {
356360
}
357361

358362
type TenantLinkSets struct {
359-
AppProfiles map[string]modeldb.Link `json:"AppProfiles,omitempty"`
360-
EndpointGroups map[string]modeldb.Link `json:"EndpointGroups,omitempty"`
361-
Networks map[string]modeldb.Link `json:"Networks,omitempty"`
362-
Policies map[string]modeldb.Link `json:"Policies,omitempty"`
363-
VolumeProfiles map[string]modeldb.Link `json:"VolumeProfiles,omitempty"`
364-
Volumes map[string]modeldb.Link `json:"Volumes,omitempty"`
363+
AppProfiles map[string]Link `json:"AppProfiles,omitempty"`
364+
EndpointGroups map[string]Link `json:"EndpointGroups,omitempty"`
365+
Networks map[string]Link `json:"Networks,omitempty"`
366+
Policies map[string]Link `json:"Policies,omitempty"`
367+
VolumeProfiles map[string]Link `json:"VolumeProfiles,omitempty"`
368+
Volumes map[string]Link `json:"Volumes,omitempty"`
365369
}
366370

367371
type Volume struct {
@@ -381,11 +385,11 @@ type Volume struct {
381385
}
382386

383387
type VolumeLinkSets struct {
384-
ServiceInstances map[string]modeldb.Link `json:"ServiceInstances,omitempty"`
388+
ServiceInstances map[string]Link `json:"ServiceInstances,omitempty"`
385389
}
386390

387391
type VolumeLinks struct {
388-
Tenant modeldb.Link `json:"Tenant,omitempty"`
392+
Tenant Link `json:"Tenant,omitempty"`
389393
}
390394

391395
type VolumeProfile struct {
@@ -405,11 +409,11 @@ type VolumeProfile struct {
405409
}
406410

407411
type VolumeProfileLinkSets struct {
408-
Services map[string]modeldb.Link `json:"Services,omitempty"`
412+
Services map[string]Link `json:"Services,omitempty"`
409413
}
410414

411415
type VolumeProfileLinks struct {
412-
Tenant modeldb.Link `json:"Tenant,omitempty"`
416+
Tenant Link `json:"Tenant,omitempty"`
413417
}
414418

415419
// AppProfilePost posts the appProfile object

0 commit comments

Comments
 (0)