Skip to content

Commit 7d306eb

Browse files
committed
operator: implement roundtripping conversion of v1alpha3
This commit adds the initial set of conversion routines to support roundtripping all valid configurations of the v1alpha3 CR through the v1alpha2 CR. To aid in the development and testing of the conversion routines, the `exhaustruct` linter has been enabled on files ending in `_conversion.go`. It requires all fields to be explicitly declared which will prevent future additions to either CR from causing regressions. It should be noted that v1alpha2 can NOT be roundtripped. Therefore the v1alpha3 CRD can not be _safely_ enabled. Future work will: - Improve user facing documentation of all fields - Support roundtripping v1alpha2 through v1alpha3 - (Potentially) refactor conversion to make use of the conversion-gen tool.
1 parent 4c6ebd4 commit 7d306eb

33 files changed

+2085
-1537
lines changed

.golangci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ linters:
2020
default: none
2121
enable:
2222
- depguard
23-
# - errcheck
23+
- exhaustruct
2424
- gosec
2525
- govet
2626
- importas
@@ -52,6 +52,14 @@ linters:
5252
- pkg: "^github.com/redpanda-data/redpanda-operator/charts$"
5353
desc: 'import specific charts, the overarching charts module is now deprecated'
5454

55+
exhaustruct:
56+
# The default is to include all structs. To disable we add a regexp that
57+
# doesn't match anything.
58+
include:
59+
- '^github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha3\..*'
60+
- '^github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2\..*'
61+
exclude: []
62+
5563
gosec:
5664
excludes:
5765
- G115 # integer overflows aren't super likely to be a problem for us and we're really just at the mercy of the APIs we use.
@@ -104,3 +112,9 @@ linters:
104112
- gosec
105113
- wrapcheck
106114
path: '(.+)_test\.go'
115+
# We're primarily concerned about conversion routines supplying a value for each possible field.
116+
# The linter doesn't support selective enablement so we're simply ignoring
117+
# all reports outside of conversion code.
118+
- linters:
119+
- exhaustruct
120+
path-except: '_conversion\.go'

acceptance/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ require (
213213
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 // indirect
214214
github.com/redpanda-data/redpanda-operator/charts/connectors v0.0.0-20250407180246-dc814fb6b3b8 // indirect
215215
github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250407180246-dc814fb6b3b8 // indirect
216-
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250528165859-05efa25f40a6 // indirect
216+
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250530212252-f020b773160c // indirect
217217
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 // indirect
218218
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 // indirect
219219
github.com/rivo/uniseg v0.4.7 // indirect

acceptance/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,8 +749,8 @@ github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250407180246-
749749
github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250407180246-dc814fb6b3b8/go.mod h1:Sof2HY8U+RLesHJInGLoqhUMzN8iN8gUHXALbROsew8=
750750
github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0 h1:6jvBn+Xr1+62BEFSHoKxayRM/Xt9hp6O5nhnE368ge4=
751751
github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0/go.mod h1:y/8tR/cBC11uDPvjosxT8DAxnuSlPWtEzVYeCAqa4K4=
752-
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250528165859-05efa25f40a6 h1:L47y1LcYVimapky8oXc58pQ9+PFnl8sxTfGKfb7zAUc=
753-
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250528165859-05efa25f40a6/go.mod h1:33q+FpNfYgIVnV5EOPTKWk2udlG6JoYi0UqLX8YHU/E=
752+
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250530212252-f020b773160c h1:o6uYfqPWRUDRPl5xGj5jf38oCUYFo0z/loOQ39Fwu4w=
753+
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250530212252-f020b773160c/go.mod h1:33q+FpNfYgIVnV5EOPTKWk2udlG6JoYi0UqLX8YHU/E=
754754
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 h1:IV2Ic66JDKPtCnNU4Kn1naJlzZmhl0izRj17qgTCo20=
755755
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0/go.mod h1:usCpPzzzhgtPrRTiUQOzFqGmukce8U0SrzEeX2ONDFE=
756756
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 h1:uTQKqF8UPNxYxKBJ11VlG6Vt2l9ctkkeXsmmjHUSUG4=

acceptance/steps/scaling.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
redpandav1alpha2 "github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2"
1414
)
1515

16-
func iCreateABasicClusterWithNodes(ctx context.Context, t framework.TestingT, clusterName string, nodeCount int) {
16+
func iCreateABasicClusterWithNodes(ctx context.Context, t framework.TestingT, clusterName string, nodeCount int32) {
1717
key := t.ResourceKey(clusterName)
1818
image := &redpandav1alpha2.RedpandaImage{
1919
Tag: ptr.To("dev"),
@@ -66,7 +66,7 @@ func iCreateABasicClusterWithNodes(ctx context.Context, t framework.TestingT, cl
6666
})
6767
}
6868

69-
func iScaleToNodes(ctx context.Context, t framework.TestingT, clusterName string, nodeCount int) {
69+
func iScaleToNodes(ctx context.Context, t framework.TestingT, clusterName string, nodeCount int32) {
7070
var cluster redpandav1alpha2.Redpanda
7171
var err error
7272

charts/redpanda/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/quasilyte/go-ruleguard/dsl v0.3.22
1313
github.com/redpanda-data/common-go/rpadmin v0.1.14-0.20250425125657-8ab73f3ad62e
1414
github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0
15-
github.com/redpanda-data/redpanda-operator/gotohelm v0.0.0-20250327164623-c3883a149a17
15+
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0
1616
github.com/redpanda-data/redpanda-operator/operator v0.0.0-20250528175436-e8cca0053dc6
1717
github.com/redpanda-data/redpanda-operator/pkg v0.0.0-20250528175436-e8cca0053dc6
1818
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8

charts/redpanda/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ github.com/redpanda-data/common-go/secrets v0.1.3 h1:VRo+OFS4Zgb2UMvwcIuUujdMhAP
537537
github.com/redpanda-data/common-go/secrets v0.1.3/go.mod h1:WjUU/5saSXwItZx6veFOGbQZUgPQz4MQ65z22y0Ky84=
538538
github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0 h1:6jvBn+Xr1+62BEFSHoKxayRM/Xt9hp6O5nhnE368ge4=
539539
github.com/redpanda-data/redpanda-operator/charts/console/v3 v3.1.0/go.mod h1:y/8tR/cBC11uDPvjosxT8DAxnuSlPWtEzVYeCAqa4K4=
540-
github.com/redpanda-data/redpanda-operator/gotohelm v0.0.0-20250327164623-c3883a149a17 h1:aARsVhc9XYhrC/aeJpDHnel8QicHbo6BtZzbhqe33UY=
541-
github.com/redpanda-data/redpanda-operator/gotohelm v0.0.0-20250327164623-c3883a149a17/go.mod h1:QkZMtADhtFgS5Bixk6N931yazp9mBtQ7VAJ5gWPrsgg=
540+
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 h1:IV2Ic66JDKPtCnNU4Kn1naJlzZmhl0izRj17qgTCo20=
541+
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0/go.mod h1:usCpPzzzhgtPrRTiUQOzFqGmukce8U0SrzEeX2ONDFE=
542542
github.com/redpanda-data/redpanda-operator/operator v0.0.0-20250528175436-e8cca0053dc6 h1:7ZGF97PVyQ5yst9mvcmnllYCfMgRSts/1XYgh84Q6Pw=
543543
github.com/redpanda-data/redpanda-operator/operator v0.0.0-20250528175436-e8cca0053dc6/go.mod h1:C4oYf3EfNvIhrNnRqciGojBoeiBm06hO8QrquzYJFG4=
544544
github.com/redpanda-data/redpanda-operator/pkg v0.0.0-20250528175436-e8cca0053dc6 h1:3j3DgUcLJIDXnQYv+bOt2GShkTq0LZlFzFypSaZFUMc=

gen/go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ require (
8888
github.com/cespare/xxhash/v2 v2.3.0 // indirect
8989
github.com/chai2010/gettext-go v1.0.2 // indirect
9090
github.com/cisco-open/k8s-objectmatcher v1.9.0 // indirect
91+
github.com/cloudhut/common v0.10.0 // indirect
9192
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
9293
github.com/cockroachdb/redact v1.1.5 // indirect
9394
github.com/containerd/containerd v1.7.24 // indirect
@@ -112,6 +113,7 @@ require (
112113
github.com/fsnotify/fsnotify v1.9.0 // indirect
113114
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
114115
github.com/getsentry/sentry-go v0.27.0 // indirect
116+
github.com/go-chi/chi/v5 v5.0.12 // indirect
115117
github.com/go-errors/errors v1.5.1 // indirect
116118
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
117119
github.com/go-logr/logr v1.4.2 // indirect
@@ -154,6 +156,7 @@ require (
154156
github.com/json-iterator/go v1.1.12 // indirect
155157
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
156158
github.com/klauspost/compress v1.18.0 // indirect
159+
github.com/knadh/koanf v1.5.0 // indirect
157160
github.com/kr/pretty v0.3.1 // indirect
158161
github.com/kr/text v0.2.0 // indirect
159162
github.com/kylelemons/godebug v1.1.0 // indirect
@@ -173,6 +176,7 @@ require (
173176
github.com/mitchellh/go-ps v1.0.0 // indirect
174177
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
175178
github.com/mitchellh/hashstructure v1.1.0 // indirect
179+
github.com/mitchellh/mapstructure v1.5.0 // indirect
176180
github.com/mitchellh/reflectwalk v1.0.2 // indirect
177181
github.com/moby/locker v1.0.1 // indirect
178182
github.com/moby/spdystream v0.5.0 // indirect
@@ -198,6 +202,10 @@ require (
198202
github.com/redpanda-data/common-go/net v0.1.0 // indirect
199203
github.com/redpanda-data/common-go/rpadmin v0.1.14-0.20250425125657-8ab73f3ad62e // indirect
200204
github.com/redpanda-data/common-go/secrets v0.1.3 // indirect
205+
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 // indirect
206+
github.com/redpanda-data/redpanda-operator/charts/connectors v0.0.0-20250407180246-dc814fb6b3b8 // indirect
207+
github.com/redpanda-data/redpanda-operator/charts/console v0.0.0-20250407180246-dc814fb6b3b8 // indirect
208+
github.com/redpanda-data/redpanda-operator/charts/redpanda/v5 v5.10.3-0.20250530212252-f020b773160c // indirect
201209
github.com/redpanda-data/redpanda-operator/gotohelm v1.1.0 // indirect
202210
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 // indirect
203211
github.com/rivo/uniseg v0.4.7 // indirect
@@ -220,6 +228,7 @@ require (
220228
github.com/twmb/franz-go v1.18.0 // indirect
221229
github.com/twmb/franz-go/pkg/kadm v1.12.0 // indirect
222230
github.com/twmb/franz-go/pkg/kmsg v1.9.0 // indirect
231+
github.com/twmb/franz-go/pkg/sr v1.2.0 // indirect
223232
github.com/twmb/tlscfg v1.2.1 // indirect
224233
github.com/virtuald/go-ordered-json v0.0.0-20170621173500-b18e6e673d74 // indirect
225234
github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect

0 commit comments

Comments
 (0)