diff --git a/examples/kube_resource/complex/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k b/examples/kube_resource/complex/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k index 01133a7..cffa465 100644 --- a/examples/kube_resource/complex/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k +++ b/examples/kube_resource/complex/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema ContainerizedWorkload: @@ -150,7 +150,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0EnvItems0: check: - regex_match(str(name), r"^[-_a-zA-Z0-9]+$") + _regex_match(str(name), r"^[-_a-zA-Z0-9]+$") schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0LivenessProbe: @@ -286,7 +286,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0PortsItems0: check: - regex_match(str(name), r"^[a-z]+$") + _regex_match(str(name), r"^[a-z]+$") schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0ReadiessProbe: diff --git a/pkg/kube_resource/generator/testdata/all_of_pattern/models/karpenter_k8s_aws_v1beta1_e_c2_node_class.k b/pkg/kube_resource/generator/testdata/all_of_pattern/models/karpenter_k8s_aws_v1beta1_e_c2_node_class.k index ac894d1..6d59a88 100644 --- a/pkg/kube_resource/generator/testdata/all_of_pattern/models/karpenter_k8s_aws_v1beta1_e_c2_node_class.k +++ b/pkg/kube_resource/generator/testdata/all_of_pattern/models/karpenter_k8s_aws_v1beta1_e_c2_node_class.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema EC2NodeClass: @@ -125,7 +125,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecAmiSelectorTermsItems0: check: - regex_match(str(id), r"ami-[0-9a-z]+") if id + _regex_match(str(id), r"ami-[0-9a-z]+") if id schema KarpenterK8sAwsV1beta1EC2NodeClassSpecBlockDeviceMappingsItems0: @@ -203,8 +203,8 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecBlockDeviceMappingsItems0Ebs: check: - regex_match(str(volumeSize), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if volumeSize - 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 + _regex_match(str(volumeSize), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if volumeSize + _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 schema KarpenterK8sAwsV1beta1EC2NodeClassSpecMetadataOptions: @@ -266,7 +266,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSecurityGroupSelectorTermsItems0: check: - regex_match(str(id), r"sg-[0-9a-z]+") if id + _regex_match(str(id), r"sg-[0-9a-z]+") if id schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSubnetSelectorTermsItems0: @@ -288,7 +288,7 @@ schema KarpenterK8sAwsV1beta1EC2NodeClassSpecSubnetSelectorTermsItems0: check: - regex_match(str(id), r"subnet-[0-9a-z]+") if id + _regex_match(str(id), r"subnet-[0-9a-z]+") if id schema KarpenterK8sAwsV1beta1EC2NodeClassStatus: diff --git a/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k b/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k index 6e0d8b2..6291771 100644 --- a/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k +++ b/pkg/kube_resource/generator/testdata/array_branch/models/operator_victoriametrics_com_v1beta1_vm_agent.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema VMAgent: @@ -372,8 +372,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpec: check: - regex_match(str(scrapeInterval), r"[0-9]+(ms|s|m|h)") if scrapeInterval - regex_match(str(scrapeTimeout), r"[0-9]+(ms|s|m|h)") if scrapeTimeout + _regex_match(str(scrapeInterval), r"[0-9]+(ms|s|m|h)") if scrapeInterval + _regex_match(str(scrapeTimeout), r"[0-9]+(ms|s|m|h)") if scrapeTimeout schema OperatorVictoriametricsComV1beta1VMAgentSpecAPIServerConfig: @@ -879,8 +879,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecResou check: - 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 - 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 + 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 + 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 schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0SpecSelector: @@ -958,8 +958,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0Status: check: - 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 - 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 + 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 + 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 schema OperatorVictoriametricsComV1beta1VMAgentSpecClaimTemplatesItems0StatusConditionsItems0: @@ -1737,7 +1737,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteItems0: check: - regex_match(str(sendTimeout), r"[0-9]+(ms|s|m|h)") if sendTimeout + _regex_match(str(sendTimeout), r"[0-9]+(ms|s|m|h)") if sendTimeout schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteItems0BasicAuth: @@ -2454,7 +2454,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecRemoteWriteSettings: check: - regex_match(str(flushInterval), r"[0-9]+(ms|s|m|h)") if flushInterval + _regex_match(str(flushInterval), r"[0-9]+(ms|s|m|h)") if flushInterval schema OperatorVictoriametricsComV1beta1VMAgentSpecResources: @@ -2476,8 +2476,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecResources: check: - 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 - 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 + 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 + 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 schema OperatorVictoriametricsComV1beta1VMAgentSpecRollingUpdate: @@ -2717,7 +2717,7 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageEmptyDir: check: - regex_match(str(sizeLimit), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if sizeLimit + _regex_match(str(sizeLimit), r"^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$") if sizeLimit schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplate: @@ -2877,8 +2877,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem check: - 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 - 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 + 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 + 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 schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateSpecSelector: @@ -2956,8 +2956,8 @@ schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTem check: - 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 - 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 + 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 + 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 schema OperatorVictoriametricsComV1beta1VMAgentSpecStatefulStorageVolumeClaimTemplateStatusConditionsItems0: diff --git a/pkg/kube_resource/generator/testdata/int_or_string_validation/models/crd_projectcalico_org_v1_global_network_policy.k b/pkg/kube_resource/generator/testdata/int_or_string_validation/models/crd_projectcalico_org_v1_global_network_policy.k index acb5ace..4513423 100644 --- a/pkg/kube_resource/generator/testdata/int_or_string_validation/models/crd_projectcalico_org_v1_global_network_policy.k +++ b/pkg/kube_resource/generator/testdata/int_or_string_validation/models/crd_projectcalico_org_v1_global_network_policy.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema GlobalNetworkPolicy: @@ -42,7 +42,7 @@ schema GlobalNetworkPolicy: check: - 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 + 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 schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestination: @@ -100,8 +100,8 @@ schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestination: check: - all notPorts in notPorts {regex_match(str(notPorts), r"^.*") if notPorts } if notPorts - all ports in ports {regex_match(str(ports), r"^.*") if ports } if ports + all notPorts in notPorts {_regex_match(str(notPorts), r"^.*") if notPorts } if notPorts + all ports in ports {_regex_match(str(ports), r"^.*") if ports } if ports schema CrdProjectcalicoOrgV1GlobalNetworkPolicyDestinationServiceAccounts: diff --git a/pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k b/pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k index 9679439..edbc842 100644 --- a/pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k +++ b/pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema OperatorConfiguration: @@ -294,10 +294,10 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationConnectionPooler: check: - regex_match(str(connection_pooler_default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_limit - regex_match(str(connection_pooler_default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_request - regex_match(str(connection_pooler_default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_limit - regex_match(str(connection_pooler_default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_request + _regex_match(str(connection_pooler_default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_limit + _regex_match(str(connection_pooler_default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if connection_pooler_default_cpu_request + _regex_match(str(connection_pooler_default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_limit + _regex_match(str(connection_pooler_default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if connection_pooler_default_memory_request connection_pooler_number_of_instances >= 1 if connection_pooler_number_of_instances not in [None, Undefined] @@ -714,11 +714,11 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationLogicalBackup: check: - regex_match(str(logical_backup_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_limit - regex_match(str(logical_backup_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_request - regex_match(str(logical_backup_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_limit - regex_match(str(logical_backup_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_request - regex_match(str(logical_backup_schedule), r"^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$") if logical_backup_schedule + _regex_match(str(logical_backup_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_limit + _regex_match(str(logical_backup_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if logical_backup_cpu_request + _regex_match(str(logical_backup_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_limit + _regex_match(str(logical_backup_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if logical_backup_memory_request + _regex_match(str(logical_backup_schedule), r"^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$") if logical_backup_schedule schema AcidZalanDoV1OperatorConfigurationConfigurationMajorVersionUpgrade: @@ -804,14 +804,14 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationPostgresPodResources: check: - regex_match(str(default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_limit - regex_match(str(default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_request - regex_match(str(default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_limit - regex_match(str(default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_request - regex_match(str(max_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if max_cpu_request - regex_match(str(max_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if max_memory_request - regex_match(str(min_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if min_cpu_limit - regex_match(str(min_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if min_memory_limit + _regex_match(str(default_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_limit + _regex_match(str(default_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if default_cpu_request + _regex_match(str(default_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_limit + _regex_match(str(default_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if default_memory_request + _regex_match(str(max_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if max_cpu_request + _regex_match(str(max_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if max_memory_request + _regex_match(str(min_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if min_cpu_limit + _regex_match(str(min_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if min_memory_limit schema AcidZalanDoV1OperatorConfigurationConfigurationScalyr: @@ -853,10 +853,10 @@ schema AcidZalanDoV1OperatorConfigurationConfigurationScalyr: check: - regex_match(str(scalyr_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_limit - regex_match(str(scalyr_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_request - regex_match(str(scalyr_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_limit - regex_match(str(scalyr_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_request + _regex_match(str(scalyr_cpu_limit), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_limit + _regex_match(str(scalyr_cpu_request), r"^(\d+m|\d+(\.\d{1,3})?)$") if scalyr_cpu_request + _regex_match(str(scalyr_memory_limit), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_limit + _regex_match(str(scalyr_memory_request), r"^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$") if scalyr_memory_request schema AcidZalanDoV1OperatorConfigurationConfigurationTeamsAPI: diff --git a/pkg/kube_resource/generator/testdata/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k b/pkg/kube_resource/generator/testdata/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k index 01133a7..cffa465 100644 --- a/pkg/kube_resource/generator/testdata/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k +++ b/pkg/kube_resource/generator/testdata/muti_models/models/core_oam_dev_v1alpha2_containerized_workload.k @@ -4,7 +4,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c """ import regex import k8s.apimachinery.pkg.apis.meta.v1 -regex_match = regex.match +_regex_match = regex.match schema ContainerizedWorkload: @@ -150,7 +150,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0EnvItems0: check: - regex_match(str(name), r"^[-_a-zA-Z0-9]+$") + _regex_match(str(name), r"^[-_a-zA-Z0-9]+$") schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0LivenessProbe: @@ -286,7 +286,7 @@ schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0PortsItems0: check: - regex_match(str(name), r"^[a-z]+$") + _regex_match(str(name), r"^[a-z]+$") schema CoreOamDevV1alpha2ContainerizedWorkloadSpecContainersItems0ReadiessProbe: diff --git a/pkg/swagger/generator/templates/header.gotmpl b/pkg/swagger/generator/templates/header.gotmpl index 707aeab..496ad76 100644 --- a/pkg/swagger/generator/templates/header.gotmpl +++ b/pkg/swagger/generator/templates/header.gotmpl @@ -19,7 +19,7 @@ Editing this file might prove futile when you re-run the KCL auto-gen generate c import {{ .ImportPath }}{{ if .MustAsName }} as {{ .AsName }}{{ end }} {{- end }} {{- if .HasPatternValidation }} -regex_match = regex.match +_regex_match = regex.match {{- end }} {{- end }} {{ "\n" -}} diff --git a/pkg/swagger/generator/templates/schemaexpr.gotmpl b/pkg/swagger/generator/templates/schemaexpr.gotmpl index 6d0726b..2494176 100644 --- a/pkg/swagger/generator/templates/schemaexpr.gotmpl +++ b/pkg/swagger/generator/templates/schemaexpr.gotmpl @@ -6,7 +6,7 @@ {{- end }} {{- if .MinLength }}len({{ .EscapedName }}) >= {{.MinLength}}{{ if not .Required }} if {{ .EscapedName }} not in [None, Undefined]{{ end }} {{- end }} -{{- if .Pattern }}regex_match(str({{ .EscapedName }}), r"{{.Pattern}}"){{ if not .Required }} if {{ .EscapedName }}{{ end }} +{{- if .Pattern }}_regex_match(str({{ .EscapedName }}), r"{{.Pattern}}"){{ if not .Required }} if {{ .EscapedName }}{{ end }} {{- end }} {{- if .UniqueItems }}isunique({{ .EscapedName }}){{ if not .Required }} if {{ .EscapedName }}{{ end }} {{- end }} diff --git a/pkg/swagger/generator/templates/schemavalidator.gotmpl b/pkg/swagger/generator/templates/schemavalidator.gotmpl index 8f0d78e..c7a4ee8 100644 --- a/pkg/swagger/generator/templates/schemavalidator.gotmpl +++ b/pkg/swagger/generator/templates/schemavalidator.gotmpl @@ -14,7 +14,7 @@ len({{ .EscapedName }}) >= {{.MinLength}}{{ if not .Required }} if {{ .EscapedName }}{{ end }} {{- end }} {{- if .Pattern }} - regex_match(str({{ .EscapedName }}), r"{{.Pattern}}"){{ if not .Required }} if {{ .EscapedName }}{{ end }} + _regex_match(str({{ .EscapedName }}), r"{{.Pattern}}"){{ if not .Required }} if {{ .EscapedName }}{{ end }} {{- end }} {{- if .UniqueItems }} isunique({{ .EscapedName }}){{ if not .Required }} if {{ .EscapedName }}{{ end }}