diff --git a/CHANGELOG.md b/CHANGELOG.md index fe7b24f98..bcccbfc2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ ### Bug Fixes - Update the AccessTokensPath() to read access tokens path through AZURE_ACCESS_TOKEN_FILE. If this -environment variable is not set, it will fall back to use default path set by Azure CLI. + environment variable is not set, it will fall back to use default path set by Azure CLI. +- Use case-insensitive string comparison for polling states. ## v9.4.0 diff --git a/autorest/azure/async.go b/autorest/azure/async.go index c8f495d85..f90699f6c 100644 --- a/autorest/azure/async.go +++ b/autorest/azure/async.go @@ -234,20 +234,15 @@ func getAsyncOperation(resp *http.Response) string { } func hasSucceeded(state string) bool { - return state == operationSucceeded + return strings.EqualFold(state, operationSucceeded) } func hasTerminated(state string) bool { - switch state { - case operationCanceled, operationFailed, operationSucceeded: - return true - default: - return false - } + return strings.EqualFold(state, operationCanceled) || strings.EqualFold(state, operationFailed) || strings.EqualFold(state, operationSucceeded) } func hasFailed(state string) bool { - return state == operationFailed + return strings.EqualFold(state, operationFailed) } type provisioningTracker interface { @@ -426,7 +421,7 @@ func updatePollingState(resp *http.Response, ps *pollingState) error { } } - if ps.State == operationInProgress && ps.URI == "" { + if strings.EqualFold(ps.State, operationInProgress) && ps.URI == "" { return autorest.NewError("azure", "updatePollingState", "Azure Polling Error - Unable to obtain polling URI for %s %s", resp.Request.Method, resp.Request.URL) }