Skip to content

Commit 0ddc03e

Browse files
authored
Merge branch 'main' into fix/build-submodule
2 parents 0dddef0 + c80f299 commit 0ddc03e

33 files changed

Lines changed: 175 additions & 226 deletions

File tree

.golangci.yml

Lines changed: 108 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,172 +1,119 @@
1-
run:
2-
timeout: 2m
3-
4-
linters-settings:
5-
errcheck:
6-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
7-
# default is false: such cases aren't reported by default.
8-
check-type-assertions: false
9-
10-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
11-
# default is false: such cases aren't reported by default.
12-
check-blank: false
13-
14-
exclude-functions:
15-
- fmt:.*,io
16-
- ioutil:^Read.*
17-
18-
govet:
19-
disable:
20-
- shadow
21-
22-
gofmt:
23-
# simplify code: gofmt with `-s` option, true by default
24-
simplify: true
25-
26-
goimports:
27-
# put imports beginning with prefix after 3rd-party packages;
28-
# it's a comma-separated list of prefixes
29-
local-prefixes: github.com/SAP/crossplane-provider-cloudfoundry
30-
31-
gocyclo:
32-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
33-
min-complexity: 10
34-
35-
dupl:
36-
# tokens count to trigger issue, 150 by default
37-
threshold: 100
38-
39-
goconst:
40-
# minimal length of string constant, 3 by default
41-
min-len: 3
42-
# minimal occurrences count to trigger, 3 by default
43-
min-occurrences: 5
44-
45-
lll:
46-
# tab width in spaces. Default to 1.
47-
tab-width: 1
48-
49-
unparam:
50-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
51-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
52-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
53-
# with golangci-lint call it on a directory with the changed file.
54-
check-exported: false
55-
56-
nakedret:
57-
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
58-
max-func-lines: 30
59-
60-
prealloc:
61-
# XXX: we don't recommend using this linter before doing performance profiling.
62-
# For most programs usage of prealloc will be a premature optimization.
63-
64-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
65-
# True by default.
66-
simple: true
67-
range-loops: true # Report preallocation suggestions on range loops, true by default
68-
for-loops: false # Report preallocation suggestions on for loops, false by default
69-
70-
gocritic:
71-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
72-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
73-
enabled-tags:
74-
- performance
75-
76-
settings: # settings passed to gocritic
77-
captLocal: # must be valid enabled check name
78-
paramsOnly: true
79-
rangeValCopy:
80-
sizeThreshold: 32
81-
1+
version: "2"
822
linters:
833
enable:
4+
- asasalint
5+
- asciicheck
6+
- bidichk
7+
- bodyclose
8+
- contextcheck
9+
- durationcheck
10+
- errchkjson
11+
- errorlint
12+
- exhaustive
13+
- gocheckcompilerdirectives
14+
- gochecksumtype
8415
- goconst
8516
- gocritic
8617
- gocyclo
87-
- gofmt # We enable this as well as goimports for its simplify mode.
88-
- goimports
89-
- gosimple
90-
- govet
18+
- gosec
19+
- gosmopolitan
20+
- loggercheck
21+
- makezero
9122
- misspell
23+
- musttag
9224
- nakedret
25+
- nilerr
26+
- nilnesserr
27+
- noctx
9328
- prealloc
94-
- staticcheck
29+
- protogetter
30+
- reassign
31+
- recvcheck
32+
- rowserrcheck
33+
- spancheck
34+
- sqlclosecheck
35+
- testifylint
9536
- unconvert
96-
- unused
97-
98-
presets:
99-
- bugs
100-
- unused
101-
fast: false
102-
103-
37+
- unparam
38+
- zerologlint
39+
settings:
40+
dupl:
41+
threshold: 100
42+
errcheck:
43+
check-type-assertions: false
44+
check-blank: false
45+
goconst:
46+
min-len: 3
47+
min-occurrences: 5
48+
gocritic:
49+
enabled-tags:
50+
- performance
51+
settings:
52+
captLocal:
53+
paramsOnly: true
54+
rangeValCopy:
55+
sizeThreshold: 32
56+
gocyclo:
57+
min-complexity: 10
58+
lll:
59+
tab-width: 1
60+
nakedret:
61+
max-func-lines: 30
62+
prealloc:
63+
simple: true
64+
range-loops: true
65+
for-loops: false
66+
unparam:
67+
check-exported: false
68+
exclusions:
69+
generated: lax
70+
rules:
71+
- linters:
72+
- dupl
73+
- errcheck
74+
- exportloopref
75+
- gocyclo
76+
- gosec
77+
- unparam
78+
path: _test(ing)?\.go
79+
- linters:
80+
- gocritic
81+
path: _test\.go
82+
text: (unnamedResult|exitAfterDefer)
83+
- linters:
84+
- gocritic
85+
text: '(hugeParam|rangeValCopy):'
86+
- linters:
87+
- staticcheck
88+
text: 'SA3000:'
89+
- linters:
90+
- gosec
91+
text: 'G101:'
92+
- linters:
93+
- gosec
94+
text: 'G104:'
95+
paths:
96+
- zz_generated\..+\.go$
97+
- third_party$
98+
- builtin$
99+
- examples$
104100
issues:
105-
# Excluding configuration per-path and per-linter
106-
exclude-rules:
107-
# Exclude some linters from running on tests files.
108-
- path: _test(ing)?\.go
109-
linters:
110-
- gocyclo
111-
- errcheck
112-
- dupl
113-
- gosec
114-
- exportloopref
115-
- unparam
116-
117-
# Ease some gocritic warnings on test files.
118-
- path: _test\.go
119-
text: "(unnamedResult|exitAfterDefer)"
120-
linters:
121-
- gocritic
122-
123-
# These are performance optimisations rather than style issues per se.
124-
# They warn when function arguments or range values copy a lot of memory
125-
# rather than using a pointer.
126-
- text: "(hugeParam|rangeValCopy):"
127-
linters:
128-
- gocritic
129-
130-
# This "TestMain should call os.Exit to set exit code" warning is not clever
131-
# enough to notice that we call a helper method that calls os.Exit.
132-
- text: "SA3000:"
133-
linters:
134-
- staticcheck
135-
136-
- text: "k8s.io/api/core/v1"
137-
linters:
138-
- goimports
139-
140-
# This is a "potential hardcoded credentials" warning. It's triggered by
141-
# any variable with 'secret' in the same, and thus hits a lot of false
142-
# positives in Kubernetes land where a Secret is an object type.
143-
- text: "G101:"
144-
linters:
145-
- gosec
146-
- gas
147-
148-
# This is an 'errors unhandled' warning that duplicates errcheck.
149-
- text: "G104:"
150-
linters:
151-
- gosec
152-
- gas
153-
154-
# Independently from option `exclude` we use default exclude patterns,
155-
# it can be disabled by this option. To list all
156-
# excluded by default patterns execute `golangci-lint run --help`.
157-
# Default value for this option is true.
158-
exclude-use-default: false
159-
160-
# Show only new issues: if there are unstaged changes or untracked files,
161-
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
162-
# It's a super-useful option for integration of golangci-lint into existing
163-
# large codebase. It's not practical to fix all existing issues at the moment
164-
# of integration: much better don't allow issues in new code.
165-
# Default is false.
166-
new: false
167-
168-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
169101
max-same-issues: 0
170-
171-
exclude-files:
172-
- "zz_generated\\..+\\.go$"
102+
new: false
103+
formatters:
104+
enable:
105+
- gofmt
106+
- goimports
107+
settings:
108+
gofmt:
109+
simplify: true
110+
goimports:
111+
local-prefixes:
112+
- github.com/SAP/crossplane-provider-cloudfoundry
113+
exclusions:
114+
generated: lax
115+
paths:
116+
- zz_generated\..+\.go$
117+
- third_party$
118+
- builtin$
119+
- examples$

Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider $(GO_PROJECT)/cmd/exporter
3737
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION)
3838
GO_SUBDIRS += cmd internal apis
3939
GO111MODULE = on
40-
GOLANGCILINT_VERSION ?= 1.64.5
40+
GOLANGCILINT_VERSION ?= 2.10.1
4141
-include build/makelib/golang.mk
4242

43+
# --out-format is deprecated with v2, replace with --output.checkstyle.path
44+
ifeq ($(RUNNING_IN_CI),true)
45+
GO_LINT_ARGS := --timeout 10m0s --output.checkstyle.path=$(GO_LINT_OUTPUT)/checkstyle.xml
46+
endif
47+
4348
# kind-related versions
4449
KIND_VERSION ?= v0.26.0
4550
KIND_NODE_IMAGE_TAG ?= v1.32.0
@@ -204,7 +209,7 @@ UPGRADE_TEST_FILTER ?= .
204209

205210
.PHONY: check-upgrade-test-vars
206211
check-upgrade-test-vars: ## Verify required upgrade test environment variables
207-
@$(INFO) Checking required environment variables for upgrade tests are present
212+
@$(INFO) Checking required environment variables for upgrade tests are present
208213
@test -n "$(UPGRADE_TEST_FROM_TAG)" || { echo "❌ Set UPGRADE_TEST_FROM_TAG"; exit 1; }
209214
@test -n "$(UPGRADE_TEST_TO_TAG)" || { echo "❌ Set UPGRADE_TEST_TO_TAG"; exit 1; }
210215
@$(OK) required upgrade test environment variables are set
@@ -338,7 +343,7 @@ test-upgrade-debug: $(KIND) check-upgrade-test-vars build-upgrade-test-images te
338343

339344
.PHONY: test-upgrade-restore-crs
340345
test-upgrade-restore-crs: ## Restore $(UPGRADE_TEST_CRS_DIR)/ to current version
341-
@$(INFO) restoring $(UPGRADE_TEST_CRS_DIR)/
346+
@$(INFO) restoring $(UPGRADE_TEST_CRS_DIR)/
342347
@git checkout $(UPGRADE_TEST_CRS_DIR)/
343348
@$(OK) CRs restored
344349

@@ -401,7 +406,7 @@ test-upgrade-help: ## Show upgrade test usage examples
401406
@$(INFO) " Base Tests: Standard resource verification (TestUpgradeProvider)"
402407
@$(INFO) " Custom Tests: External-name validation (Test_Space_External_Name, etc.)"
403408
@$(INFO) ""
404-
409+
405410
# ====================================================================================
406411
# Special Targets
407412

@@ -445,4 +450,4 @@ publish:
445450
echo "Publishing image $(DOCKER_REGISTRY)/$${image}:$(VERSION)"; \
446451
docker push $(DOCKER_REGISTRY)/$${image}:$(VERSION); \
447452
done
448-
@$(OK) "Publishing images $(PUBLISH_IMAGES) to $(DOCKER_REGISTRY)"
453+
@$(OK) "Publishing images $(PUBLISH_IMAGES) to $(DOCKER_REGISTRY)"

apis/resources/v1alpha1/app_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"k8s.io/apimachinery/pkg/runtime/schema"
1010

1111
v1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
12-
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
1312
)
1413

1514
type AppObservation struct {
@@ -107,7 +106,7 @@ type DockerConfiguration struct {
107106

108107
// (Attributes) Defines login credentials for private docker repositories
109108
// +kubebuilder:validation:Optional
110-
Credentials *xpv1.SecretReference `json:"credentialsSecretRef,omitempty"`
109+
Credentials *v1.SecretReference `json:"credentialsSecretRef,omitempty"`
111110
}
112111

113112
// RouteConfiguration defines the route for the application

cmd/exporter/cf/serviceinstance/convert.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ func convertServiceInstanceResource(ctx context.Context, cfClient *client.Client
144144
managedSI.Spec.ForProvider.ServicePlan = generateServicePlan(ctx, cfClient, serviceInstance.ServiceInstance, evHandler)
145145

146146
if mInfo := serviceInstance.MaintenanceInfo; mInfo != nil {
147-
managedSI.Spec.ForProvider.Managed.MaintenanceInfo.Description = &mInfo.Description
148-
managedSI.Spec.ForProvider.Managed.MaintenanceInfo.Version = &mInfo.Description
147+
managedSI.Spec.ForProvider.MaintenanceInfo.Description = &mInfo.Description
148+
managedSI.Spec.ForProvider.MaintenanceInfo.Version = &mInfo.Description
149149
}
150150

151151
var comment *string
152-
managedSI.Spec.ForProvider.Managed.Parameters, comment = generateParams(ctx, cfClient, serviceInstance.ServiceInstance, evHandler)
152+
managedSI.Spec.ForProvider.Parameters, comment = generateParams(ctx, cfClient, serviceInstance.ServiceInstance, evHandler)
153153
if comment != nil {
154154
serviceInstanceWithComment.AddComment(*comment)
155155
}
156-
managedSI.Spec.ForProvider.UserProvided.Credentials = generateCreds(ctx, cfClient, serviceInstance.ServiceInstance, evHandler)
156+
managedSI.Spec.ForProvider.Credentials = generateCreds(ctx, cfClient, serviceInstance.ServiceInstance, evHandler)
157157

158158
managedSI.Spec.ForProvider.SpaceReference = v1alpha1.SpaceReference{
159159
Space: &serviceInstance.Relationships.Space.Data.GUID,

cmd/exporter/cf/serviceinstance/serviceinstance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func (si serviceinstance) Export(ctx context.Context, cfClient *client.Client, e
7979
ctx, cancel := context.WithTimeout(ctx, 10*time.Minute)
8080
defer cancel()
8181
for _, sInstance := range serviceInstances.AllByGUIDs() {
82-
slog.Debug("exporting serviceinstance", "name", sInstance.(*res).ServiceInstance.Name)
82+
slog.Debug("exporting serviceinstance", "name", sInstance.(*res).Name)
8383
evHandler.Resource(convertServiceInstanceResource(ctx, cfClient, sInstance.(*res), evHandler, resolveReferences))
8484
}
8585
return nil

cmd/exporter/cf/userrole/userrole.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (r *Role) GetGUID() string {
6060
}
6161

6262
func (r *Role) GetName() string {
63-
name := fmt.Sprintf("%s --- %s", *r.User.Username, r.Role.Type)
63+
name := fmt.Sprintf("%s --- %s", *r.Username, r.Type)
6464
names := parsan.ParseAndSanitize(
6565
name,
6666
parsan.RFC1035LowerSubdomain,

cmd/exporter/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (c cliConfig) CommandUse(*cli.ConfigSchema) string {
5252
}
5353

5454
func main() {
55-
cli.Configuration.CLIConfiguration.ConfiguratorCLI = cliConfig{cli.DefaultConfiguratorCLI{}}
55+
cli.Configuration.ConfiguratorCLI = cliConfig{cli.DefaultConfiguratorCLI{}}
5656
cli.Configuration.ShortName = ShortName
5757
cli.Configuration.ObservedSystem = observedSystem
5858
export.SetCommand(exportCmd)

0 commit comments

Comments
 (0)