Skip to content

Commit 0c5a145

Browse files
committed
Make linter happy
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
1 parent 5403b31 commit 0c5a145

File tree

17 files changed

+87
-87
lines changed

17 files changed

+87
-87
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ jobs:
2121
matrix:
2222
working-directory:
2323
- ""
24-
- tools/setup-envtest
24+
- examples/kind
25+
- providers/kind
2526
steps:
2627
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
2728
- name: Calculate go version

Makefile

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ TOOLS_BIN_DIR := $(abspath $(TOOLS_DIR)/bin)
5252
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
5353
GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff
5454
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
55-
ENVTEST_DIR := $(abspath tools/setup-envtest)
56-
SCRATCH_ENV_DIR := $(abspath examples/scratch-env)
55+
EXAMPLES_KIND_DIR := $(abspath examples/kind)
56+
PROVIDERS_KIND_DIR := $(abspath providers/kind)
5757
GO_INSTALL := ./hack/go-install.sh
5858

5959
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
@@ -73,8 +73,7 @@ test: test-tools ## Run the script check-everything.sh which will check all.
7373
TRACE=1 ./hack/check-everything.sh
7474

7575
.PHONY: test-tools
76-
test-tools: ## tests the tools codebase (setup-envtest)
77-
cd tools/setup-envtest && go test ./...
76+
test-tools:
7877

7978
## --------------------------------------
8079
## Binaries
@@ -118,7 +117,8 @@ $(GO_MOD_CHECK): # Build gomodcheck
118117
.PHONY: lint
119118
lint: $(GOLANGCI_LINT) ## Lint codebase
120119
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
121-
cd tools/setup-envtest; $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
120+
cd examples/kind; $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
121+
cd proviers/kind; $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
122122

123123
.PHONY: lint-fix
124124
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter.
@@ -132,50 +132,8 @@ lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported
132132
modules: ## Runs go mod to ensure modules are up to date.
133133
go mod tidy
134134
cd $(TOOLS_DIR); go mod tidy
135-
cd $(ENVTEST_DIR); go mod tidy
136-
cd $(SCRATCH_ENV_DIR); go mod tidy
137-
138-
## --------------------------------------
139-
## Release
140-
## --------------------------------------
141-
142-
RELEASE_DIR := tools/setup-envtest/out
143-
144-
.PHONY: $(RELEASE_DIR)
145-
$(RELEASE_DIR):
146-
mkdir -p $(RELEASE_DIR)/
147-
148-
.PHONY: release
149-
release: clean-release $(RELEASE_DIR) ## Build release.
150-
@if ! [ -z "$$(git status --porcelain)" ]; then echo "Your local git repository contains uncommitted changes, use git clean before proceeding."; exit 1; fi
151-
152-
# Build binaries first.
153-
$(MAKE) release-binaries
154-
155-
.PHONY: release-binaries
156-
release-binaries: ## Build release binaries.
157-
RELEASE_BINARY=setup-envtest-linux-amd64 GOOS=linux GOARCH=amd64 $(MAKE) release-binary
158-
RELEASE_BINARY=setup-envtest-linux-arm64 GOOS=linux GOARCH=arm64 $(MAKE) release-binary
159-
RELEASE_BINARY=setup-envtest-linux-ppc64le GOOS=linux GOARCH=ppc64le $(MAKE) release-binary
160-
RELEASE_BINARY=setup-envtest-linux-s390x GOOS=linux GOARCH=s390x $(MAKE) release-binary
161-
RELEASE_BINARY=setup-envtest-darwin-amd64 GOOS=darwin GOARCH=amd64 $(MAKE) release-binary
162-
RELEASE_BINARY=setup-envtest-darwin-arm64 GOOS=darwin GOARCH=arm64 $(MAKE) release-binary
163-
RELEASE_BINARY=setup-envtest-windows-amd64.exe GOOS=windows GOARCH=amd64 $(MAKE) release-binary
164-
165-
.PHONY: release-binary
166-
release-binary: $(RELEASE_DIR)
167-
docker run \
168-
--rm \
169-
-e CGO_ENABLED=0 \
170-
-e GOOS=$(GOOS) \
171-
-e GOARCH=$(GOARCH) \
172-
-e GOCACHE=/tmp/ \
173-
--user $$(id -u):$$(id -g) \
174-
-v "$$(pwd):/workspace$(DOCKER_VOL_OPTS)" \
175-
-w /workspace/tools/setup-envtest \
176-
golang:$(GO_VERSION) \
177-
go build -a -trimpath -ldflags "-extldflags '-static'" \
178-
-o ./out/$(RELEASE_BINARY) ./
135+
cd $(EXAMPLES_KIND_DIR); go mod tidy
136+
cd $(PROVIDERS_KIND_DIR); go mod tidy
179137

180138
## --------------------------------------
181139
## Cleanup / Verification
@@ -196,7 +154,7 @@ clean-release: ## Remove the release folder
196154

197155
.PHONY: verify-modules
198156
verify-modules: modules $(GO_MOD_CHECK) ## Verify go modules are up to date
199-
@if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(ENVTEST_DIR)/go.mod $(ENVTEST_DIR)/go.sum $(SCRATCH_ENV_DIR)/go.sum); then \
157+
@if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(EXAMPLES_KIND_DIR)/go.mod $(EXAMPLES_KIND_DIR)/go.sum $(PROVIDERS_KIND_DIR)/go.mod $(PROVIDERS_KIND_DIR)/go.sum); then \
200158
git diff; \
201159
echo "go module files are out of date, please run 'make modules'"; exit 1; \
202160
fi

examples/kind/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func main() {
6666
mgr, err := mcmanager.New(cfg, provider, manager.Options{})
6767
if err != nil {
6868
entryLog.Error(err, "unable to set up overall controller manager")
69-
os.Exit(1)
69+
os.Exit(1) //nolint:gocritic // We want to return an error RC.
7070
}
7171

7272
if err := mcbuilder.ControllerManagedBy(mgr).

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ require (
66
github.com/go-logr/logr v1.4.2
77
github.com/onsi/ginkgo/v2 v2.21.0
88
github.com/onsi/gomega v1.35.1
9+
github.com/spf13/pflag v1.0.5
10+
go.uber.org/zap v1.27.0
11+
golang.org/x/mod v0.21.0
12+
golang.org/x/sync v0.8.0
913
golang.org/x/sys v0.26.0
1014
k8s.io/api v0.32.0
1115
k8s.io/apiextensions-apiserver v0.32.0
@@ -14,6 +18,7 @@ require (
1418
k8s.io/klog/v2 v2.130.1
1519
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
1620
sigs.k8s.io/controller-runtime v0.20.1
21+
sigs.k8s.io/yaml v1.4.0
1722
)
1823

1924
require (
@@ -48,13 +53,10 @@ require (
4853
github.com/prometheus/client_model v0.6.1 // indirect
4954
github.com/prometheus/common v0.55.0 // indirect
5055
github.com/prometheus/procfs v0.15.1 // indirect
51-
github.com/spf13/pflag v1.0.5 // indirect
5256
github.com/x448/float16 v0.8.4 // indirect
5357
go.uber.org/multierr v1.11.0 // indirect
54-
go.uber.org/zap v1.27.0 // indirect
5558
golang.org/x/net v0.30.0 // indirect
5659
golang.org/x/oauth2 v0.23.0 // indirect
57-
golang.org/x/sync v0.8.0 // indirect
5860
golang.org/x/term v0.25.0 // indirect
5961
golang.org/x/text v0.19.0 // indirect
6062
golang.org/x/time v0.7.0 // indirect
@@ -67,5 +69,4 @@ require (
6769
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
6870
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
6971
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
70-
sigs.k8s.io/yaml v1.4.0 // indirect
7172
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
116116
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
117117
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
118118
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
119+
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
120+
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
119121
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
120122
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
121123
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=

internal/forked/testing/addr/manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
2525

26-
"sigs.k8s.io/controller-runtime/pkg/internal/testing/addr"
26+
"github.com/multicluster-runtime/multicluster-runtime/internal/forked/testing/addr"
2727
)
2828

2929
var _ = Describe("SuggestAddress", func() {

pkg/builder/forked_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/go-logr/logr"
2626
. "github.com/onsi/ginkgo/v2"
2727
. "github.com/onsi/gomega"
28-
2928
appsv1 "k8s.io/api/apps/v1"
3029
corev1 "k8s.io/api/core/v1"
3130
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -35,6 +34,7 @@ import (
3534
"k8s.io/client-go/rest"
3635
"k8s.io/client-go/util/workqueue"
3736
"k8s.io/utils/ptr"
37+
"sigs.k8s.io/controller-runtime/pkg/source"
3838

3939
"sigs.k8s.io/controller-runtime/pkg/cache"
4040
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -219,7 +219,7 @@ var _ = Describe("application", func() {
219219

220220
instance, err := TypedControllerManagedBy[mcreconcile.WithCluster[empty]](m).
221221
Named("my_controller-1").
222-
WatchesRawSource(must(
222+
WatchesRawSource(must[source.TypedSource[mcreconcile.WithCluster[empty]]](
223223
mcsource.TypedKind(
224224
&appsv1.ReplicaSet{},
225225
mchandler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, rs *appsv1.ReplicaSet) []mcreconcile.WithCluster[empty] {

pkg/builder/multicluster_options.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ limitations under the License.
1616

1717
package builder
1818

19+
// EngageOptions configures how the controller should engage with clusters
20+
// when a provider is configured.
1921
type EngageOptions struct {
2022
engageWithLocalCluster *bool
2123
engageWithProviderClusters *bool

pkg/controller/controller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,12 @@ func (c *mcController[request]) Engage(ctx context.Context, name string, cl clus
117117
return nil
118118
}
119119

120-
ctx, cancel := context.WithCancel(ctx)
120+
ctx, cancel := context.WithCancel(ctx) //nolint:govet // cancel is called in the error case only.
121121

122122
// pass through in case the controller itself is cluster aware
123123
if ctrl, ok := c.TypedController.(multicluster.Aware); ok {
124124
if err := ctrl.Engage(ctx, name, cl); err != nil {
125+
cancel()
125126
return err
126127
}
127128
}
@@ -152,14 +153,14 @@ func (c *mcController[request]) Engage(ctx context.Context, name string, cl clus
152153
}
153154
}()
154155

155-
return nil
156+
return nil //nolint:govet // cancel is called in the error case only.
156157
}
157158

158159
func (c *mcController[request]) MultiClusterWatch(src mcsource.TypedSource[client.Object, request]) error {
159160
c.lock.Lock()
160161
defer c.lock.Unlock()
161162

162-
ctx, cancel := context.WithCancel(context.Background())
163+
ctx, cancel := context.WithCancel(context.Background()) //nolint:govet // cancel is called in the error case only.
163164

164165
for name, eng := range c.clusters {
165166
src, err := src.ForCluster(name, eng.cluster)
@@ -175,7 +176,7 @@ func (c *mcController[request]) MultiClusterWatch(src mcsource.TypedSource[clien
175176

176177
c.sources = append(c.sources, src)
177178

178-
return nil
179+
return nil //nolint:govet // cancel is called in the error case only.
179180
}
180181

181182
func startWithinContext[request mcreconcile.ClusterAware[request]](ctx context.Context, src source.TypedSource[request]) source.TypedSource[request] {

pkg/handler/lift.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
type EventHandlerFunc = func(string, cluster.Cluster) EventHandler
3636

3737
// TypedEventHandlerFunc produces a handler.TypedEventHandler for a cluster.
38-
type TypedEventHandlerFunc[object client.Object, request mcreconcile.ClusterAware[request]] = func(string, cluster.Cluster) handler.TypedEventHandler[object, request]
38+
type TypedEventHandlerFunc[object client.Object, request mcreconcile.ClusterAware[request]] func(string, cluster.Cluster) handler.TypedEventHandler[object, request]
3939

4040
// ForCluster wraps a handler.EventHandler without multi-cluster support for one
4141
// concrete cluster.

0 commit comments

Comments
 (0)