Commit ca8831e7 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch '6-fix-go-ci-lint' into 'master'

fix(go-ci-lint): fix SA4005, SA6000 and S1007

Closes #6

See merge request to-be-continuous/tools/vault-secrets-provider!7
parents b63ad492 ae957821
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -32,3 +32,5 @@

### VS Code ###
/.vscode/
reports/coverage.out
reports/coverage.out
+16 −19
Original line number Diff line number Diff line
@@ -35,15 +35,14 @@ const (
 */
type ErrorResponse struct {
	Errors []string `json:"errors"`
	normalized bool
}

func (er ErrorResponse) Error() string {
	if !er.normalized {
	normErrors := make([]string, 0)
	r, _ := regexp.Compile(`^(\d+) errors? occurred:`)
	for i := 0; i < len(er.Errors); i++ {
		// nolint
			if match, _ := regexp.MatchString("^(\\d+) errors? occurred:", er.Errors[i]); match {
		if match := r.MatchString(er.Errors[i]); match {
			// this is a multiline error: extract and normalize each line starting with "* "
			lines := strings.Split(er.Errors[i], "\n")
			for ln := 0; ln < len(lines); ln++ {
@@ -58,8 +57,6 @@ func (er ErrorResponse) Error() string {
		}
	}
	er.Errors = normErrors
		er.normalized = true
	}
	return strings.Join(er.Errors, ", ")
}