Skip to content

chore: enable gci linter #4330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ linters:
#- errchkjson
#- errname
#- gochecknoinits
#- gci
- gci
#- goconst
- gocritic
#- gocyclo
Expand Down
9 changes: 5 additions & 4 deletions cmd/gitops-server/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
httpmiddleware "github.com/slok/go-http-metrics/middleware"
httpmiddlewarestd "github.com/slok/go-http-metrics/middleware/std"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
k8sMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"

"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
"github.com/weaveworks/weave-gitops/core/clustersmngr"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
Expand All @@ -38,10 +43,6 @@ import (
"github.com/weaveworks/weave-gitops/pkg/server/auth"
"github.com/weaveworks/weave-gitops/pkg/server/middleware"
"github.com/weaveworks/weave-gitops/pkg/telemetry"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/config"
k8sMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
)

const (
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops-server/cmd"
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/gitops/check/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package check
import (
"fmt"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/discovery"

"github.com/weaveworks/weave-gitops/cmd/gitops/check/oidcconfig"
"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"github.com/weaveworks/weave-gitops/pkg/services/check"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/discovery"

"github.com/spf13/cobra"
)

func GetCommand(opts *config.Options) *cobra.Command {
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/create/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/create/dashboard"
"github.com/weaveworks/weave-gitops/cmd/gitops/create/terraform"
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/create/dashboard/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"time"

"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/logger"
"github.com/weaveworks/weave-gitops/pkg/run"
"github.com/weaveworks/weave-gitops/pkg/run/install"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/create/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/flux-iac/tofu-controller/tfctl"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/delete/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package delete

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/delete/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/delete/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/flux-iac/tofu-controller/tfctl"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/get/bcrypt/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"os"

"github.com/spf13/cobra"
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"golang.org/x/crypto/bcrypt"
"golang.org/x/term"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
)

func HashCommand(opts *config.Options) *cobra.Command {
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/get/config/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/spf13/cobra"

cfg "github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/config"
"github.com/weaveworks/weave-gitops/pkg/logger"
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/logs/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package logs

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/logs/terraform"
)
Expand Down
8 changes: 5 additions & 3 deletions cmd/gitops/logs/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
ctx "context"
"errors"
"fmt"
"github.com/spf13/cobra"
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"io"

"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/replan/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package replan

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/replan/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/replan/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"github.com/flux-iac/tofu-controller/tfctl"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/resume/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package resume

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/resume/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/resume/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/flux-iac/tofu-controller/tfctl"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/root/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/manifoldco/promptui"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/client-go/rest"

"github.com/weaveworks/weave-gitops/cmd/gitops/check"
cfg "github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/create"
Expand All @@ -26,7 +28,6 @@ import (
"github.com/weaveworks/weave-gitops/pkg/config"
"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/utils"
"k8s.io/client-go/rest"
)

const defaultNamespace = "flux-system"
Expand Down
1 change: 1 addition & 0 deletions cmd/gitops/suspend/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package suspend

import (
"github.com/spf13/cobra"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/cmd/gitops/suspend/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion cmd/gitops/suspend/terraform/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"github.com/flux-iac/tofu-controller/tfctl"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"k8s.io/cli-runtime/pkg/genericclioptions"

"github.com/weaveworks/weave-gitops/cmd/gitops/config"
"github.com/weaveworks/weave-gitops/pkg/run"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var kubeConfigArgs *genericclioptions.ConfigFlags
Expand Down
14 changes: 7 additions & 7 deletions core/clustersmngr/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"testing"
"time"

"github.com/go-logr/logr"
. "github.com/onsi/gomega"
"sigs.k8s.io/controller-runtime/pkg/client"

kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
"github.com/fluxcd/pkg/apis/meta"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/weaveworks/weave-gitops/core/clustersmngr"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/go-logr/logr"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops/core/clustersmngr"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/kube"
)

func TestClientGet(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion core/clustersmngr/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"os"
"time"

"github.com/weaveworks/weave-gitops/pkg/server/auth"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"sigs.k8s.io/cli-utils/pkg/flowcontrol"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops/pkg/server/auth"
)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
Expand Down
3 changes: 2 additions & 1 deletion core/clustersmngr/cluster/delegating_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"sync"

"github.com/weaveworks/weave-gitops/pkg/server/auth"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -16,6 +15,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

"github.com/weaveworks/weave-gitops/pkg/server/auth"
)

type delegatingCacheCluster struct {
Expand Down
5 changes: 3 additions & 2 deletions core/clustersmngr/cluster/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"
"net"

"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
apiruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
)

type singleCluster struct {
Expand Down
5 changes: 3 additions & 2 deletions core/clustersmngr/cluster/single_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"testing"

. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/rest"

"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
"github.com/weaveworks/weave-gitops/pkg/testutils"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/client-go/rest"
)

func TestSingleCluster(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion core/clustersmngr/clustersmngr.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"fmt"
"sync"

"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
Expand Down
9 changes: 5 additions & 4 deletions core/clustersmngr/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ import (
"github.com/go-logr/logr"
"github.com/hashicorp/go-multierror"
"github.com/prometheus/client_golang/prometheus"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/core/nsaccess"
"github.com/weaveworks/weave-gitops/pkg/featureflags"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/core/nsaccess"
"github.com/weaveworks/weave-gitops/pkg/featureflags"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
)

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
Expand Down
5 changes: 3 additions & 2 deletions core/clustersmngr/factory_caches.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"sync"

"github.com/cheshir/ttlcache"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
)

type Clusters struct {
Expand Down
5 changes: 3 additions & 2 deletions core/clustersmngr/factory_caches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import (
"github.com/cheshir/ttlcache"
"github.com/google/go-cmp/cmp"
. "github.com/onsi/gomega"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/rest"

"github.com/weaveworks/weave-gitops/core/clustersmngr"
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
"github.com/weaveworks/weave-gitops/pkg/kube"
"github.com/weaveworks/weave-gitops/pkg/server/auth"
v1 "k8s.io/api/core/v1"
"k8s.io/client-go/rest"
)

func TestUsersNamespaces(t *testing.T) {
Expand Down
Loading
Loading