Skip to content

Commit 6e9572d

Browse files
authored
fix: improve obsinstaller validation (#905)
* fix: improve obsinstaller validation Signed-off-by: Pavol Loffay <[email protected]> * fix: improve obsinstaller validation Signed-off-by: Pavol Loffay <[email protected]> * fix: improve obsinstaller validation Signed-off-by: Pavol Loffay <[email protected]> --------- Signed-off-by: Pavol Loffay <[email protected]>
1 parent 01ad960 commit 6e9572d

File tree

12 files changed

+645
-147
lines changed

12 files changed

+645
-147
lines changed

bundle/manifests/observability.openshift.io_observabilityinstallers.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,21 @@ spec:
350350
rule: (has(self.keySecret) && has(self.certSecret))
351351
|| (!has(self.keySecret) && !has(self.certSecret))
352352
type: object
353+
x-kubernetes-validations:
354+
- message: Only one or zero storage configurations can
355+
be specified
356+
rule: '[has(self.s3), has(self.s3STS), has(self.s3CCO),
357+
has(self.azure), has(self.azureWIF), has(self.gcs),
358+
has(self.gcsWIF)].filter(x, x).size() <= 1'
353359
type: object
354360
type: object
361+
x-kubernetes-validations:
362+
- message: Storage configuration is required when tracing is enabled
363+
rule: (!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3),
364+
has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO),
365+
has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF),
366+
has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x,
367+
x).size() > 0
355368
type: object
356369
type: object
357370
status:

deploy/crds/common/observability.openshift.io_observabilityinstallers.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,21 @@ spec:
350350
rule: (has(self.keySecret) && has(self.certSecret))
351351
|| (!has(self.keySecret) && !has(self.certSecret))
352352
type: object
353+
x-kubernetes-validations:
354+
- message: Only one or zero storage configurations can
355+
be specified
356+
rule: '[has(self.s3), has(self.s3STS), has(self.s3CCO),
357+
has(self.azure), has(self.azureWIF), has(self.gcs),
358+
has(self.gcsWIF)].filter(x, x).size() <= 1'
353359
type: object
354360
type: object
361+
x-kubernetes-validations:
362+
- message: Storage configuration is required when tracing is enabled
363+
rule: (!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3),
364+
has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO),
365+
has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF),
366+
has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x,
367+
x).size() > 0
355368
type: object
356369
type: object
357370
status:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ require (
7979
github.com/go-openapi/validate v0.24.0 // indirect
8080
github.com/gogo/protobuf v1.3.2 // indirect
8181
github.com/google/btree v1.1.3 // indirect
82-
github.com/google/cel-go v0.26.0 // indirect
82+
github.com/google/cel-go v0.26.1 // indirect
8383
github.com/google/gnostic-models v0.7.0 // indirect
8484
github.com/google/uuid v1.6.0 // indirect
8585
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ github.com/golang/snappy v1.0.0 h1:Oy607GVXHs7RtbggtPBnr2RmDArIsAefDwvrdWvRhGs=
166166
github.com/golang/snappy v1.0.0/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
167167
github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg=
168168
github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
169-
github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI=
170-
github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
169+
github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ=
170+
github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
171171
github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo=
172172
github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ=
173173
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=

pkg/apis/go.mod

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,33 @@ go 1.24.0
44

55
require (
66
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.83.0-rhobs1
7+
github.com/stretchr/testify v1.10.0
78
k8s.io/api v0.33.2
89
k8s.io/apimachinery v0.33.2
910
)
1011

1112
require (
13+
cel.dev/expr v0.24.0 // indirect
14+
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
15+
github.com/davecgh/go-spew v1.1.1 // indirect
1216
github.com/fxamacker/cbor/v2 v2.8.0 // indirect
1317
github.com/go-logr/logr v1.4.2 // indirect
1418
github.com/gogo/protobuf v1.3.2 // indirect
19+
github.com/google/cel-go v0.26.1 // indirect
1520
github.com/json-iterator/go v1.1.12 // indirect
1621
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
1722
github.com/modern-go/reflect2 v1.0.2 // indirect
23+
github.com/pmezard/go-difflib v1.0.0 // indirect
24+
github.com/stoewer/go-strcase v1.2.0 // indirect
1825
github.com/x448/float16 v0.8.4 // indirect
26+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
1927
golang.org/x/net v0.40.0 // indirect
2028
golang.org/x/text v0.25.0 // indirect
29+
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect
30+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect
31+
google.golang.org/protobuf v1.36.5 // indirect
2132
gopkg.in/inf.v0 v0.9.1 // indirect
33+
gopkg.in/yaml.v3 v3.0.1 // indirect
2234
k8s.io/klog/v2 v2.130.1 // indirect
2335
k8s.io/utils v0.0.0-20250502105355-0f33e8f1c979 // indirect
2436
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect

pkg/apis/go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
cel.dev/expr v0.24.0 h1:56OvJKSH3hDGL0ml5uSxZmz3/3Pq4tJ+fb1unVLAFcY=
2+
cel.dev/expr v0.24.0/go.mod h1:hLPLo1W4QUmuYdA72RBX06QTs6MXw941piREPl3Yfiw=
3+
github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=
4+
github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g=
15
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
26
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
37
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -7,6 +11,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
711
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
812
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
913
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
14+
github.com/google/cel-go v0.26.1 h1:iPbVVEdkhTX++hpe3lzSk7D3G3QSYqLGoHOcEio+UXQ=
15+
github.com/google/cel-go v0.26.1/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM=
1016
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
1117
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
1218
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
@@ -32,8 +38,11 @@ github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR
3238
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
3339
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
3440
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
41+
github.com/stoewer/go-strcase v1.2.0 h1:Z2iHWqGXH00XYgqDmNgQbIBxf3wrNq0F3feEy0ainaU=
42+
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
3543
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
3644
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
45+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
3746
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
3847
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3948
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
@@ -43,6 +52,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
4352
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
4453
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
4554
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
55+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU=
56+
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
4657
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
4758
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
4859
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@@ -69,11 +80,18 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
6980
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7081
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7182
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
83+
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 h1:YcyjlL1PRr2Q17/I0dPk2JmYS5CDXfcdb2Z3YRioEbw=
84+
google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:OCdP9MfskevB/rbYvHTsXTtKC+3bHWajPdoKgjcYkfo=
85+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs=
86+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
87+
google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM=
88+
google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
7289
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
7390
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
7491
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
7592
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
7693
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
94+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
7795
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
7896
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7997
k8s.io/api v0.33.2 h1:YgwIS5jKfA+BZg//OQhkJNIfie/kmRsO0BmNaVSimvY=

pkg/apis/observability/v1alpha1/tracing.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package v1alpha1
22

33
// TracingSpec defines the desired state of the tracing capability.
4+
// +kubebuilder:validation:XValidation:rule="(!has(self.enabled) || !self.enabled) || [has(self.storage.objectStorage.s3), has(self.storage.objectStorage.s3STS), has(self.storage.objectStorage.s3CCO), has(self.storage.objectStorage.azure), has(self.storage.objectStorage.azureWIF), has(self.storage.objectStorage.gcs), has(self.storage.objectStorage.gcsWIF)].filter(x, x).size() > 0",message="Storage configuration is required when tracing is enabled"
45
type TracingSpec struct {
56
CommonCapabilitiesSpec `json:",inline"`
67

@@ -11,10 +12,14 @@ type TracingSpec struct {
1112
// TracingStorageSpec defines the storage for tracing capability.
1213
type TracingStorageSpec struct {
1314
// ObjectStorageSpec defines the object storage configuration for tracing.
15+
// +optional
16+
// +kubebuilder:validation:Optional
17+
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Object storage config"
1418
ObjectStorageSpec TracingObjectStorageSpec `json:"objectStorage,omitempty"`
1519
}
1620

1721
// TracingObjectStorageSpec defines the object storage for the tracing capability.
22+
// +kubebuilder:validation:XValidation:rule="[has(self.s3), has(self.s3STS), has(self.s3CCO), has(self.azure), has(self.azureWIF), has(self.gcs), has(self.gcsWIF)].filter(x, x).size() <= 1",message="Only one or zero storage configurations can be specified"
1823
type TracingObjectStorageSpec struct {
1924
// S3 defines the S3 object storage configuration.
2025
S3 *S3Spec `json:"s3,omitempty"`

0 commit comments

Comments
 (0)