Skip to content

Commit 5a6c484

Browse files
committed
Minor changes for the review comments
GetIPAddressStateResponse kept as original struct, and added GetIPAddressStatusResponse Minor changes to reflect GetIPAddressStatusResponse
1 parent 199980c commit 5a6c484

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

cns/NetworkContainerContract.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ type GetIPAddressesRequest struct {
238238

239239
// GetIPAddressStateResponse is used in CNS IPAM mode as a response to get IP address state
240240
type GetIPAddressStateResponse struct {
241+
IPAddresses []IPAddressState
242+
Response Response
243+
}
244+
245+
// GetIPAddressStatusResponse is used in CNS IPAM mode as a response to get IP address, state and Pod info
246+
type GetIPAddressStatusResponse struct {
241247
IPConfigurationStatus[] IPConfigurationStatus
242248
Response Response
243249
}

cns/cnsclient/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,6 @@ func printIPAddresses(addrSlice []cns.IPConfigurationStatus) {
9393
})
9494

9595
for _, addr := range addrSlice {
96-
fmt.Printf("%+v\n", addr)
96+
cns.IPConfigurationStatus.String(addr)
9797
}
9898
}

cns/cnsclient/cnsclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (cnsClient *CNSClient) ReleaseIPAddress(orchestratorContext []byte) error {
321321
// usage GetIPAddressesWithStates(cns.Available, cns.Allocated)
322322
func (cnsClient *CNSClient) GetIPAddressesMatchingStates(StateFilter ...string) ([]cns.IPConfigurationStatus, error) {
323323
var (
324-
resp cns.GetIPAddressStateResponse
324+
resp cns.GetIPAddressStatusResponse
325325
err error
326326
res *http.Response
327327
body bytes.Buffer

cns/cnsclient/cnsclient_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,7 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
233233
t.Fatalf("Expected to not fail when releasing IP reservation found with context: %+v", err)
234234
}
235235

236-
ipaddresses, err := cnsClient.GetIPAddressesMatchingStates("Available")
237-
fmt.Println(ipaddresses)
236+
ipaddresses, err := cnsClient.GetIPAddressesMatchingStates(cns.Available)
238237
if err != nil {
239238
t.Fatalf("Get allocated IP addresses failed %+v", err)
240239
}
@@ -246,4 +245,5 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
246245
if ipaddresses[0].IPAddress != desiredIpAddress && ipaddresses[0].State != cns.Available {
247246
t.Fatalf("Available IP address does not match expected, address state: %+v", ipaddresses)
248247
}
248+
fmt.Println(ipaddresses)
249249
}

cns/restserver/ipam.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (service *HTTPRestService) GetPendingProgramIPConfigs() []cns.IPConfigurati
193193
func (service *HTTPRestService) getIPAddressesHandler(w http.ResponseWriter, r *http.Request) {
194194
var (
195195
req cns.GetIPAddressesRequest
196-
resp cns.GetIPAddressStateResponse
196+
resp cns.GetIPAddressStatusResponse
197197
statusCode int
198198
returnMessage string
199199
err error
@@ -237,14 +237,7 @@ func filterIPConfigsMatchingState(toBeAdded map[string]cns.IPConfigurationStatus
237237
vsf := make([]cns.IPConfigurationStatus, 0)
238238
for _, v := range toBeAdded {
239239
if f(v, states) {
240-
ipconfigstate := cns.IPConfigurationStatus {
241-
IPAddress: v.IPAddress,
242-
State: v.State,
243-
OrchestratorContext: v.OrchestratorContext,
244-
NCID: v.NCID,
245-
ID: v.ID,
246-
}
247-
vsf = append(vsf, ipconfigstate)
240+
vsf = append(vsf, v)
248241
}
249242
}
250243
return vsf

0 commit comments

Comments
 (0)