-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance error report and ignore removed resources on destroy (#107
) * feat: enhance error report and ignore removed resources on destroy * fix(ci): Workaround Go 1.16 issue with go.sum dependencies * chore: Update dependencies
- Loading branch information
1 parent
463ceec
commit 6a9f09c
Showing
14 changed files
with
227 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package common | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/jmespath/go-jmespath" | ||
"github.com/spf13/cast" | ||
) | ||
|
||
func errorFromResponse(response *http.Response) error { | ||
var data interface{} | ||
err := json.NewDecoder(response.Body).Decode(&data) | ||
if err != nil { | ||
return errors.New(response.Status) | ||
} | ||
|
||
search, err := jmespath.Search("[message, errors[].[reason, message]][][] | join(', ', @)", data) | ||
if err != nil { | ||
return errors.New(response.Status) | ||
} | ||
|
||
if searchArray, ok := search.([]interface{}); ok { | ||
return errors.New(strings.Join(cast.ToStringSlice(searchArray), ", ")) | ||
} | ||
|
||
return errors.New(cast.ToString(search)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.