update golangci-lint v1.49.0

This commit is contained in:
yugo kobayashi
2022-09-22 12:56:15 +00:00
parent e62480d11c
commit 401cf9579c
15 changed files with 49 additions and 41 deletions

View File

@@ -903,7 +903,7 @@ func TestFileOps(t *testing.T) {
defer f.Close()
for {
buf := make([]byte, rand.Intn(10)) // nolint:gosec
buf := make([]byte, rand.Intn(10)) //nolint:gosec
n, err := f.Read(buf)
if err != nil && err != io.EOF {
t.Fatalf("unexpected error: %v", err)

View File

@@ -74,30 +74,30 @@ func PathJoin(incoming []string) string {
//
// E.g. if part == 'PEACH'
//
// OLD : NEW : POS
// --------------------------------------------------------
// {empty} : PEACH : irrelevant
// / : /PEACH : irrelevant
// pie : PEACH/pie : 0 (or negative)
// /pie : /PEACH/pie : 0 (or negative)
// raw : raw/PEACH : 1 (or larger)
// /raw : /raw/PEACH : 1 (or larger)
// a/nice/warm/pie : a/nice/warm/PEACH/pie : 3
// /a/nice/warm/pie : /a/nice/warm/PEACH/pie : 3
// OLD : NEW : POS
// --------------------------------------------------------
// {empty} : PEACH : irrelevant
// / : /PEACH : irrelevant
// pie : PEACH/pie : 0 (or negative)
// /pie : /PEACH/pie : 0 (or negative)
// raw : raw/PEACH : 1 (or larger)
// /raw : /raw/PEACH : 1 (or larger)
// a/nice/warm/pie : a/nice/warm/PEACH/pie : 3
// /a/nice/warm/pie : /a/nice/warm/PEACH/pie : 3
//
// * An empty part results in no change.
//
// * Absolute paths get their leading '/' stripped, treated like
// relative paths, and the leading '/' is re-added on output.
// The meaning of pos is intentionally the same in either absolute or
// relative paths; if it weren't, this function could convert absolute
// paths to relative paths, which is not desirable.
// - Absolute paths get their leading '/' stripped, treated like
// relative paths, and the leading '/' is re-added on output.
// The meaning of pos is intentionally the same in either absolute or
// relative paths; if it weren't, this function could convert absolute
// paths to relative paths, which is not desirable.
//
// * For robustness (liberal input, conservative output) Pos values that
// that are too small (large) to index the split filepath result in a
// prefix (postfix) rather than an error. Use extreme position values
// to assure a prefix or postfix (e.g. 0 will always prefix, and
// 9999 will presumably always postfix).
// - For robustness (liberal input, conservative output) Pos values that
// that are too small (large) to index the split filepath result in a
// prefix (postfix) rather than an error. Use extreme position values
// to assure a prefix or postfix (e.g. 0 will always prefix, and
// 9999 will presumably always postfix).
func InsertPathPart(path string, pos int, part string) string {
if part == "" {
return path
@@ -121,7 +121,7 @@ func InsertPathPart(path string, pos int, part string) string {
result := make([]string, len(parts)+1)
copy(result, parts[0:pos])
result[pos] = part
return PathJoin(append(result, parts[pos:]...)) // nolint: makezero
return PathJoin(append(result, parts[pos:]...)) //nolint: makezero
}
func IsHiddenFilePath(pattern string) bool {

View File

@@ -82,7 +82,7 @@ type KRMFunctionVersion struct {
type KRMFunctionValidation struct {
// OpenAPIV3Schema is the OpenAPI v3 schema for an instance of the KRM function.
OpenAPIV3Schema *spec.Schema `yaml:"openAPIV3Schema,omitempty" json:"openAPIV3Schema,omitempty"` // nolint: tagliatelle
OpenAPIV3Schema *spec.Schema `yaml:"openAPIV3Schema,omitempty" json:"openAPIV3Schema,omitempty"` //nolint: tagliatelle
}
type KRMFunctionNames struct {

View File

@@ -34,7 +34,7 @@ func (c *Filter) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error) {
}
func (c *Filter) Run(reader io.Reader, writer io.Writer) error {
cmd := exec.Command(c.Path, c.Args...) // nolint:gosec
cmd := exec.Command(c.Path, c.Args...) //nolint:gosec
cmd.Stdin = reader
cmd.Stdout = writer
cmd.Stderr = os.Stderr

View File

@@ -204,7 +204,7 @@ func (s *StorageMount) String() string {
func GetFunctionSpec(n *yaml.RNode) (*FunctionSpec, error) {
meta, err := n.GetMeta()
if err != nil {
return nil, nil
return nil, fmt.Errorf("failed to get ResourceMeta: %w", err)
}
fn, err := getFunctionSpecFromAnnotation(n, meta)
@@ -237,7 +237,10 @@ func getFunctionSpecFromAnnotation(n *yaml.RNode, meta yaml.ResourceMeta) (*Func
}
}
n, err := n.Pipe(yaml.Lookup("metadata", "configFn"))
if err != nil || yaml.IsMissingOrNull(n) {
if err != nil {
return nil, fmt.Errorf("failed to LookUp configFn: %w", err)
}
if yaml.IsMissingOrNull(n) {
return nil, nil
}
s, err := n.String()

View File

@@ -281,7 +281,8 @@ metadata:
out: []string{"gcr.io/example.com/image:v1.0.0"},
},
{name: "no function spec",
{
name: "no function spec",
in: []f{
{
explicitFunction: true,
@@ -290,6 +291,7 @@ foo: bar
`,
},
},
error: "failed to get FunctionSpec: failed to get ResourceMeta: missing Resource metadata",
},
// Test