mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	Linter to ensure go-cmp/cmp is used ONLY in tests
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
		| @@ -26,7 +26,7 @@ import ( | |||||||
| 	"sort" | 	"sort" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| ) | ) | ||||||
|  |  | ||||||
| type Unwanted struct { | type Unwanted struct { | ||||||
|   | |||||||
| @@ -91,6 +91,7 @@ issues: | |||||||
| linters: | linters: | ||||||
|   disable-all: false |   disable-all: false | ||||||
|   enable: # please keep this alphabetized |   enable: # please keep this alphabetized | ||||||
|  |     - depguard | ||||||
|     - forbidigo |     - forbidigo | ||||||
|     - ginkgolinter |     - ginkgolinter | ||||||
|     - gocritic |     - gocritic | ||||||
| @@ -176,6 +177,16 @@ linters-settings: # please keep this alphabetized | |||||||
|           # this restriction. Whether we then do a global search/replace remains |           # this restriction. Whether we then do a global search/replace remains | ||||||
|           # to be decided. |           # to be decided. | ||||||
|           with-helpers .* |           with-helpers .* | ||||||
|  |   depguard: | ||||||
|  |     rules: | ||||||
|  |       main: | ||||||
|  |         files: | ||||||
|  |           - $all | ||||||
|  |           - "!$test" | ||||||
|  |           - "!**/test/**" | ||||||
|  |         deny: | ||||||
|  |           - pkg: "github.com/google/go-cmp/cmp" | ||||||
|  |             desc: "cmp is allowed only in test files" | ||||||
|   forbidigo: |   forbidigo: | ||||||
|     analyze-types: true |     analyze-types: true | ||||||
|     forbid: |     forbid: | ||||||
|   | |||||||
| @@ -135,6 +135,7 @@ issues: | |||||||
| linters: | linters: | ||||||
|   disable-all: false |   disable-all: false | ||||||
|   enable: # please keep this alphabetized |   enable: # please keep this alphabetized | ||||||
|  |     - depguard | ||||||
|     - forbidigo |     - forbidigo | ||||||
|     - ginkgolinter |     - ginkgolinter | ||||||
|     - gocritic |     - gocritic | ||||||
| @@ -222,6 +223,16 @@ linters-settings: # please keep this alphabetized | |||||||
|           # this restriction. Whether we then do a global search/replace remains |           # this restriction. Whether we then do a global search/replace remains | ||||||
|           # to be decided. |           # to be decided. | ||||||
|           with-helpers .* |           with-helpers .* | ||||||
|  |   depguard: | ||||||
|  |     rules: | ||||||
|  |       main: | ||||||
|  |         files: | ||||||
|  |           - $all | ||||||
|  |           - "!$test" | ||||||
|  |           - "!**/test/**" | ||||||
|  |         deny: | ||||||
|  |           - pkg: "github.com/google/go-cmp/cmp" | ||||||
|  |             desc: "cmp is allowed only in test files" | ||||||
|   forbidigo: |   forbidigo: | ||||||
|     analyze-types: true |     analyze-types: true | ||||||
|     forbid: |     forbid: | ||||||
|   | |||||||
| @@ -141,6 +141,7 @@ issues: | |||||||
| linters: | linters: | ||||||
|   disable-all: true |   disable-all: true | ||||||
|   enable: # please keep this alphabetized |   enable: # please keep this alphabetized | ||||||
|  |     - depguard | ||||||
|     - forbidigo |     - forbidigo | ||||||
|     - ginkgolinter |     - ginkgolinter | ||||||
|     - gocritic |     - gocritic | ||||||
| @@ -224,6 +225,16 @@ linters-settings: # please keep this alphabetized | |||||||
|           # this restriction. Whether we then do a global search/replace remains |           # this restriction. Whether we then do a global search/replace remains | ||||||
|           # to be decided. |           # to be decided. | ||||||
|           with-helpers .* |           with-helpers .* | ||||||
|  |   depguard: | ||||||
|  |     rules: | ||||||
|  |       main: | ||||||
|  |         files: | ||||||
|  |           - $all | ||||||
|  |           - "!$test" | ||||||
|  |           - "!**/test/**" | ||||||
|  |         deny: | ||||||
|  |           - pkg: "github.com/google/go-cmp/cmp" | ||||||
|  |             desc: "cmp is allowed only in test files" | ||||||
|   forbidigo: |   forbidigo: | ||||||
|     analyze-types: true |     analyze-types: true | ||||||
|     forbid: |     forbid: | ||||||
|   | |||||||
| @@ -147,6 +147,7 @@ issues: | |||||||
| linters: | linters: | ||||||
|   disable-all: {{if .Base -}} true {{- else -}} false {{- end}} |   disable-all: {{if .Base -}} true {{- else -}} false {{- end}} | ||||||
|   enable: # please keep this alphabetized |   enable: # please keep this alphabetized | ||||||
|  |     - depguard | ||||||
|     - forbidigo |     - forbidigo | ||||||
|     - ginkgolinter |     - ginkgolinter | ||||||
|     - gocritic |     - gocritic | ||||||
| @@ -180,6 +181,16 @@ linters-settings: # please keep this alphabetized | |||||||
|       settings: |       settings: | ||||||
|         config: | |         config: | | ||||||
|           {{include "hack/logcheck.conf" | indent 10 | trim}} |           {{include "hack/logcheck.conf" | indent 10 | trim}} | ||||||
|  |   depguard: | ||||||
|  |     rules: | ||||||
|  |       main: | ||||||
|  |         files: | ||||||
|  |           - $all | ||||||
|  |           - "!$test" | ||||||
|  |           - "!**/test/**" | ||||||
|  |         deny: | ||||||
|  |           - pkg: "github.com/google/go-cmp/cmp" | ||||||
|  |             desc: "cmp is allowed only in test files" | ||||||
|   forbidigo: |   forbidigo: | ||||||
|     analyze-types: true |     analyze-types: true | ||||||
|     forbid: |     forbid: | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ package pod | |||||||
| import ( | import ( | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" | 	metavalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation" | ||||||
| 	"k8s.io/apimachinery/pkg/util/sets" | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import ( | |||||||
| 	"encoding/pem" | 	"encoding/pem" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
| 	"k8s.io/apimachinery/pkg/util/sets" | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
|   | |||||||
| @@ -30,7 +30,7 @@ import ( | |||||||
| 	"unicode" | 	"unicode" | ||||||
| 	"unicode/utf8" | 	"unicode/utf8" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	netutils "k8s.io/utils/net" | 	netutils "k8s.io/utils/net" | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ import ( | |||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"sync" | 	"sync" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	"k8s.io/klog/v2" | 	"k8s.io/klog/v2" | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import ( | |||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	clientset "k8s.io/client-go/kubernetes" | 	clientset "k8s.io/client-go/kubernetes" | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strconv" | 	"strconv" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	flowcontrolv1 "k8s.io/api/flowcontrol/v1" | 	flowcontrolv1 "k8s.io/api/flowcontrol/v1" | ||||||
| 	apierrors "k8s.io/apimachinery/pkg/api/errors" | 	apierrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
|   | |||||||
| @@ -26,8 +26,8 @@ import ( | |||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp"         //nolint:depguard | ||||||
| 	"github.com/google/go-cmp/cmp/cmpopts" | 	"github.com/google/go-cmp/cmp/cmpopts" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ import ( | |||||||
| 	"slices" | 	"slices" | ||||||
| 	"sync" | 	"sync" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	resourceapi "k8s.io/api/resource/v1beta1" | 	resourceapi "k8s.io/api/resource/v1beta1" | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import ( | |||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ limitations under the License. | |||||||
| package noderesources | package noderesources | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"github.com/google/go-cmp/cmp/cmpopts" | 	"github.com/google/go-cmp/cmp/cmpopts" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/api/resource" | 	"k8s.io/apimachinery/pkg/api/resource" | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import ( | |||||||
| 	"errors" | 	"errors" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/client-go/kubernetes/scheme" | 	"k8s.io/client-go/kubernetes/scheme" | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ import ( | |||||||
| 	"io" | 	"io" | ||||||
| 	"strings" | 	"strings" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	fuzz "github.com/google/gofuzz" | 	fuzz "github.com/google/gofuzz" | ||||||
| 	flag "github.com/spf13/pflag" | 	flag "github.com/spf13/pflag" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -37,7 +37,7 @@ import ( | |||||||
| 	jsonserializer "k8s.io/apimachinery/pkg/runtime/serializer/json" | 	jsonserializer "k8s.io/apimachinery/pkg/runtime/serializer/json" | ||||||
| 	"k8s.io/apimachinery/pkg/util/sets" | 	"k8s.io/apimachinery/pkg/util/sets" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| ) | ) | ||||||
|  |  | ||||||
| // RoundtripToUnstructured verifies the roundtrip faithfulness of all external types in a scheme | // RoundtripToUnstructured verifies the roundtrip faithfulness of all external types in a scheme | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ import ( | |||||||
| 	"strings" | 	"strings" | ||||||
| 	"text/tabwriter" | 	"text/tabwriter" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	"k8s.io/apimachinery/pkg/util/dump" | 	"k8s.io/apimachinery/pkg/util/dump" | ||||||
| ) | ) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,7 +21,7 @@ import ( | |||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apiserver/pkg/admission" | 	"k8s.io/apiserver/pkg/admission" | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ import ( | |||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/emicklei/go-restful/v3" | 	"github.com/emicklei/go-restful/v3" | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	apidiscoveryv2 "k8s.io/api/apidiscovery/v2" | 	apidiscoveryv2 "k8s.io/api/apidiscovery/v2" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/util/wait" | 	"k8s.io/apimachinery/pkg/util/wait" | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ import ( | |||||||
| 	"sync" | 	"sync" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	apierrors "k8s.io/apimachinery/pkg/api/errors" | 	apierrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/fields" | 	"k8s.io/apimachinery/pkg/fields" | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ import ( | |||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	"k8s.io/apimachinery/pkg/api/meta" | 	"k8s.io/apimachinery/pkg/api/meta" | ||||||
| 	v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/fields" | 	"k8s.io/apimachinery/pkg/fields" | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ import ( | |||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
| 	apierrors "k8s.io/apimachinery/pkg/api/errors" | 	apierrors "k8s.io/apimachinery/pkg/api/errors" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import ( | |||||||
| 	"sort" | 	"sort" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	"k8s.io/apimachinery/pkg/api/meta" | 	"k8s.io/apimachinery/pkg/api/meta" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ import ( | |||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime/serializer" | 	"k8s.io/apimachinery/pkg/runtime/serializer" | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ import ( | |||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"testing" | 	"testing" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	apiequality "k8s.io/apimachinery/pkg/api/equality" | 	apiequality "k8s.io/apimachinery/pkg/api/equality" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime" | 	"k8s.io/apimachinery/pkg/runtime" | ||||||
| 	"k8s.io/apimachinery/pkg/runtime/schema" | 	"k8s.io/apimachinery/pkg/runtime/schema" | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ import ( | |||||||
| 	"sync/atomic" | 	"sync/atomic" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
| 	"github.com/spf13/pflag" | 	"github.com/spf13/pflag" | ||||||
|  |  | ||||||
| 	"k8s.io/klog/v2" | 	"k8s.io/klog/v2" | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ import ( | |||||||
| 	"sync/atomic" | 	"sync/atomic" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| 	"github.com/google/go-cmp/cmp" | 	"github.com/google/go-cmp/cmp" //nolint:depguard | ||||||
|  |  | ||||||
| 	v1 "k8s.io/api/core/v1" | 	v1 "k8s.io/api/core/v1" | ||||||
| 	resourceapi "k8s.io/api/resource/v1beta1" | 	resourceapi "k8s.io/api/resource/v1beta1" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Davanum Srinivas
					Davanum Srinivas