From 215bdbc57ea0287a919cc9e3379e23a55087ea62 Mon Sep 17 00:00:00 2001 From: Alex Pana <8968914+acpana@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:42:42 +0000 Subject: [PATCH 1/2] lint: add depguard Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com> --- .golangci.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.golangci.yaml b/.golangci.yaml index 72f89c4407..3aedd73f1c 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -23,6 +23,7 @@ issues: linters: disable-all: true enable: + - depguard - errcheck - errorlint # - exportloopref @@ -60,3 +61,9 @@ linters-settings: - shadow - testinggoroutine - unusedwrite + depguard: + rules: + main: + deny: + - pkg: "github.com/ghodss/yaml" + desc: Use "sigs.k8s.io/yaml" From e68f2d28bdaae2876d69b1f183b0934a8990b739 Mon Sep 17 00:00:00 2001 From: Alex Pana <8968914+acpana@users.noreply.github.com> Date: Wed, 8 Jan 2025 01:31:15 +0000 Subject: [PATCH 2/2] nolint:depguard Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com> --- config/tests/samples/create/samples.go | 2 +- operator/pkg/test/controller/manifest.go | 2 +- operator/scripts/generate-image-configmap/main.go | 2 +- operator/scripts/utils/yaml.go | 2 +- pkg/cli/cmd/apply/yamlresource/yaml_to_unstructured_resource.go | 2 +- pkg/cli/cmd/printresources/printer/printer.go | 2 +- pkg/cli/outputsink/filename/filename.go | 2 +- pkg/cli/outputsink/sink_test.go | 2 +- pkg/cli/stream/yamlstream.go | 2 +- pkg/controller/dynamic/common_test_functions.go | 2 +- pkg/crd/crdloader/crdloader.go | 2 +- pkg/snippet/snippetgeneration/snippetgeneration.go | 2 +- pkg/test/resourcefixture/resourcefixture.go | 2 +- pkg/test/unstructured.go | 2 +- pkg/test/yaml/yaml.go | 2 +- scripts/generate-cnrm-cluster-roles/main.go | 2 +- scripts/generate-crds/main.go | 2 +- scripts/generate-gvks/main.go | 2 +- scripts/parse-crds/parse-crds.go | 2 +- .../servicemapping/servicemappingloader/servicemappingloader.go | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/config/tests/samples/create/samples.go b/config/tests/samples/create/samples.go index e1f46e86ba..b6b506243c 100644 --- a/config/tests/samples/create/samples.go +++ b/config/tests/samples/create/samples.go @@ -36,7 +36,7 @@ import ( testyaml "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test/yaml" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/util/sets" diff --git a/operator/pkg/test/controller/manifest.go b/operator/pkg/test/controller/manifest.go index 5efb4c67f7..cb00285a68 100644 --- a/operator/pkg/test/controller/manifest.go +++ b/operator/pkg/test/controller/manifest.go @@ -22,7 +22,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/operator/pkg/k8s" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/cluster" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/declarative/pkg/manifest" diff --git a/operator/scripts/generate-image-configmap/main.go b/operator/scripts/generate-image-configmap/main.go index cb107c581d..160581c6a2 100644 --- a/operator/scripts/generate-image-configmap/main.go +++ b/operator/scripts/generate-image-configmap/main.go @@ -27,7 +27,7 @@ import ( "path" "strings" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/operator/scripts/utils/yaml.go b/operator/scripts/utils/yaml.go index c6967fc02b..9f265c4814 100644 --- a/operator/scripts/utils/yaml.go +++ b/operator/scripts/utils/yaml.go @@ -21,7 +21,7 @@ import ( "io" "io/ioutil" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard goyaml "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/cli/cmd/apply/yamlresource/yaml_to_unstructured_resource.go b/pkg/cli/cmd/apply/yamlresource/yaml_to_unstructured_resource.go index 55f09e6db7..53ca93246f 100644 --- a/pkg/cli/cmd/apply/yamlresource/yaml_to_unstructured_resource.go +++ b/pkg/cli/cmd/apply/yamlresource/yaml_to_unstructured_resource.go @@ -20,7 +20,7 @@ import ( "io" "io/ioutil" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/cli/cmd/printresources/printer/printer.go b/pkg/cli/cmd/printresources/printer/printer.go index 8f85edfcde..9a42347d92 100644 --- a/pkg/cli/cmd/printresources/printer/printer.go +++ b/pkg/cli/cmd/printresources/printer/printer.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/cli/cmd/printresources/resourcedescription" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "github.com/olekukonko/tablewriter" ) diff --git a/pkg/cli/outputsink/filename/filename.go b/pkg/cli/outputsink/filename/filename.go index 566c346031..35c174f662 100644 --- a/pkg/cli/outputsink/filename/filename.go +++ b/pkg/cli/outputsink/filename/filename.go @@ -27,7 +27,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/resourceskeleton" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/servicemapping/servicemappingloader" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "github.com/gosimple/slug" tfschema "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/cli/outputsink/sink_test.go b/pkg/cli/outputsink/sink_test.go index f368bd88cd..7428324706 100644 --- a/pkg/cli/outputsink/sink_test.go +++ b/pkg/cli/outputsink/sink_test.go @@ -29,7 +29,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test" tfprovider "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/tf/provider" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" diff --git a/pkg/cli/stream/yamlstream.go b/pkg/cli/stream/yamlstream.go index 33894d28be..0d5e641652 100644 --- a/pkg/cli/stream/yamlstream.go +++ b/pkg/cli/stream/yamlstream.go @@ -20,7 +20,7 @@ import ( "fmt" "io" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/controller/dynamic/common_test_functions.go b/pkg/controller/dynamic/common_test_functions.go index ae7db979e7..9493da8893 100644 --- a/pkg/controller/dynamic/common_test_functions.go +++ b/pkg/controller/dynamic/common_test_functions.go @@ -21,7 +21,7 @@ import ( condition "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/apis/k8s/v1alpha1" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" diff --git a/pkg/crd/crdloader/crdloader.go b/pkg/crd/crdloader/crdloader.go index df467027d1..045c5041b9 100644 --- a/pkg/crd/crdloader/crdloader.go +++ b/pkg/crd/crdloader/crdloader.go @@ -25,7 +25,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/text" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" diff --git a/pkg/snippet/snippetgeneration/snippetgeneration.go b/pkg/snippet/snippetgeneration/snippetgeneration.go index 7c6e938033..e36b252c54 100644 --- a/pkg/snippet/snippetgeneration/snippetgeneration.go +++ b/pkg/snippet/snippetgeneration/snippetgeneration.go @@ -23,7 +23,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/mapslice" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard goyaml "gopkg.in/yaml.v2" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/test/resourcefixture/resourcefixture.go b/pkg/test/resourcefixture/resourcefixture.go index 9e67b076b6..9cd16856fe 100644 --- a/pkg/test/resourcefixture/resourcefixture.go +++ b/pkg/test/resourcefixture/resourcefixture.go @@ -26,7 +26,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/test" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/pkg/test/unstructured.go b/pkg/test/unstructured.go index 5a4183ec06..b4d3f3735e 100644 --- a/pkg/test/unstructured.go +++ b/pkg/test/unstructured.go @@ -17,7 +17,7 @@ package test import ( "testing" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) diff --git a/pkg/test/yaml/yaml.go b/pkg/test/yaml/yaml.go index c0d12c5359..99af4564e0 100644 --- a/pkg/test/yaml/yaml.go +++ b/pkg/test/yaml/yaml.go @@ -21,7 +21,7 @@ import ( cnrmyaml "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/yaml" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard "github.com/google/go-cmp/cmp" ) diff --git a/scripts/generate-cnrm-cluster-roles/main.go b/scripts/generate-cnrm-cluster-roles/main.go index d047609aa3..8a91805965 100644 --- a/scripts/generate-cnrm-cluster-roles/main.go +++ b/scripts/generate-cnrm-cluster-roles/main.go @@ -28,7 +28,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/slice" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard rbacv1 "k8s.io/api/rbac/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) diff --git a/scripts/generate-crds/main.go b/scripts/generate-crds/main.go index f1bb9e73d5..169b59a75c 100644 --- a/scripts/generate-crds/main.go +++ b/scripts/generate-crds/main.go @@ -40,7 +40,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/repo" "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/util/slice" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" crdgen "sigs.k8s.io/controller-tools/pkg/crd" "sigs.k8s.io/controller-tools/pkg/genall" diff --git a/scripts/generate-gvks/main.go b/scripts/generate-gvks/main.go index d8fd963009..38483e26c0 100644 --- a/scripts/generate-gvks/main.go +++ b/scripts/generate-gvks/main.go @@ -26,7 +26,7 @@ import ( "sort" "strings" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/scripts/parse-crds/parse-crds.go b/scripts/parse-crds/parse-crds.go index 18aecd11ed..b44198aaef 100644 --- a/scripts/parse-crds/parse-crds.go +++ b/scripts/parse-crds/parse-crds.go @@ -28,7 +28,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/crd/crdgeneration" kccyaml "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/yaml" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard apiextensions "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" ) diff --git a/scripts/resource-autogen/servicemapping/servicemappingloader/servicemappingloader.go b/scripts/resource-autogen/servicemapping/servicemappingloader/servicemappingloader.go index bd644cb4ba..10f8ee8e87 100644 --- a/scripts/resource-autogen/servicemapping/servicemappingloader/servicemappingloader.go +++ b/scripts/resource-autogen/servicemapping/servicemappingloader/servicemappingloader.go @@ -27,7 +27,7 @@ import ( "github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/allowlist" generatedembed "github.com/GoogleCloudPlatform/k8s-config-connector/scripts/resource-autogen/servicemapping/embed/generated" - "github.com/ghodss/yaml" + "github.com/ghodss/yaml" //nolint:depguard ) var emptyIAMConfig v1alpha1.IAMConfig