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
90 changes: 52 additions & 38 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: "2"
run:
timeout: 10m
allow-parallel-runners: true

linters:
disable-all: true
default: none
enable:
- asasalint
- asciicheck
Expand All @@ -17,10 +16,8 @@ linters:
- errchkjson
- gocritic
- godot
- gofmt
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
Expand All @@ -36,39 +33,56 @@ linters:
- unused
- usestdlibvars
- whitespace

linters-settings:
goconst:
ignore-tests: true
nolintlint:
allow-unused: false
allow-leading-space: false
require-specific: true
revive:
# make sure error-strings issues actually surface (default confidence is 0.8)
confidence: 0.6
settings:
nolintlint:
require-specific: true
allow-unused: false
revive:
confidence: 0.6
rules:
- name: context-keys-type
- name: duplicated-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: errorf
- name: superfluous-else
- name: unreachable-code
- name: bool-literal-in-expr
- name: constant-logical-expr
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- name: context-keys-type
- name: duplicated-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: if-return
- name: increment-decrement
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: errorf
- name: superfluous-else
- name: unreachable-code
- name: bool-literal-in-expr
- name: constant-logical-expr

- linters:
- goconst
path: (.+)_test\.go
paths:
- pkg/client
- third_party$
- builtin$
- examples$
issues:
exclude-dirs:
- pkg/client

max-same-issues: 0
max-issues-per-linter: 0
max-same-issues: 0
formatters:
enable:
- gofmt
exclusions:
generated: lax
paths:
- pkg/client
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ OPENSHIFT_GOIMPORTS_BIN := openshift-goimports
OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER)
export OPENSHIFT_GOIMPORTS # so hack scripts can use it

GOLANGCI_LINT_VER := v1.63.1
GOLANGCI_LINT_VER := v2.1.6
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

Expand Down Expand Up @@ -142,7 +142,7 @@ install: ## install binaries to GOBIN
.PHONY: install

$(GOLANGCI_LINT):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/v2/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER)

$(LOGCHECK):
GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/logtools/logcheck $(LOGCHECK_BIN) $(LOGCHECK_VER)
Expand Down
8 changes: 4 additions & 4 deletions contrib/example-backend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ func (s *Server) Run(ctx context.Context) error {
}

// start controllers
go s.Controllers.ServiceExport.Start(ctx, 1)
go s.Controllers.ServiceNamespace.Start(ctx, 1)
go s.Controllers.ClusterBinding.Start(ctx, 1)
go s.Controllers.ServiceExportRequest.Start(ctx, 1)
go s.ServiceExport.Start(ctx, 1)
go s.ServiceNamespace.Start(ctx, 1)
go s.ClusterBinding.Start(ctx, 1)
go s.ServiceExportRequest.Start(ctx, 1)

go func() {
<-ctx.Done()
Expand Down
4 changes: 2 additions & 2 deletions pkg/indexers/serviceexportrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func IndexServiceExportRequestByGroupResource(obj interface{}) ([]string, error)
}
keys := []string{}
for _, gr := range sbr.Spec.Resources {
keys = append(keys, gr.GroupResource.Resource+"."+gr.GroupResource.Group)
keys = append(keys, gr.Resource+"."+gr.Group)
}
return keys, nil
}
Expand All @@ -44,7 +44,7 @@ func IndexServiceExportRequestByServiceExport(obj interface{}) ([]string, error)
}
keys := []string{}
for _, gr := range sbr.Spec.Resources {
keys = append(keys, sbr.Namespace+"/"+gr.GroupResource.Resource+"."+gr.GroupResource.Group)
keys = append(keys, sbr.Namespace+"/"+gr.Resource+"."+gr.Group)
}
return keys, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (c *controller) enqueueServiceBinding(logger klog.Logger, obj interface{})
}

func (c *controller) enqueueServiceExport(logger klog.Logger, _ interface{}) {
bindings, err := c.serviceBindingInformer.Informer().GetIndexer().ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.reconciler.consumerSecretRefKey)
bindings, err := c.serviceBindingInformer.Informer().GetIndexer().ByIndex(indexers.ByServiceBindingKubeconfigSecret, c.consumerSecretRefKey)
if err != nil {
runtime.HandleError(err)
return
Expand All @@ -189,7 +189,7 @@ func (c *controller) enqueueServiceExport(logger klog.Logger, _ interface{}) {
runtime.HandleError(err)
return
}
logger.V(2).Info("queueing APIServiceBinding", "key", key, "reason", "APIServiceExport", "ServiceExportKey", c.reconciler.consumerSecretRefKey)
logger.V(2).Info("queueing APIServiceBinding", "key", key, "reason", "APIServiceExport", "ServiceExportKey", c.consumerSecretRefKey)
c.queue.Add(key)
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/framework/kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ func NewWorkspace(t *testing.T, config *rest.Config, options ...ClusterWorkspace
}

// workaround broken GenerateName for workspaces: https://github.com/kcp-dev/kcp/pull/2193
ws.ObjectMeta.Name = ws.ObjectMeta.GenerateName
ws.ObjectMeta.GenerateName = ""
ws.Name = ws.GenerateName
ws.GenerateName = ""
token := make([]byte, 4)
rand.Read(token) //nolint:errcheck
base36hash := strings.ToLower(base36.EncodeBytes(token))
Expand Down