Skip to content

Commit 2584d99

Browse files
tamilmani1989ofiliz
authored andcommitted
Exposed IPAM API path and structures as public
* Modified files which are using those variables
1 parent 7c8570f commit 2584d99

File tree

3 files changed

+71
-71
lines changed

3 files changed

+71
-71
lines changed

cnm/ipam/api.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@ const (
88
EndpointType = "IpamDriver"
99

1010
// Libnetwork IPAM plugin remote API paths
11-
getCapabilitiesPath = "/IpamDriver.GetCapabilities"
12-
getAddressSpacesPath = "/IpamDriver.GetDefaultAddressSpaces"
13-
requestPoolPath = "/IpamDriver.RequestPool"
14-
releasePoolPath = "/IpamDriver.ReleasePool"
15-
getPoolInfoPath = "/IpamDriver.GetPoolInfo"
16-
requestAddressPath = "/IpamDriver.RequestAddress"
17-
releaseAddressPath = "/IpamDriver.ReleaseAddress"
11+
GetCapabilitiesPath = "/IpamDriver.GetCapabilities"
12+
GetAddressSpacesPath = "/IpamDriver.GetDefaultAddressSpaces"
13+
RequestPoolPath = "/IpamDriver.RequestPool"
14+
ReleasePoolPath = "/IpamDriver.ReleasePool"
15+
GetPoolInfoPath = "/IpamDriver.GetPoolInfo"
16+
RequestAddressPath = "/IpamDriver.RequestAddress"
17+
ReleaseAddressPath = "/IpamDriver.ReleaseAddress"
1818

1919
// Libnetwork IPAM plugin options
2020
OptAddressType = "RequestAddressType"
2121
OptAddressTypeGateway = "com.docker.network.gateway"
2222
)
2323

2424
// Request sent by libnetwork when querying plugin capabilities.
25-
type getCapabilitiesRequest struct {
25+
type GetCapabilitiesRequest struct {
2626
}
2727

2828
// Response sent by plugin when registering its capabilities with libnetwork.
29-
type getCapabilitiesResponse struct {
29+
type GetCapabilitiesResponse struct {
3030
Err string
3131
RequiresMACAddress bool
3232
RequiresRequestReplay bool
3333
}
3434

3535
// Request sent by libnetwork when querying the default address space names.
36-
type getDefaultAddressSpacesRequest struct {
36+
type GetDefaultAddressSpacesRequest struct {
3737
}
3838

3939
// Response sent by plugin when returning the default address space names.
40-
type getDefaultAddressSpacesResponse struct {
40+
type GetDefaultAddressSpacesResponse struct {
4141
Err string
4242
LocalDefaultAddressSpace string
4343
GlobalDefaultAddressSpace string
4444
}
4545

4646
// Request sent by libnetwork when acquiring a reference to an address pool.
47-
type requestPoolRequest struct {
47+
type RequestPoolRequest struct {
4848
AddressSpace string
4949
Pool string
5050
SubPool string
@@ -53,58 +53,58 @@ type requestPoolRequest struct {
5353
}
5454

5555
// Response sent by plugin when an address pool is successfully referenced.
56-
type requestPoolResponse struct {
56+
type RequestPoolResponse struct {
5757
Err string
5858
PoolID string
5959
Pool string
6060
Data map[string]string
6161
}
6262

6363
// Request sent by libnetwork when releasing a previously registered address pool.
64-
type releasePoolRequest struct {
64+
type ReleasePoolRequest struct {
6565
PoolID string
6666
}
6767

6868
// Response sent by plugin when an address pool is successfully released.
69-
type releasePoolResponse struct {
69+
type ReleasePoolResponse struct {
7070
Err string
7171
}
7272

7373
// Request sent when querying address pool information.
74-
type getPoolInfoRequest struct {
74+
type GetPoolInfoRequest struct {
7575
PoolID string
7676
}
7777

7878
// Response sent by plugin when returning address pool information.
79-
type getPoolInfoResponse struct {
79+
type GetPoolInfoResponse struct {
8080
Err string
8181
Capacity int
8282
Available int
8383
UnhealthyAddresses []string
8484
}
8585

8686
// Request sent by libnetwork when reserving an address from a pool.
87-
type requestAddressRequest struct {
87+
type RequestAddressRequest struct {
8888
PoolID string
8989
Address string
9090
Options map[string]string
9191
}
9292

9393
// Response sent by plugin when an address is successfully reserved.
94-
type requestAddressResponse struct {
94+
type RequestAddressResponse struct {
9595
Err string
9696
Address string
9797
Data map[string]string
9898
}
9999

100100
// Request sent by libnetwork when releasing an address back to the pool.
101-
type releaseAddressRequest struct {
101+
type ReleaseAddressRequest struct {
102102
PoolID string
103103
Address string
104104
Options map[string]string
105105
}
106106

107107
// Response sent by plugin when an address is successfully released.
108-
type releaseAddressResponse struct {
108+
type ReleaseAddressResponse struct {
109109
Err string
110110
}

cnm/ipam/ipam.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func (plugin *ipamPlugin) Start(config *common.PluginConfig) error {
7272
// Add protocol handlers.
7373
listener := plugin.Listener
7474
listener.AddEndpoint(plugin.EndpointType)
75-
listener.AddHandler(getCapabilitiesPath, plugin.getCapabilities)
76-
listener.AddHandler(getAddressSpacesPath, plugin.getDefaultAddressSpaces)
77-
listener.AddHandler(requestPoolPath, plugin.requestPool)
78-
listener.AddHandler(releasePoolPath, plugin.releasePool)
79-
listener.AddHandler(getPoolInfoPath, plugin.getPoolInfo)
80-
listener.AddHandler(requestAddressPath, plugin.requestAddress)
81-
listener.AddHandler(releaseAddressPath, plugin.releaseAddress)
75+
listener.AddHandler(GetCapabilitiesPath, plugin.getCapabilities)
76+
listener.AddHandler(GetAddressSpacesPath, plugin.getDefaultAddressSpaces)
77+
listener.AddHandler(RequestPoolPath, plugin.requestPool)
78+
listener.AddHandler(ReleasePoolPath, plugin.releasePool)
79+
listener.AddHandler(GetPoolInfoPath, plugin.getPoolInfo)
80+
listener.AddHandler(RequestAddressPath, plugin.requestAddress)
81+
listener.AddHandler(ReleaseAddressPath, plugin.releaseAddress)
8282

8383
// Plugin is ready to be discovered.
8484
err = plugin.EnableDiscovery()
@@ -107,11 +107,11 @@ func (plugin *ipamPlugin) Stop() {
107107

108108
// Handles GetCapabilities requests.
109109
func (plugin *ipamPlugin) getCapabilities(w http.ResponseWriter, r *http.Request) {
110-
var req getCapabilitiesRequest
110+
var req GetCapabilitiesRequest
111111

112112
log.Request(plugin.Name, &req, nil)
113113

114-
resp := getCapabilitiesResponse{
114+
resp := GetCapabilitiesResponse{
115115
RequiresMACAddress: requiresMACAddress,
116116
RequiresRequestReplay: requiresRequestReplay,
117117
}
@@ -123,8 +123,8 @@ func (plugin *ipamPlugin) getCapabilities(w http.ResponseWriter, r *http.Request
123123

124124
// Handles GetDefaultAddressSpaces requests.
125125
func (plugin *ipamPlugin) getDefaultAddressSpaces(w http.ResponseWriter, r *http.Request) {
126-
var req getDefaultAddressSpacesRequest
127-
var resp getDefaultAddressSpacesResponse
126+
var req GetDefaultAddressSpacesRequest
127+
var resp GetDefaultAddressSpacesResponse
128128

129129
log.Request(plugin.Name, &req, nil)
130130

@@ -140,7 +140,7 @@ func (plugin *ipamPlugin) getDefaultAddressSpaces(w http.ResponseWriter, r *http
140140

141141
// Handles RequestPool requests.
142142
func (plugin *ipamPlugin) requestPool(w http.ResponseWriter, r *http.Request) {
143-
var req requestPoolRequest
143+
var req RequestPoolRequest
144144

145145
// Decode request.
146146
err := plugin.Listener.Decode(w, r, &req)
@@ -159,7 +159,7 @@ func (plugin *ipamPlugin) requestPool(w http.ResponseWriter, r *http.Request) {
159159
// Encode response.
160160
data := make(map[string]string)
161161
poolId = ipam.NewAddressPoolId(req.AddressSpace, poolId, "").String()
162-
resp := requestPoolResponse{PoolID: poolId, Pool: subnet, Data: data}
162+
resp := RequestPoolResponse{PoolID: poolId, Pool: subnet, Data: data}
163163

164164
err = plugin.Listener.Encode(w, &resp)
165165

@@ -168,7 +168,7 @@ func (plugin *ipamPlugin) requestPool(w http.ResponseWriter, r *http.Request) {
168168

169169
// Handles ReleasePool requests.
170170
func (plugin *ipamPlugin) releasePool(w http.ResponseWriter, r *http.Request) {
171-
var req releasePoolRequest
171+
var req ReleasePoolRequest
172172

173173
// Decode request.
174174
err := plugin.Listener.Decode(w, r, &req)
@@ -191,7 +191,7 @@ func (plugin *ipamPlugin) releasePool(w http.ResponseWriter, r *http.Request) {
191191
}
192192

193193
// Encode response.
194-
resp := releasePoolResponse{}
194+
resp := ReleasePoolResponse{}
195195

196196
err = plugin.Listener.Encode(w, &resp)
197197

@@ -200,7 +200,7 @@ func (plugin *ipamPlugin) releasePool(w http.ResponseWriter, r *http.Request) {
200200

201201
// Handles GetPoolInfo requests.
202202
func (plugin *ipamPlugin) getPoolInfo(w http.ResponseWriter, r *http.Request) {
203-
var req getPoolInfoRequest
203+
var req GetPoolInfoRequest
204204

205205
// Decode request.
206206
err := plugin.Listener.Decode(w, r, &req)
@@ -223,7 +223,7 @@ func (plugin *ipamPlugin) getPoolInfo(w http.ResponseWriter, r *http.Request) {
223223
}
224224

225225
// Encode response.
226-
resp := getPoolInfoResponse{
226+
resp := GetPoolInfoResponse{
227227
Capacity: apInfo.Capacity,
228228
Available: apInfo.Available,
229229
}
@@ -239,7 +239,7 @@ func (plugin *ipamPlugin) getPoolInfo(w http.ResponseWriter, r *http.Request) {
239239

240240
// Handles RequestAddress requests.
241241
func (plugin *ipamPlugin) requestAddress(w http.ResponseWriter, r *http.Request) {
242-
var req requestAddressRequest
242+
var req RequestAddressRequest
243243

244244
// Decode request.
245245
err := plugin.Listener.Decode(w, r, &req)
@@ -271,7 +271,7 @@ func (plugin *ipamPlugin) requestAddress(w http.ResponseWriter, r *http.Request)
271271

272272
// Encode response.
273273
data := make(map[string]string)
274-
resp := requestAddressResponse{Address: addr, Data: data}
274+
resp := RequestAddressResponse{Address: addr, Data: data}
275275

276276
err = plugin.Listener.Encode(w, &resp)
277277

@@ -280,7 +280,7 @@ func (plugin *ipamPlugin) requestAddress(w http.ResponseWriter, r *http.Request)
280280

281281
// Handles ReleaseAddress requests.
282282
func (plugin *ipamPlugin) releaseAddress(w http.ResponseWriter, r *http.Request) {
283-
var req releaseAddressRequest
283+
var req ReleaseAddressRequest
284284

285285
// Decode request.
286286
err := plugin.Listener.Decode(w, r, &req)
@@ -303,7 +303,7 @@ func (plugin *ipamPlugin) releaseAddress(w http.ResponseWriter, r *http.Request)
303303
}
304304

305305
// Encode response.
306-
resp := releaseAddressResponse{}
306+
resp := ReleaseAddressResponse{}
307307

308308
err = plugin.Listener.Encode(w, &resp)
309309

0 commit comments

Comments
 (0)