Skip to content

Commit

Permalink
fix lint (istio#40056)
Browse files Browse the repository at this point in the history
* fix lint

* make gen
  • Loading branch information
zirain authored Jul 22, 2022
1 parent 56e7740 commit dc3a94f
Show file tree
Hide file tree
Showing 24 changed files with 33 additions and 61 deletions.
6 changes: 6 additions & 0 deletions common/config/.golangci-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,15 @@ linters:
enable:
- goimports
- gofumpt
- gci
fast: false

linters-settings:
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(istio.io/) # Groups all imports with the specified Prefix.
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
Expand Down
6 changes: 6 additions & 0 deletions common/config/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ linters:
- unconvert
- unparam
- varcheck
- gci
fast: false

linters-settings:
Expand Down Expand Up @@ -164,6 +165,11 @@ linters-settings:
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
# with golangci-lint call it on a directory with the changed file.
check-exported: false
gci:
sections:
- standard # Captures all standard packages if they do not match another section.
- default # Contains all imports that could not be matched to another section type.
- prefix(istio.io/) # Groups all imports with the specified Prefix.
gocritic:
enabled-checks:
- appendCombine
Expand Down
3 changes: 1 addition & 2 deletions istioctl/cmd/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import (
meshconfig "istio.io/api/mesh/v1alpha1"
networkingv1alpha3 "istio.io/api/networking/v1alpha3"
clientv1alpha3 "istio.io/client-go/pkg/apis/networking/v1alpha3"
"istio.io/pkg/log"

"istio.io/istio/istioctl/pkg/clioptions"
"istio.io/istio/istioctl/pkg/multicluster"
"istio.io/istio/operator/pkg/tpath"
Expand All @@ -53,6 +51,7 @@ import (
"istio.io/istio/pkg/url"
"istio.io/istio/pkg/util/protomarshal"
"istio.io/istio/pkg/util/shellescape"
"istio.io/pkg/log"
)

var (
Expand Down
4 changes: 1 addition & 3 deletions istioctl/pkg/multicluster/remote_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/serializer/json"
"k8s.io/apimachinery/pkg/runtime/serializer/versioning"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"

// to avoid 'No Auth Provider found for name "gcp"'
_ "k8s.io/client-go/plugin/pkg/client/auth"
_ "k8s.io/client-go/plugin/pkg/client/auth" // to avoid 'No Auth Provider found for name "gcp"'
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/tools/clientcmd/api/latest"
Expand Down
4 changes: 1 addition & 3 deletions istioctl/pkg/util/configdump/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import (

adminapi "github.com/envoyproxy/go-control-plane/envoy/admin/v3"
"github.com/golang/protobuf/jsonpb"

// nolint: staticcheck
legacyproto "github.com/golang/protobuf/proto"
legacyproto "github.com/golang/protobuf/proto" // nolint: staticcheck
emptypb "github.com/golang/protobuf/ptypes/empty"
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
Expand Down
4 changes: 1 addition & 3 deletions operator/cmd/mesh/operator-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import (

v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
_ "k8s.io/client-go/plugin/pkg/client/auth"
_ "k8s.io/client-go/plugin/pkg/client/auth" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)

"istio.io/istio/operator/pkg/helm"
"istio.io/istio/operator/pkg/manifest"
Expand Down
4 changes: 1 addition & 3 deletions operator/cmd/operator/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
"go.opencensus.io/stats/view"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
_ "k8s.io/client-go/plugin/pkg/client/auth"
_ "k8s.io/client-go/plugin/pkg/client/auth" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down
4 changes: 1 addition & 3 deletions operator/pkg/util/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (

jsonpatch "github.com/evanphx/json-patch/v5"
"github.com/golang/protobuf/jsonpb"

// nolint: staticcheck
legacyproto "github.com/golang/protobuf/proto"
legacyproto "github.com/golang/protobuf/proto" // nolint: staticcheck
"github.com/kylelemons/godebug/diff"
"google.golang.org/protobuf/proto"
yaml3 "k8s.io/apimachinery/pkg/util/yaml"
Expand Down
8 changes: 2 additions & 6 deletions pilot/pkg/config/kube/crdclient/cache_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ package crdclient
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/informers"

// import GKE cluster authentication plugin
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

// import OIDC cluster authentication plugin, e.g. for Tectonic
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // import GKE cluster authentication plugin
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc" // import OIDC cluster authentication plugin, e.g. for Tectonic
"k8s.io/client-go/tools/cache"

"istio.io/istio/pilot/pkg/model"
Expand Down
8 changes: 2 additions & 6 deletions pilot/pkg/config/kube/crdclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/client-go/informers"

// import GKE cluster authentication plugin
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"

// import OIDC cluster authentication plugin, e.g. for Tectonic
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // import GKE cluster authentication plugin
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc" // import OIDC cluster authentication plugin, e.g. for Tectonic
"k8s.io/client-go/tools/cache"
gatewayapiclient "sigs.k8s.io/gateway-api/pkg/client/clientset/versioned"

Expand Down
4 changes: 1 addition & 3 deletions pilot/pkg/networking/core/v1alpha3/extension/wasmplugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
"istio.io/istio/pilot/pkg/model"
"istio.io/istio/pkg/config/xds"
"istio.io/istio/pkg/util/sets"

// include for registering wasm logging scope
_ "istio.io/istio/pkg/wasm"
_ "istio.io/istio/pkg/wasm" // include for registering wasm logging scope
"istio.io/pkg/log"
)

Expand Down
1 change: 0 additions & 1 deletion pilot/pkg/networking/grpcgen/grpcecho_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"time"

"google.golang.org/grpc"

// To install the xds resolvers and balancers.
_ "google.golang.org/grpc/xds"

Expand Down
4 changes: 1 addition & 3 deletions pilot/pkg/networking/grpcgen/grpcgen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ import (
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/serviceconfig"
"google.golang.org/grpc/status"

// To install the xds resolvers and balancers.
xdsgrpc "google.golang.org/grpc/xds"
xdsgrpc "google.golang.org/grpc/xds" // To install the xds resolvers and balancers.

networking "istio.io/api/networking/v1alpha3"
security "istio.io/api/security/v1beta1"
Expand Down
4 changes: 1 addition & 3 deletions pkg/kube/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/client-go/kubernetes"

// allow out of cluster authentication
_ "k8s.io/client-go/plugin/pkg/client/auth"
_ "k8s.io/client-go/plugin/pkg/client/auth" // allow out of cluster authentication
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"

Expand Down
1 change: 0 additions & 1 deletion pkg/test/echo/cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"time"

"github.com/spf13/cobra"

// To install the xds resolvers and balancers.
_ "google.golang.org/grpc/xds"
wrappers "google.golang.org/protobuf/types/known/wrapperspb"
Expand Down
1 change: 0 additions & 1 deletion pkg/test/echo/cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"syscall"

"github.com/spf13/cobra"

// To install the xds resolvers and balancers.
_ "google.golang.org/grpc/xds"

Expand Down
4 changes: 2 additions & 2 deletions pkg/test/fakes/imageregistry/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import (
"regexp"
"strings"

"istio.io/pkg/log"

"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/partial"
"github.com/google/go-containerregistry/pkg/v1/remote"

"istio.io/pkg/log"
)

var (
Expand Down
2 changes: 0 additions & 2 deletions pkg/test/framework/components/cluster/clusterboot/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import (
"github.com/hashicorp/go-multierror"

"istio.io/istio/pkg/test/framework/components/cluster"

// imported to trigger registration
_ "istio.io/istio/pkg/test/framework/components/cluster/kube"

// imported to trigger registration
_ "istio.io/istio/pkg/test/framework/components/cluster/staticvm"
"istio.io/istio/pkg/test/framework/config"
Expand Down
4 changes: 1 addition & 3 deletions pkg/test/framework/components/echo/deployment/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import (
"istio.io/istio/pkg/test/framework/components/cluster"
"istio.io/istio/pkg/test/framework/components/echo"
"istio.io/istio/pkg/test/framework/components/echo/kube"

// force registraton of factory func
_ "istio.io/istio/pkg/test/framework/components/echo/staticvm"
_ "istio.io/istio/pkg/test/framework/components/echo/staticvm" // force registraton of factory func
"istio.io/istio/pkg/test/framework/components/istio"
"istio.io/istio/pkg/test/framework/components/namespace"
"istio.io/istio/pkg/test/framework/resource"
Expand Down
6 changes: 2 additions & 4 deletions pkg/test/framework/components/echo/kube/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"

"istio.io/istio/pkg/test/util/file"

"istio.io/istio/pkg/test/env"

"istio.io/api/label"
meshconfig "istio.io/api/mesh/v1alpha1"
istioctlcmd "istio.io/istio/istioctl/cmd"
"istio.io/istio/pkg/config/constants"
"istio.io/istio/pkg/config/protocol"
echoCommon "istio.io/istio/pkg/test/echo/common"
"istio.io/istio/pkg/test/env"
"istio.io/istio/pkg/test/framework/components/echo"
"istio.io/istio/pkg/test/framework/components/environment/kube"
"istio.io/istio/pkg/test/framework/components/istio"
Expand All @@ -50,6 +47,7 @@ import (
"istio.io/istio/pkg/test/framework/resource/config/apply"
"istio.io/istio/pkg/test/scopes"
"istio.io/istio/pkg/test/shell"
"istio.io/istio/pkg/test/util/file"
"istio.io/istio/pkg/test/util/retry"
"istio.io/istio/pkg/test/util/tmpl"
"istio.io/istio/pkg/util/protomarshal"
Expand Down
3 changes: 1 addition & 2 deletions pkg/test/util/yml/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ import (
"fmt"
"reflect"

"sigs.k8s.io/yaml"

v1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"sigs.k8s.io/yaml"

"istio.io/istio/pkg/test"
"istio.io/istio/pkg/test/util/tmpl"
Expand Down
4 changes: 1 addition & 3 deletions pkg/util/protomarshal/protomarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import (
"strings"

"github.com/golang/protobuf/jsonpb"

// nolint: staticcheck
legacyproto "github.com/golang/protobuf/proto"
legacyproto "github.com/golang/protobuf/proto" // nolint: staticcheck
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
"sigs.k8s.io/yaml"
Expand Down
4 changes: 1 addition & 3 deletions tests/fuzz/crd_roundtrip_fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (

fuzz "github.com/AdaLogics/go-fuzz-headers"
"github.com/davecgh/go-spew/spew"

// nolint: staticcheck
legacyproto "github.com/golang/protobuf/proto"
legacyproto "github.com/golang/protobuf/proto" // nolint: staticcheck
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/protobuf/testing/protocmp"
Expand Down
1 change: 0 additions & 1 deletion tools/bug-report/pkg/kubeclient/kubeclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package kubeclient

import (
"k8s.io/client-go/kubernetes"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/tools/clientcmd"
Expand Down

0 comments on commit dc3a94f

Please sign in to comment.