Fix NPE panic in ACI client
resp is nil when `Do()` has an error. Also seems there was some gofmt issues in the file.
This commit is contained in:
@@ -699,7 +699,7 @@ func (p *ACIProvider) DeletePod(ctx context.Context, pod *v1.Pod) error {
|
|||||||
func (p *ACIProvider) GetPod(ctx context.Context, namespace, name string) (*v1.Pod, error) {
|
func (p *ACIProvider) GetPod(ctx context.Context, namespace, name string) (*v1.Pod, error) {
|
||||||
cg, err, status := p.aciClient.GetContainerGroup(ctx, p.resourceGroup, fmt.Sprintf("%s-%s", namespace, name))
|
cg, err, status := p.aciClient.GetContainerGroup(ctx, p.resourceGroup, fmt.Sprintf("%s-%s", namespace, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if *status == http.StatusNotFound {
|
if status != nil && *status == http.StatusNotFound {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (c *Client) GetContainerGroup(ctx context.Context, resourceGroup, container
|
|||||||
// Send the request.
|
// Send the request.
|
||||||
resp, err := c.hc.Do(req)
|
resp, err := c.hc.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Sending get container group request failed: %v", err), &resp.StatusCode
|
return nil, fmt.Errorf("Sending get container group request failed: %v", err), nil
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user