Skip to content
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
13 changes: 13 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ linters:
- errchkjson
- errorlint
- exhaustive
- gci
- ginkgolinter
- goconst
- gocritic
Expand Down Expand Up @@ -53,6 +54,18 @@ linters:
- whitespace

linters-settings:
gci:
custom-order: true
sections:
- standard
- default
- prefix(k8s.io,sigs.k8s.io)
- prefix(github.com/kcp-dev)
- prefix(github.com/multicluster-runtime)
- prefix(github.com/kcp-dev/multicluster-provider)
- blank
- dot
skip-generated: true
govet:
enable-all: true
disable:
Expand Down
21 changes: 9 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ $(GOLANGCI_LINT):
golangci-lint \
${GOLANGCI_LINT_VERSION}

GIMPS = _tools/gimps
GIMPS_VERSION = 0.6.0

.PHONY: $(GIMPS)
$(GIMPS):
@hack/download-tool.sh \
https://github.com/xrstf/gimps/releases/download/v${GIMPS_VERSION}/gimps_${GIMPS_VERSION}_${GOOS}_${GOARCH}.tar.gz \
gimps \
${GIMPS_VERSION}

WWHRD = _tools/wwhrd
WWHRD_VERSION = 0.4.0

Expand Down Expand Up @@ -100,8 +90,15 @@ lint: $(GOLANGCI_LINT)
./...

.PHONY: imports
imports: $(GIMPS)
$(GIMPS) .
imports: WHAT ?=
imports: $(GOLANGCI_LINT)
@if [ -n "$(WHAT)" ]; then \
$(GOLANGCI_LINT) run --enable-only=gci --fix --fast $(WHAT); \
else \
for MOD in . $$(git ls-files '**/go.mod' | sed 's,/go.mod,,'); do \
(cd $$MOD; $(GOLANGCI_LINT) run --enable-only=gci --fix --fast); \
done; \
fi

.PHONY: verify
verify:
Expand Down
4 changes: 2 additions & 2 deletions virtualworkspace/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import (
"fmt"
"time"

"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/runtime/schema"
toolscache "k8s.io/client-go/tools/cache"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/kcp-dev/logicalcluster/v3"
)

var _ cache.Cache = &scopedCache{}
Expand Down
4 changes: 2 additions & 2 deletions virtualworkspace/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"net/http"
"net/url"

"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/rest"
Expand All @@ -33,6 +31,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/cluster"

"github.com/kcp-dev/logicalcluster/v3"
)

func newScopedCluster(cfg *rest.Config, clusterName logicalcluster.Name, wildcardCA WildcardCache, scheme *runtime.Scheme) (*scopedCluster, error) {
Expand Down
6 changes: 3 additions & 3 deletions virtualworkspace/forked_cache_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import (
"fmt"
"reflect"

kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
"github.com/kcp-dev/logicalcluster/v3"

apierrors "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/fields"
Expand All @@ -36,6 +33,9 @@ import (
"k8s.io/apimachinery/pkg/selection"
"k8s.io/client-go/tools/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
"github.com/kcp-dev/logicalcluster/v3"
)

// cacheReader is a client.Reader.
Expand Down
4 changes: 2 additions & 2 deletions virtualworkspace/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package virtualworkspace
import (
"fmt"

"github.com/kcp-dev/logicalcluster/v3"

"k8s.io/apimachinery/pkg/api/meta"

"github.com/kcp-dev/logicalcluster/v3"
)

// ClusterIndexFunc indexes by cluster name.
Expand Down
3 changes: 2 additions & 1 deletion virtualworkspace/indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package virtualworkspace
import (
"testing"

"github.com/kcp-dev/logicalcluster/v3"
"github.com/stretchr/testify/require"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/kcp-dev/logicalcluster/v3"
)

func TestClusterIndexFunc(t *testing.T) {
Expand Down
11 changes: 6 additions & 5 deletions virtualworkspace/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,8 @@ import (
"time"

"github.com/go-logr/logr"
kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
"github.com/kcp-dev/logicalcluster/v3"
"golang.org/x/sync/errgroup"

mcmanager "github.com/multicluster-runtime/multicluster-runtime/pkg/manager"
"github.com/multicluster-runtime/multicluster-runtime/pkg/multicluster"

"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand All @@ -39,6 +34,12 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/cluster"
"sigs.k8s.io/controller-runtime/pkg/log"

kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
"github.com/kcp-dev/logicalcluster/v3"

mcmanager "github.com/multicluster-runtime/multicluster-runtime/pkg/manager"
"github.com/multicluster-runtime/multicluster-runtime/pkg/multicluster"
)

var _ multicluster.Provider = &Provider{}
Expand Down
8 changes: 4 additions & 4 deletions virtualworkspace/wildcard.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import (
"sync"
"time"

kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers"
"github.com/kcp-dev/logicalcluster/v3"

apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -38,6 +34,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"

kcpcache "github.com/kcp-dev/apimachinery/v2/pkg/cache"
kcpinformers "github.com/kcp-dev/apimachinery/v2/third_party/informers"
"github.com/kcp-dev/logicalcluster/v3"
)

// WildcardCache is a cache that operates on a /clusters/* endpoint.
Expand Down