Skip to content

Commit fba48bd

Browse files
authored
feat: mangle regex.match system module function (#88)
Signed-off-by: peefy <[email protected]>
1 parent 7a52907 commit fba48bd

File tree

14 files changed

+922
-67
lines changed

14 files changed

+922
-67
lines changed

examples/kube_resource/complex/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
44
"""
55
import regex
66
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
78

89

910
schema ContainerizedWorkload:
@@ -149,7 +150,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0EnvItems0:
149150

150151

151152
check:
152-
regex.match(str(name), r"^[-_a-zA-Z0-9]+$")
153+
regex_match(str(name), r"^[-_a-zA-Z0-9]+$")
153154

154155

155156
schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0LivenessProbe:
@@ -285,7 +286,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0PortsItems0:
285286

286287

287288
check:
288-
regex.match(str(name), r"^[a-z]+$")
289+
regex_match(str(name), r"^[a-z]+$")
289290

290291

291292
schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0ReadiessProbe:

pkg/kube_resource/generator/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func crdObj2CrdInternal(crdObj runtime.Object) (*apiextensions.CustomResourceDef
204204
case *apiextensions.CustomResourceDefinition:
205205
crd = crdObj.(*apiextensions.CustomResourceDefinition)
206206
default:
207-
return nil, errors.New(fmt.Sprintf("unknown crd object type %v", crdObj.GetObjectKind()))
207+
return nil, fmt.Errorf("unknown crd object type %v", crdObj.GetObjectKind())
208208
}
209209

210210
if !CRDContainsValidation(crd) {

pkg/kube_resource/generator/testdata/all_of_pattern/models/karpenter_k8s_aws_v1beta1_e_c2_node_class.k

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
44
"""
55
import regex
66
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
78

89

910
schema EC2NodeClass:
@@ -124,7 +125,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecAmiSelectorTermsItems0:
124125

125126

126127
check:
127-
regex.match(str(id), r"ami-[0-9a-z]+") if id
128+
regex_match(str(id), r"ami-[0-9a-z]+") if id
128129

129130

130131
schema KarpenterK8sAwsV1beta1EC2NodeClassSpecBlockDeviceMappingsItems0:
@@ -202,8 +203,8 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecBlockDeviceMappingsItems0Ebs:
202203

203204

204205
check:
205-
regex.match(str(volumeSize), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if volumeSize
206-
regex.match(str(volumeSize), r"^((?:[1-9][0-9]{0,3}|[1-4][0-9]{4}|[5][0-8][0-9]{3}|59000)Gi|(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-3][0-9]{3}|64000)G|([1-9]||[1-5][0-7]|58)Ti|([1-9]||[1-5][0-9]|6[0-3]|64)T)$") if volumeSize
206+
regex_match(str(volumeSize), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if volumeSize
207+
regex_match(str(volumeSize), r"^((?:[1-9][0-9]{0,3}|[1-4][0-9]{4}|[5][0-8][0-9]{3}|59000)Gi|(?:[1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-3][0-9]{3}|64000)G|([1-9]||[1-5][0-7]|58)Ti|([1-9]||[1-5][0-9]|6[0-3]|64)T)$") if volumeSize
207208

208209

209210
schema KarpenterK8sAwsV1beta1EC2NodeClassSpecMetadataOptions:
@@ -265,7 +266,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSecurityGroupSelectorTermsItems0:
265266

266267

267268
check:
268-
regex.match(str(id), r"sg-[0-9a-z]+") if id
269+
regex_match(str(id), r"sg-[0-9a-z]+") if id
269270

270271

271272
schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSubnetSelectorTermsItems0:
@@ -287,7 +288,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSubnetSelectorTermsItems0:
287288

288289

289290
check:
290-
regex.match(str(id), r"subnet-[0-9a-z]+") if id
291+
regex_match(str(id), r"subnet-[0-9a-z]+") if id
291292

292293

293294
schema KarpenterK8sAwsV1beta1EC2NodeClassStatus:

pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
44
"""
55
import regex
66
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
78

89

910
schema VMAgent:
@@ -371,8 +372,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpec:
371372

372373

373374
check:
374-
regex.match(str(scrapeInterval), r"[0-9]+(ms|s|m|h)") if scrapeInterval
375-
regex.match(str(scrapeTimeout), r"[0-9]+(ms|s|m|h)") if scrapeTimeout
375+
regex_match(str(scrapeInterval), r"[0-9]+(ms|s|m|h)") if scrapeInterval
376+
regex_match(str(scrapeTimeout), r"[0-9]+(ms|s|m|h)") if scrapeTimeout
376377

377378

378379
schema OperatorVictoriametricsComV1beta1VMAgentSpecAPIServerConfig:
@@ -878,8 +879,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecResou
878879

879880

880881
check:
881-
all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
882-
all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
882+
all _, limits in limits {regex_match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
883+
all _, requests in requests {regex_match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
883884

884885

885886
schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecSelector:
@@ -957,8 +958,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0Status:
957958

958959

959960
check:
960-
all _, allocatedResources in allocatedResources {regex.match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources
961-
all _, capacity in capacity {regex.match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
961+
all _, allocatedResources in allocatedResources {regex_match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources
962+
all _, capacity in capacity {regex_match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
962963

963964

964965
schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0StatusConditionsItems0:
@@ -995,7 +996,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0StatusCon
995996
$type: str
996997

997998

998-
schema [any]:
999+
schema OperatorVictoriametricsComV1beta1VMAgentSpecDNSConfig:
9991000
"""
10001001
Specifies the DNS parameters of a pod. Parameters specified here will be merged to the generated DNS configuration based on DNSPolicy.
10011002

@@ -1736,7 +1737,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteItems0:
17361737

17371738

17381739
check:
1739-
regex.match(str(sendTimeout), r"[0-9]+(ms|s|m|h)") if sendTimeout
1740+
regex_match(str(sendTimeout), r"[0-9]+(ms|s|m|h)") if sendTimeout
17401741

17411742

17421743
schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteItems0BasicAuth:
@@ -2453,7 +2454,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteSettings:
24532454

24542455

24552456
check:
2456-
regex.match(str(flushInterval), r"[0-9]+(ms|s|m|h)") if flushInterval
2457+
regex_match(str(flushInterval), r"[0-9]+(ms|s|m|h)") if flushInterval
24572458

24582459

24592460
schema OperatorVictoriametricsComV1beta1VMAgentSpecResources:
@@ -2475,8 +2476,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecResources:
24752476

24762477

24772478
check:
2478-
all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
2479-
all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
2479+
all _, limits in limits {regex_match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
2480+
all _, requests in requests {regex_match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
24802481

24812482

24822483
schema OperatorVictoriametricsComV1beta1VMAgentSpecRollingUpdate:
@@ -2716,7 +2717,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageEmptyDir:
27162717

27172718

27182719
check:
2719-
regex.match(str(sizeLimit), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if sizeLimit
2720+
regex_match(str(sizeLimit), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if sizeLimit
27202721

27212722

27222723
schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplate:
@@ -2876,8 +2877,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem
28762877

28772878

28782879
check:
2879-
all _, limits in limits {regex.match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
2880-
all _, requests in requests {regex.match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
2880+
all _, limits in limits {regex_match(str(limits), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if limits } if limits
2881+
all _, requests in requests {regex_match(str(requests), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if requests } if requests
28812882

28822883

28832884
schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateSpecSelector:
@@ -2955,8 +2956,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem
29552956

29562957

29572958
check:
2958-
all _, allocatedResources in allocatedResources {regex.match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources
2959-
all _, capacity in capacity {regex.match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
2959+
all _, allocatedResources in allocatedResources {regex_match(str(allocatedResources), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if allocatedResources } if allocatedResources
2960+
all _, capacity in capacity {regex_match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
29602961

29612962

29622963
schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateStatusConditionsItems0:

pkg/kube_resource/generator/testdata/int_or_string_validation/models/crd_projectcalico_org_v1_global_network_policy.k

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
This file was generated by the KCL auto-gen tool. DO NOT EDIT.
33
Editing this file might prove futile when you re-run the KCL auto-gen generate command.
44
"""
5+
import regex
56
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
68

79

810
schema GlobalNetworkPolicy:
@@ -40,7 +42,7 @@ schema GlobalNetworkPolicy:
4042

4143

4244
check:
43-
all _, capacity in capacity {regex.match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
45+
all _, capacity in capacity {regex_match(str(capacity), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if capacity } if capacity
4446

4547

4648
schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestination:
@@ -98,8 +100,8 @@ schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestination:
98100

99101

100102
check:
101-
all notPorts in notPorts {regex.match(str(notPorts), r"^.*") if notPorts } if notPorts
102-
all ports in ports {regex.match(str(ports), r"^.*") if ports } if ports
103+
all notPorts in notPorts {regex_match(str(notPorts), r"^.*") if notPorts } if notPorts
104+
all ports in ports {regex_match(str(ports), r"^.*") if ports } if ports
103105

104106

105107
schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestinationServiceAccounts:

pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
44
"""
55
import regex
66
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
78

89

910
schema OperatorConfiguration:
@@ -293,10 +294,10 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationConnectionPooler:
293294

294295

295296
check:
296-
regex.match(str(connection_pooler_default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_limit
297-
regex.match(str(connection_pooler_default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_request
298-
regex.match(str(connection_pooler_default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_limit
299-
regex.match(str(connection_pooler_default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_request
297+
regex_match(str(connection_pooler_default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_limit
298+
regex_match(str(connection_pooler_default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_request
299+
regex_match(str(connection_pooler_default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_limit
300+
regex_match(str(connection_pooler_default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_request
300301
connection_pooler_number_of_instances >= 1
301302

302303

@@ -713,11 +714,11 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationLogicalBackup:
713714

714715

715716
check:
716-
regex.match(str(logical_backup_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_limit
717-
regex.match(str(logical_backup_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_request
718-
regex.match(str(logical_backup_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_limit
719-
regex.match(str(logical_backup_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_request
720-
regex.match(str(logical_backup_schedule), r"^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$") if logical_backup_schedule
717+
regex_match(str(logical_backup_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_limit
718+
regex_match(str(logical_backup_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_request
719+
regex_match(str(logical_backup_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_limit
720+
regex_match(str(logical_backup_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_request
721+
regex_match(str(logical_backup_schedule), r"^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$") if logical_backup_schedule
721722

722723

723724
schema AcidZalanDoV1OperatorConfigurationConfigurationMajorVersionUpgrade:
@@ -803,14 +804,14 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationPostgresPodResources:
803804

804805

805806
check:
806-
regex.match(str(default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_limit
807-
regex.match(str(default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_request
808-
regex.match(str(default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_limit
809-
regex.match(str(default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_request
810-
regex.match(str(max_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if max_cpu_request
811-
regex.match(str(max_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if max_memory_request
812-
regex.match(str(min_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if min_cpu_limit
813-
regex.match(str(min_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if min_memory_limit
807+
regex_match(str(default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_limit
808+
regex_match(str(default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_request
809+
regex_match(str(default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_limit
810+
regex_match(str(default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_request
811+
regex_match(str(max_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if max_cpu_request
812+
regex_match(str(max_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if max_memory_request
813+
regex_match(str(min_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if min_cpu_limit
814+
regex_match(str(min_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if min_memory_limit
814815

815816

816817
schema AcidZalanDoV1OperatorConfigurationConfigurationScalyr:
@@ -852,10 +853,10 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationScalyr:
852853

853854

854855
check:
855-
regex.match(str(scalyr_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_limit
856-
regex.match(str(scalyr_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_request
857-
regex.match(str(scalyr_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_limit
858-
regex.match(str(scalyr_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_request
856+
regex_match(str(scalyr_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_limit
857+
regex_match(str(scalyr_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_request
858+
regex_match(str(scalyr_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_limit
859+
regex_match(str(scalyr_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_request
859860

860861

861862
schema AcidZalanDoV1OperatorConfigurationConfigurationTeamsAPI:

pkg/kube_resource/generator/testdata/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c
44
"""
55
import regex
66
import k8s.apimachinery.pkg.apis.meta.v1
7+
regex_match = regex.match
78

89

910
schema ContainerizedWorkload:
@@ -149,7 +150,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0EnvItems0:
149150

150151

151152
check:
152-
regex.match(str(name), r"^[-_a-zA-Z0-9]+$")
153+
regex_match(str(name), r"^[-_a-zA-Z0-9]+$")
153154

154155

155156
schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0LivenessProbe:
@@ -285,7 +286,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0PortsItems0:
285286

286287

287288
check:
288-
regex.match(str(name), r"^[a-z]+$")
289+
regex_match(str(name), r"^[a-z]+$")
289290

290291

291292
schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0ReadiessProbe:

0 commit comments

Comments
 (0)