diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index 4d5298cd57d..1f3ecff2d4d 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -246,7 +246,7 @@ linters: # pointerPolicy: SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers. depguard: rules: - main: + go-cmp: files: - $all - "!$test" @@ -254,6 +254,13 @@ linters: deny: - pkg: "github.com/google/go-cmp/cmp" desc: "cmp is allowed only in test files" + pkg-errors: + files: + - $all + - "!**/cmd/kubeadm/**" + deny: + - pkg: "github.com/pkg/errors" + desc: "pkg/errors is allowed only in cmd/kubeadm" forbidigo: analyze-types: true forbid: diff --git a/hack/golangci.yaml b/hack/golangci.yaml index 842ace600f2..423fd4fa207 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -260,7 +260,7 @@ linters: # pointerPolicy: SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers. depguard: rules: - main: + go-cmp: files: - $all - "!$test" @@ -268,6 +268,13 @@ linters: deny: - pkg: "github.com/google/go-cmp/cmp" desc: "cmp is allowed only in test files" + pkg-errors: + files: + - $all + - "!**/cmd/kubeadm/**" + deny: + - pkg: "github.com/pkg/errors" + desc: "pkg/errors is allowed only in cmd/kubeadm" forbidigo: analyze-types: true forbid: diff --git a/hack/golangci.yaml.in b/hack/golangci.yaml.in index 706bc36f77a..cff3c272098 100644 --- a/hack/golangci.yaml.in +++ b/hack/golangci.yaml.in @@ -190,7 +190,7 @@ linters: {{include "hack/kube-api-linter/kube-api-linter.yaml" | indent 10 | trim}} depguard: rules: - main: + go-cmp: files: - $all - "!$test" @@ -198,6 +198,13 @@ linters: deny: - pkg: "github.com/google/go-cmp/cmp" desc: "cmp is allowed only in test files" + pkg-errors: + files: + - $all + - "!**/cmd/kubeadm/**" + deny: + - pkg: "github.com/pkg/errors" + desc: "pkg/errors is allowed only in cmd/kubeadm" forbidigo: analyze-types: true forbid: diff --git a/test/e2e_node/container_restart_test.go b/test/e2e_node/container_restart_test.go index 641d17ad5b3..d4e75dc0f42 100644 --- a/test/e2e_node/container_restart_test.go +++ b/test/e2e_node/container_restart_test.go @@ -29,7 +29,6 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" - "github.com/pkg/errors" kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" v1 "k8s.io/api/core/v1" @@ -165,7 +164,7 @@ func extractObservedBackoff(ctx context.Context, f *framework.Framework, podName } } } - return r, errors.Errorf("Could not find container status for container %s in pod %s", containerName, podName) + return r, fmt.Errorf("Could not find container status for container %s in pod %s", containerName, podName) } func newFailAlwaysPod() *v1.Pod { diff --git a/test/e2e_node/image_pull_test.go b/test/e2e_node/image_pull_test.go index 7c3f3bf1054..b8f7b8bb637 100644 --- a/test/e2e_node/image_pull_test.go +++ b/test/e2e_node/image_pull_test.go @@ -21,6 +21,7 @@ package e2enode import ( "context" + "errors" "fmt" "strings" "sync" @@ -28,7 +29,6 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" - "github.com/pkg/errors" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -357,7 +357,7 @@ type pulledStruct struct { func getDurationsFromPulledEventMsg(msg string) (*pulledStruct, error) { splits := strings.Split(msg, " ") if len(splits) != 13 { - return nil, errors.Errorf("pull event message should be spilted to 13: %d", len(splits)) + return nil, fmt.Errorf("pull event message should be spilted to 13: %d", len(splits)) } pulledDuration, err := time.ParseDuration(splits[5]) if err != nil {