From 0d74298eed2c1bfd6e7aae379a5e2b7f77ed0c44 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Thu, 12 Nov 2020 15:01:18 +0100 Subject: [PATCH] Use ACI .IsHttpStatus() rather than accessing .StatusCode directly, that might lead to nil pointer panic Signed-off-by: Guillaume Tardif --- aci/aci.go | 2 +- aci/compose.go | 2 +- aci/containers.go | 2 +- aci/volumes.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aci/aci.go b/aci/aci.go index 04e612ee4..49eaa7b0c 100644 --- a/aci/aci.go +++ b/aci/aci.go @@ -173,7 +173,7 @@ func stopACIContainerGroup(ctx context.Context, aciContext store.AciContext, con } result, err := containerGroupsClient.Stop(ctx, aciContext.ResourceGroup, containerGroupName) - if result.StatusCode == http.StatusNotFound { + if result.IsHTTPStatus(http.StatusNotFound) { return errdefs.ErrNotFound } return err diff --git a/aci/compose.go b/aci/compose.go index d8792fe32..73828e7de 100644 --- a/aci/compose.go +++ b/aci/compose.go @@ -62,7 +62,7 @@ func (cs *aciComposeService) Down(ctx context.Context, project string) error { if err != nil { return err } - if cg.StatusCode == http.StatusNoContent { + if cg.IsHTTPStatus(http.StatusNoContent) { return errdefs.ErrNotFound } diff --git a/aci/containers.go b/aci/containers.go index 3f6be0893..2674298ae 100644 --- a/aci/containers.go +++ b/aci/containers.go @@ -223,7 +223,7 @@ func (cs *aciContainerService) Delete(ctx context.Context, containerID string, r cg, err := deleteACIContainerGroup(ctx, cs.ctx, groupName) // Delete returns `StatusNoContent` if the group is not found - if cg.StatusCode == http.StatusNoContent { + if cg.IsHTTPStatus(http.StatusNoContent) { return errdefs.ErrNotFound } if err != nil { diff --git a/aci/volumes.go b/aci/volumes.go index e04e0728c..e7e3e0ad8 100644 --- a/aci/volumes.go +++ b/aci/volumes.go @@ -223,7 +223,7 @@ func (cs *aciVolumeService) Delete(ctx context.Context, id string, options inter if err == nil { if _, ok := account.Tags[dockerVolumeTag]; ok { result, err := storageAccountsClient.Delete(ctx, cs.aciContext.ResourceGroup, storageAccount) - if result.StatusCode == http.StatusNoContent { + if result.IsHTTPStatus(http.StatusNoContent) { return errors.Wrapf(errdefs.ErrNotFound, "storage account %s does not exist", storageAccount) } return err