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:
Brian Goff
2018-09-19 18:15:35 -07:00
parent b8d0b6eb03
commit 74840defdf
2 changed files with 12 additions and 12 deletions

View File

@@ -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

View File

@@ -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()