Minor changes for the review comments

GetIPAddressStateResponse kept as original struct, and added
GetIPAddressStatusResponse
Minor changes to reflect GetIPAddressStatusResponse
This commit is contained in:
Kshitija Murudi 2021-03-01 20:46:58 -08:00
Родитель 199980cb42
Коммит 5a6c4846de
5 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -238,6 +238,12 @@ type GetIPAddressesRequest struct {
// GetIPAddressStateResponse is used in CNS IPAM mode as a response to get IP address state
type GetIPAddressStateResponse struct {
IPAddresses []IPAddressState
Response Response
}
// GetIPAddressStatusResponse is used in CNS IPAM mode as a response to get IP address, state and Pod info
type GetIPAddressStatusResponse struct {
IPConfigurationStatus[] IPConfigurationStatus
Response Response
}

Просмотреть файл

@ -93,6 +93,6 @@ func printIPAddresses(addrSlice []cns.IPConfigurationStatus) {
})
for _, addr := range addrSlice {
fmt.Printf("%+v\n", addr)
cns.IPConfigurationStatus.String(addr)
}
}

Просмотреть файл

@ -321,7 +321,7 @@ func (cnsClient *CNSClient) ReleaseIPAddress(orchestratorContext []byte) error {
// usage GetIPAddressesWithStates(cns.Available, cns.Allocated)
func (cnsClient *CNSClient) GetIPAddressesMatchingStates(StateFilter ...string) ([]cns.IPConfigurationStatus, error) {
var (
resp cns.GetIPAddressStateResponse
resp cns.GetIPAddressStatusResponse
err error
res *http.Response
body bytes.Buffer

Просмотреть файл

@ -233,8 +233,7 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
t.Fatalf("Expected to not fail when releasing IP reservation found with context: %+v", err)
}
ipaddresses, err := cnsClient.GetIPAddressesMatchingStates("Available")
fmt.Println(ipaddresses)
ipaddresses, err := cnsClient.GetIPAddressesMatchingStates(cns.Available)
if err != nil {
t.Fatalf("Get allocated IP addresses failed %+v", err)
}
@ -246,4 +245,5 @@ func TestCNSClientRequestAndRelease(t *testing.T) {
if ipaddresses[0].IPAddress != desiredIpAddress && ipaddresses[0].State != cns.Available {
t.Fatalf("Available IP address does not match expected, address state: %+v", ipaddresses)
}
fmt.Println(ipaddresses)
}

Просмотреть файл

@ -193,7 +193,7 @@ func (service *HTTPRestService) GetPendingProgramIPConfigs() []cns.IPConfigurati
func (service *HTTPRestService) getIPAddressesHandler(w http.ResponseWriter, r *http.Request) {
var (
req cns.GetIPAddressesRequest
resp cns.GetIPAddressStateResponse
resp cns.GetIPAddressStatusResponse
statusCode int
returnMessage string
err error
@ -237,14 +237,7 @@ func filterIPConfigsMatchingState(toBeAdded map[string]cns.IPConfigurationStatus
vsf := make([]cns.IPConfigurationStatus, 0)
for _, v := range toBeAdded {
if f(v, states) {
ipconfigstate := cns.IPConfigurationStatus {
IPAddress: v.IPAddress,
State: v.State,
OrchestratorContext: v.OrchestratorContext,
NCID: v.NCID,
ID: v.ID,
}
vsf = append(vsf, ipconfigstate)
vsf = append(vsf, v)
}
}
return vsf