Merge pull request #905 from docker/fix_aci_potential_nil_panic

Use ACI .IsHttpStatus() rather than accessing .StatusCode directly
This commit is contained in:
Nicolas De loof 2020-11-12 15:12:14 +01:00 committed by GitHub
commit aa09ecb1f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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