Fix various golangci-lint errors (#2059)

This commit is contained in:
Anton Bretting
2022-02-12 20:28:08 +09:00
committed by GitHub
parent 9a2df3c0a2
commit 2f04831817
29 changed files with 362 additions and 263 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ func (c *Context) Exec(command string, args []interface{}, inputs ...string) (st
for i, a := range args {
switch a.(type) {
case string:
strArgs[i] = a.(string)
strArgs[i] = fmt.Sprintf("%v", a)
default:
return "", fmt.Errorf("unexpected type of arg \"%s\" in args %v at index %d", reflect.TypeOf(a), args, i)
}
+9 -7
View File
@@ -3,10 +3,11 @@ package tmpl
import (
"encoding/json"
"fmt"
"github.com/google/go-cmp/cmp"
"path/filepath"
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestReadFile(t *testing.T) {
@@ -207,14 +208,15 @@ func TestRequired(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := Required(tt.args.warn, tt.args.val)
if (err != nil) != tt.wantErr {
t.Errorf("Required() error = %v, wantErr %v", err, tt.wantErr)
testCase := tt
t.Run(testCase.name, func(t *testing.T) {
got, err := Required(testCase.args.warn, testCase.args.val)
if (err != nil) != testCase.wantErr {
t.Errorf("Required() error = %v, wantErr %v", err, testCase.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Required() got = %v, want %v", got, tt.want)
if !reflect.DeepEqual(got, testCase.want) {
t.Errorf("Required() got = %v, want %v", got, testCase.want)
}
})
}
+4 -4
View File
@@ -1,11 +1,11 @@
package tmpl
import (
"errors"
"fmt"
"sync"
"github.com/roboll/helmfile/pkg/plugins"
"github.com/variantdev/vals"
"sync"
)
//to generate mock run mockgen -source=expand_secret_ref.go -destination=expand_secrets_mock.go -package=tmpl
@@ -26,12 +26,12 @@ func fetchSecretValue(path string) (string, error) {
rendered, ok := resultMap["key"]
if !ok {
return "", errors.New(fmt.Sprintf("unexpected error occurred, %v doesn't have 'key' key", resultMap))
return "", fmt.Errorf("unexpected error occurred, %v doesn't have 'key' key", resultMap)
}
result, ok := rendered.(string)
if !ok {
return "", errors.New(fmt.Sprintf("expected %v to be string", rendered))
return "", fmt.Errorf("expected %v to be string", rendered)
}
return result, nil