Skip to content

Commit 97af003

Browse files
committed
fix: use size() in CEL rule to avoid gofmt Unicode quote conversion
gofmt 1.19+ reformats consecutive single quotes ('') in doc comments to Unicode curly double-quotes, corrupting the CEL rule at generation time. Replace empty-string comparisons with size() > 0 checks which use no string literals and are immune to gofmt reformatting.
1 parent 9e62471 commit 97af003

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

api/v2/apisixconsumer_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ type ApisixConsumerJwtAuth struct {
134134
// - For symmetric algorithms (HS256, HS384, HS512): use secret. private_key and public_key are not required.
135135
// - For asymmetric algorithms (RS*, ES*, PS*, EdDSA): at least one of public_key or private_key must be provided.
136136
//
137-
// +kubebuilder:validation:XValidation:rule="!has(self.algorithm) || self.algorithm in ['HS256','HS384','HS512'] || (has(self.public_key) && self.public_key != '') || (has(self.private_key) && self.private_key != '')",message="asymmetric JWT algorithms (RS*/ES*/PS*/EdDSA) require at least one of public_key or private_key"
137+
// +kubebuilder:validation:XValidation:rule="!has(self.algorithm) || self.algorithm in ['HS256','HS384','HS512'] || (has(self.public_key) && size(self.public_key) > 0) || (has(self.private_key) && size(self.private_key) > 0)",message="asymmetric JWT algorithms (RS*/ES*/PS*/EdDSA) require at least one of public_key or private_key"
138138
type ApisixConsumerJwtAuthValue struct {
139139
// Key is the unique identifier for the JWT credential.
140140
Key string `json:"key" yaml:"key"`

config/crd/bases/apisix.apache.org_apisixconsumers.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,9 @@ spec:
215215
- message: asymmetric JWT algorithms (RS*/ES*/PS*/EdDSA) require
216216
at least one of public_key or private_key
217217
rule: '!has(self.algorithm) || self.algorithm in [''HS256'',''HS384'',''HS512'']
218-
|| (has(self.public_key) && self.public_key != '''') ||
219-
(has(self.private_key) && self.private_key != '''')'
218+
|| (has(self.public_key) && size(self.public_key) > 0)
219+
|| (has(self.private_key) && size(self.private_key) >
220+
0)'
220221
type: object
221222
keyAuth:
222223
description: KeyAuth configures the key authentication details.

0 commit comments

Comments
 (0)