Skip to content

Commit 42020a5

Browse files
authored
chore: enable gci linter (#4330)
1 parent fc8c151 commit 42020a5

File tree

135 files changed

+344
-238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+344
-238
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ linters:
1111
#- errchkjson
1212
#- errname
1313
#- gochecknoinits
14-
#- gci
14+
- gci
1515
#- goconst
1616
- gocritic
1717
#- gocyclo

cmd/gitops-server/cmd/cmd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ import (
2424
httpmiddleware "github.com/slok/go-http-metrics/middleware"
2525
httpmiddlewarestd "github.com/slok/go-http-metrics/middleware/std"
2626
"github.com/spf13/cobra"
27+
"k8s.io/client-go/tools/clientcmd"
28+
"sigs.k8s.io/controller-runtime/pkg/client"
29+
"sigs.k8s.io/controller-runtime/pkg/client/config"
30+
k8sMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
31+
2732
"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
2833
"github.com/weaveworks/weave-gitops/core/clustersmngr"
2934
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
@@ -38,10 +43,6 @@ import (
3843
"github.com/weaveworks/weave-gitops/pkg/server/auth"
3944
"github.com/weaveworks/weave-gitops/pkg/server/middleware"
4045
"github.com/weaveworks/weave-gitops/pkg/telemetry"
41-
"k8s.io/client-go/tools/clientcmd"
42-
"sigs.k8s.io/controller-runtime/pkg/client"
43-
"sigs.k8s.io/controller-runtime/pkg/client/config"
44-
k8sMetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
4546
)
4647

4748
const (

cmd/gitops-server/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops-server/cmd"
67
)
78

cmd/gitops/check/cmd.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package check
33
import (
44
"fmt"
55

6+
"github.com/spf13/cobra"
7+
"k8s.io/cli-runtime/pkg/genericclioptions"
8+
"k8s.io/client-go/discovery"
9+
610
"github.com/weaveworks/weave-gitops/cmd/gitops/check/oidcconfig"
711
"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
812
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
913
"github.com/weaveworks/weave-gitops/pkg/run"
1014
"github.com/weaveworks/weave-gitops/pkg/services/check"
11-
"k8s.io/cli-runtime/pkg/genericclioptions"
12-
"k8s.io/client-go/discovery"
13-
14-
"github.com/spf13/cobra"
1515
)
1616

1717
func GetCommand(opts *config.Options) *cobra.Command {

cmd/gitops/create/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"time"
55

66
"github.com/spf13/cobra"
7+
78
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
89
"github.com/weaveworks/weave-gitops/cmd/gitops/create/dashboard"
910
"github.com/weaveworks/weave-gitops/cmd/gitops/create/terraform"

cmd/gitops/create/dashboard/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import (
1010
"time"
1111

1212
"github.com/spf13/cobra"
13+
"k8s.io/cli-runtime/pkg/genericclioptions"
14+
1315
"github.com/weaveworks/weave-gitops/cmd/gitops/cmderrors"
1416
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1517
"github.com/weaveworks/weave-gitops/pkg/kube"
1618
"github.com/weaveworks/weave-gitops/pkg/logger"
1719
"github.com/weaveworks/weave-gitops/pkg/run"
1820
"github.com/weaveworks/weave-gitops/pkg/run/install"
19-
"k8s.io/cli-runtime/pkg/genericclioptions"
2021
)
2122

2223
const (

cmd/gitops/create/terraform/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"github.com/flux-iac/tofu-controller/tfctl"
77
"github.com/spf13/cobra"
88
"github.com/spf13/viper"
9+
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
911
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1012
"github.com/weaveworks/weave-gitops/pkg/run"
11-
"k8s.io/cli-runtime/pkg/genericclioptions"
1213
)
1314

1415
var kubeConfigArgs *genericclioptions.ConfigFlags

cmd/gitops/delete/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package delete
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
67
"github.com/weaveworks/weave-gitops/cmd/gitops/delete/terraform"
78
)

cmd/gitops/delete/terraform/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"github.com/flux-iac/tofu-controller/tfctl"
77
"github.com/spf13/cobra"
88
"github.com/spf13/viper"
9+
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
911
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1012
"github.com/weaveworks/weave-gitops/pkg/run"
11-
"k8s.io/cli-runtime/pkg/genericclioptions"
1213
)
1314

1415
var kubeConfigArgs *genericclioptions.ConfigFlags

cmd/gitops/get/bcrypt/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"os"
77

88
"github.com/spf13/cobra"
9-
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
109
"golang.org/x/crypto/bcrypt"
1110
"golang.org/x/term"
11+
12+
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1213
)
1314

1415
func HashCommand(opts *config.Options) *cobra.Command {

cmd/gitops/get/config/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66

77
"github.com/spf13/cobra"
8+
89
cfg "github.com/weaveworks/weave-gitops/cmd/gitops/config"
910
"github.com/weaveworks/weave-gitops/pkg/config"
1011
"github.com/weaveworks/weave-gitops/pkg/logger"

cmd/gitops/logs/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package logs
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
67
"github.com/weaveworks/weave-gitops/cmd/gitops/logs/terraform"
78
)

cmd/gitops/logs/terraform/cmd.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import (
55
ctx "context"
66
"errors"
77
"fmt"
8-
"github.com/spf13/cobra"
9-
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
10-
"github.com/weaveworks/weave-gitops/pkg/run"
118
"io"
9+
10+
"github.com/spf13/cobra"
1211
corev1 "k8s.io/api/core/v1"
1312
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1413
"k8s.io/cli-runtime/pkg/genericclioptions"
1514
"k8s.io/client-go/kubernetes"
15+
16+
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
17+
"github.com/weaveworks/weave-gitops/pkg/run"
1618
)
1719

1820
var kubeConfigArgs *genericclioptions.ConfigFlags

cmd/gitops/replan/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package replan
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
67
"github.com/weaveworks/weave-gitops/cmd/gitops/replan/terraform"
78
)

cmd/gitops/replan/terraform/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"github.com/flux-iac/tofu-controller/tfctl"
88
"github.com/spf13/cobra"
99
"github.com/spf13/viper"
10+
"k8s.io/cli-runtime/pkg/genericclioptions"
11+
1012
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1113
"github.com/weaveworks/weave-gitops/pkg/run"
12-
"k8s.io/cli-runtime/pkg/genericclioptions"
1314
)
1415

1516
var kubeConfigArgs *genericclioptions.ConfigFlags

cmd/gitops/resume/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package resume
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
67
"github.com/weaveworks/weave-gitops/cmd/gitops/resume/terraform"
78
)

cmd/gitops/resume/terraform/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"github.com/flux-iac/tofu-controller/tfctl"
77
"github.com/spf13/cobra"
88
"github.com/spf13/viper"
9+
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
911
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1012
"github.com/weaveworks/weave-gitops/pkg/run"
11-
"k8s.io/cli-runtime/pkg/genericclioptions"
1213
)
1314

1415
var kubeConfigArgs *genericclioptions.ConfigFlags

cmd/gitops/root/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/manifoldco/promptui"
1111
"github.com/spf13/cobra"
1212
"github.com/spf13/viper"
13+
"k8s.io/client-go/rest"
14+
1315
"github.com/weaveworks/weave-gitops/cmd/gitops/check"
1416
cfg "github.com/weaveworks/weave-gitops/cmd/gitops/config"
1517
"github.com/weaveworks/weave-gitops/cmd/gitops/create"
@@ -26,7 +28,6 @@ import (
2628
"github.com/weaveworks/weave-gitops/pkg/config"
2729
"github.com/weaveworks/weave-gitops/pkg/kube"
2830
"github.com/weaveworks/weave-gitops/pkg/utils"
29-
"k8s.io/client-go/rest"
3031
)
3132

3233
const defaultNamespace = "flux-system"

cmd/gitops/suspend/cmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package suspend
22

33
import (
44
"github.com/spf13/cobra"
5+
56
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
67
"github.com/weaveworks/weave-gitops/cmd/gitops/suspend/terraform"
78
)

cmd/gitops/suspend/terraform/cmd.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import (
66
"github.com/flux-iac/tofu-controller/tfctl"
77
"github.com/spf13/cobra"
88
"github.com/spf13/viper"
9+
"k8s.io/cli-runtime/pkg/genericclioptions"
10+
911
"github.com/weaveworks/weave-gitops/cmd/gitops/config"
1012
"github.com/weaveworks/weave-gitops/pkg/run"
11-
"k8s.io/cli-runtime/pkg/genericclioptions"
1213
)
1314

1415
var kubeConfigArgs *genericclioptions.ConfigFlags

core/clustersmngr/client_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ import (
77
"testing"
88
"time"
99

10-
"github.com/go-logr/logr"
11-
. "github.com/onsi/gomega"
12-
"sigs.k8s.io/controller-runtime/pkg/client"
13-
1410
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1"
1511
"github.com/fluxcd/pkg/apis/meta"
1612
sourcev1 "github.com/fluxcd/source-controller/api/v1"
17-
"github.com/weaveworks/weave-gitops/core/clustersmngr"
18-
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
19-
"github.com/weaveworks/weave-gitops/pkg/kube"
13+
"github.com/go-logr/logr"
14+
. "github.com/onsi/gomega"
2015
corev1 "k8s.io/api/core/v1"
2116
rbacv1 "k8s.io/api/rbac/v1"
2217
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2318
"k8s.io/apimachinery/pkg/labels"
2419
"k8s.io/apimachinery/pkg/types"
2520
"k8s.io/apimachinery/pkg/util/rand"
2621
"k8s.io/client-go/rest"
22+
"sigs.k8s.io/controller-runtime/pkg/client"
23+
24+
"github.com/weaveworks/weave-gitops/core/clustersmngr"
25+
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
26+
"github.com/weaveworks/weave-gitops/pkg/kube"
2727
)
2828

2929
func TestClientGet(t *testing.T) {

core/clustersmngr/cluster/cluster.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ import (
66
"os"
77
"time"
88

9-
"github.com/weaveworks/weave-gitops/pkg/server/auth"
109
"k8s.io/client-go/kubernetes"
1110
"k8s.io/client-go/rest"
1211
"sigs.k8s.io/cli-utils/pkg/flowcontrol"
1312
"sigs.k8s.io/controller-runtime/pkg/client"
13+
14+
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1415
)
1516

1617
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

core/clustersmngr/cluster/delegating_cache.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"fmt"
77
"sync"
88

9-
"github.com/weaveworks/weave-gitops/pkg/server/auth"
109
v1 "k8s.io/api/core/v1"
1110
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1211
"k8s.io/apimachinery/pkg/runtime"
@@ -16,6 +15,8 @@ import (
1615
"sigs.k8s.io/controller-runtime/pkg/cache"
1716
"sigs.k8s.io/controller-runtime/pkg/client"
1817
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
18+
19+
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1920
)
2021

2122
type delegatingCacheCluster struct {

core/clustersmngr/cluster/single.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import (
44
"fmt"
55
"net"
66

7-
"github.com/weaveworks/weave-gitops/pkg/kube"
8-
"github.com/weaveworks/weave-gitops/pkg/server/auth"
97
apiruntime "k8s.io/apimachinery/pkg/runtime"
108
"k8s.io/client-go/kubernetes"
119
"k8s.io/client-go/rest"
1210
"sigs.k8s.io/controller-runtime/pkg/client"
1311
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
12+
13+
"github.com/weaveworks/weave-gitops/pkg/kube"
14+
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1415
)
1516

1617
type singleCluster struct {

core/clustersmngr/cluster/single_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import (
55
"testing"
66

77
. "github.com/onsi/gomega"
8+
"k8s.io/apimachinery/pkg/util/rand"
9+
"k8s.io/client-go/rest"
10+
811
"github.com/weaveworks/weave-gitops/pkg/kube"
912
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1013
"github.com/weaveworks/weave-gitops/pkg/testutils"
11-
"k8s.io/apimachinery/pkg/util/rand"
12-
"k8s.io/client-go/rest"
1314
)
1415

1516
func TestSingleCluster(t *testing.T) {

core/clustersmngr/clustersmngr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ import (
55
"fmt"
66
"sync"
77

8-
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
98
"sigs.k8s.io/controller-runtime/pkg/client"
9+
10+
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
1011
)
1112

1213
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

core/clustersmngr/factory.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ import (
1212
"github.com/go-logr/logr"
1313
"github.com/hashicorp/go-multierror"
1414
"github.com/prometheus/client_golang/prometheus"
15-
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
16-
"github.com/weaveworks/weave-gitops/core/nsaccess"
17-
"github.com/weaveworks/weave-gitops/pkg/featureflags"
18-
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1915
v1 "k8s.io/api/core/v1"
2016
"k8s.io/apimachinery/pkg/util/wait"
2117
"k8s.io/client-go/discovery"
2218
"sigs.k8s.io/controller-runtime/pkg/client"
19+
20+
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
21+
"github.com/weaveworks/weave-gitops/core/nsaccess"
22+
"github.com/weaveworks/weave-gitops/pkg/featureflags"
23+
"github.com/weaveworks/weave-gitops/pkg/server/auth"
2324
)
2425

2526
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate

core/clustersmngr/factory_caches.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import (
77
"sync"
88

99
"github.com/cheshir/ttlcache"
10-
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
11-
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1210
v1 "k8s.io/api/core/v1"
1311
"k8s.io/apimachinery/pkg/util/sets"
1412
"sigs.k8s.io/controller-runtime/pkg/client"
13+
14+
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
15+
"github.com/weaveworks/weave-gitops/pkg/server/auth"
1516
)
1617

1718
type Clusters struct {

core/clustersmngr/factory_caches_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import (
88
"github.com/cheshir/ttlcache"
99
"github.com/google/go-cmp/cmp"
1010
. "github.com/onsi/gomega"
11+
v1 "k8s.io/api/core/v1"
12+
"k8s.io/client-go/rest"
13+
1114
"github.com/weaveworks/weave-gitops/core/clustersmngr"
1215
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
1316
"github.com/weaveworks/weave-gitops/pkg/kube"
1417
"github.com/weaveworks/weave-gitops/pkg/server/auth"
15-
v1 "k8s.io/api/core/v1"
16-
"k8s.io/client-go/rest"
1718
)
1819

1920
func TestUsersNamespaces(t *testing.T) {

0 commit comments

Comments
 (0)