// Copyright 2019. PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package schema

import (
	"fmt"
	"strings"

	"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
	"k8s.io/apimachinery/pkg/util/yaml"
)

// Generated from kubebuilder
// TODO: add auto generation and verification
const crdYaml string = `apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.2.2
  creationTimestamp: null
  name: tidbclusterconfigs.tep.pingcap.com
spec:
  group: tep.pingcap.com
  names:
    kind: TiDBClusterConfig
    listKind: TiDBClusterConfigList
    plural: tidbclusterconfigs
    singular: tidbclusterconfig
  scope: ""
  validation:
    openAPIV3Schema:
      properties:
        apiVersion:
          description: 'APIVersion defines the versioned schema of this representation
            of an object. Servers should convert recognized schemas to the latest
            internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
          type: string
        kind:
          description: 'Kind is a string value representing the REST resource this
            object represents. Servers may infer this from the endpoint the client
            submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
          type: string
        metadata:
          type: object
        pd-config:
          description: PDConfig is the configuration of pd-server
          properties:
            auto-compaction-mode:
              description: AutoCompactionMode is either 'periodic' or 'revision'.
                The default value is 'periodic'.
              type: string
            auto-compaction-retention-v2:
              description: AutoCompactionRetention is either duration string with
                time unit (e.g. '5m' for 5-minute), or revision unit (e.g. '5000').
                If no time unit is provided and compaction mode is 'periodic', the
                unit defaults to hour. For example, '5' translates into 5-hour. The
                default retention is 1 hour. Before etcd v3.3.x, the type of retention
                is int. We add 'v2' suffix to make it backward compatible.
              type: string
            cluster-version:
              type: string
            election-interval:
              description: ElectionInterval is the interval for etcd Raft election.
              type: string
            enable-grpc-gateway:
              description: 'Optional: Defaults to true'
              type: boolean
            enable-prevote:
              description: 'Prevote is true to enable Raft Pre-Vote. If enabled, Raft
                runs an additional election phase to check whether it would get enough
                votes to win an election, thus minimizing disruptions. Optional: Defaults
                to true'
              type: boolean
            force-new-cluster:
              type: boolean
            label-property:
              additionalProperties:
                items:
                  description: PDStoreLabel is the config item of LabelPropertyConfig.
                  properties:
                    key:
                      type: string
                    value:
                      type: string
                  type: object
                type: array
              type: object
            lease:
              description: 'LeaderLease time, if leader doesn''t update its TTL in
                etcd after lease time, etcd will expire the leader key and other servers
                can campaign the leader again. Etcd only supports seconds TTL, so
                here is second too. Optional: Defaults to 3'
              format: int64
              type: integer
            log:
              description: Log related config.
              properties:
                development:
                  description: Development puts the logger in development mode, which
                    changes the behavior of DPanicLevel and takes stacktraces more
                    liberally.
                  type: boolean
                disable-caller:
                  description: DisableCaller stops annotating logs with the calling
                    function's file name and line number. By default, all logs are
                    annotated.
                  type: boolean
                disable-error-verbose:
                  description: DisableErrorVerbose stops annotating logs with the
                    full verbose error message.
                  type: boolean
                disable-stacktrace:
                  description: DisableStacktrace completely disables automatic stacktrace
                    capturing. By default, stacktraces are captured for WarnLevel
                    and above logs in development and ErrorLevel and above in production.
                  type: boolean
                disable-timestamp:
                  description: Disable automatic timestamps in output.
                  type: boolean
                file:
                  description: File log config.
                  properties:
                    filename:
                      description: Log filename, leave empty to disable file log.
                      type: string
                    log-rotate:
                      description: Is log rotate enabled.
                      type: boolean
                    max-backups:
                      description: Maximum number of old log files to retain.
                      type: integer
                    max-days:
                      description: Max log keep days, default is never deleting.
                      type: integer
                    max-size:
                      description: Max size for a single file, in MB.
                      type: integer
                  type: object
                format:
                  description: Log format. one of json, text, or console.
                  type: string
                level:
                  description: 'Log level. Optional: Defaults to info'
                  type: string
              type: object
            log-file:
              description: Backward compatibility.
              type: string
            log-level:
              type: string
            metric:
              properties:
                address:
                  type: string
                interval:
                  type: string
                job:
                  type: string
              type: object
            namespace:
              additionalProperties:
                description: PDNamespaceConfig is to overwrite the global setting
                  for specific namespace
                properties:
                  hot-region-schedule-limit:
                    description: HotRegionScheduleLimit is the max coexist hot region
                      schedules.
                    format: int64
                    type: integer
                  leader-schedule-limit:
                    description: LeaderScheduleLimit is the max coexist leader schedules.
                    format: int64
                    type: integer
                  max-replicas:
                    description: MaxReplicas is the number of replicas for each region.
                    format: int64
                    type: integer
                  merge-schedule-limit:
                    description: MergeScheduleLimit is the max coexist merge schedules.
                    format: int64
                    type: integer
                  region-schedule-limit:
                    description: RegionScheduleLimit is the max coexist region schedules.
                    format: int64
                    type: integer
                  replica-schedule-limit:
                    description: ReplicaScheduleLimit is the max coexist replica schedules.
                    format: int64
                    type: integer
                type: object
              type: object
            namespace-classifier:
              description: 'NamespaceClassifier is for classifying stores/regions
                into different namespaces. Optional: Defaults to true'
              type: string
            pd-server:
              description: PDServerConfig is the configuration for pd server.
              properties:
                use-region-storage:
                  description: UseRegionStorage enables the independent region storage.
                  type: boolean
              type: object
            quota-backend-bytes:
              description: QuotaBackendBytes Raise alarms when backend size exceeds
                the given quota. 0 means use the default quota. the default size is
                2GB, the maximum is 8GB.
              type: string
            replication:
              description: Immutable, change should be made through pd-ctl after cluster
                creation
              properties:
                location-labels:
                  description: The label keys specified the location of a store. The
                    placement priorities is implied by the order of label keys. For
                    example, ["zone", "rack"] means that we should place replicas
                    to different zones first, then to different racks if we don't
                    have enough zones. Immutable, change should be made through pd-ctl
                    after cluster creation
                  items:
                    type: string
                  type: array
                max-replicas:
                  description: 'MaxReplicas is the number of replicas for each region.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 3'
                  format: int64
                  type: integer
                strictly-match-label:
                  description: StrictlyMatchLabel strictly checks if the label of
                    TiKV is matched with LocaltionLabels. Immutable, change should
                    be made through pd-ctl after cluster creation
                  type: boolean
              type: object
            schedule:
              description: Immutable, change should be made through pd-ctl after cluster
                creation
              properties:
                disable-location-replacement:
                  description: DisableLocationReplacement is the option to prevent
                    replica checker from moving replica to a better location. Immutable,
                    change should be made through pd-ctl after cluster creation
                  type: boolean
                disable-make-up-replica:
                  description: DisableMakeUpReplica is the option to prevent replica
                    checker from making up replicas when replica count is less than
                    expected. Immutable, change should be made through pd-ctl after
                    cluster creation
                  type: boolean
                disable-namespace-relocation:
                  description: DisableNamespaceRelocation is the option to prevent
                    namespace checker from moving replica to the target namespace.
                    Immutable, change should be made through pd-ctl after cluster
                    creation
                  type: boolean
                disable-raft-learner:
                  description: DisableLearner is the option to disable using AddLearnerNode
                    instead of AddNode Immutable, change should be made through pd-ctl
                    after cluster creation
                  type: boolean
                disable-remove-down-replica:
                  description: DisableRemoveDownReplica is the option to prevent replica
                    checker from removing down replicas. Immutable, change should
                    be made through pd-ctl after cluster creation
                  type: boolean
                disable-remove-extra-replica:
                  description: DisableRemoveExtraReplica is the option to prevent
                    replica checker from removing extra replicas. Immutable, change
                    should be made through pd-ctl after cluster creation
                  type: boolean
                disable-replace-offline-replica:
                  description: DisableReplaceOfflineReplica is the option to prevent
                    replica checker from repalcing offline replicas. Immutable, change
                    should be made through pd-ctl after cluster creation
                  type: boolean
                high-space-ratio:
                  description: HighSpaceRatio is the highest usage ratio of store
                    which regraded as high space. High space means there is a lot
                    of spare capacity, and store region score varies directly with
                    used size. Immutable, change should be made through pd-ctl after
                    cluster creation
                hot-region-cache-hits-threshold:
                  description: HotRegionCacheHitThreshold is the cache hits threshold
                    of the hot region. If the number of times a region hits the hot
                    cache is greater than this threshold, it is considered a hot region.
                    Immutable, change should be made through pd-ctl after cluster
                    creation
                  format: int64
                  type: integer
                hot-region-schedule-limit:
                  description: 'HotRegionScheduleLimit is the max coexist hot region
                    schedules. Immutable, change should be made through pd-ctl after
                    cluster creation Optional: Defaults to 4'
                  format: int64
                  type: integer
                leader-schedule-limit:
                  description: 'LeaderScheduleLimit is the max coexist leader schedules.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 4'
                  format: int64
                  type: integer
                low-space-ratio:
                  description: "     high space stage         transition stage           low
                    space stage   |--------------------|-----------------------------|-------------------------|
                    \  ^                    ^                             ^                         ^
                    \  0       HighSpaceRatio * capacity       LowSpaceRatio * capacity
                    \         capacity \n LowSpaceRatio is the lowest usage ratio
                    of store which regraded as low space. When in low space, store
                    region score increases to very large and varies inversely with
                    available size. Immutable, change should be made through pd-ctl
                    after cluster creation"
                max-merge-region-keys:
                  description: 'Immutable, change should be made through pd-ctl after
                    cluster creation Optional: Defaults to 200000'
                  format: int64
                  type: integer
                max-merge-region-size:
                  description: 'If both the size of region is smaller than MaxMergeRegionSize
                    and the number of rows in region is smaller than MaxMergeRegionKeys,
                    it will try to merge with adjacent regions. Immutable, change
                    should be made through pd-ctl after cluster creation Optional:
                    Defaults to 20'
                  format: int64
                  type: integer
                max-pending-peer-count:
                  description: 'Immutable, change should be made through pd-ctl after
                    cluster creation Optional: Defaults to 16'
                  format: int64
                  type: integer
                max-snapshot-count:
                  description: 'If the snapshot count of one store is greater than
                    this value, it will never be used as a source or target store.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 3'
                  format: int64
                  type: integer
                max-store-down-time:
                  description: 'MaxStoreDownTime is the max duration after which a
                    store will be considered to be down if it hasn''t reported heartbeats.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 30m'
                  type: string
                merge-schedule-limit:
                  description: 'MergeScheduleLimit is the max coexist merge schedules.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 8'
                  format: int64
                  type: integer
                patrol-region-interval:
                  description: PatrolRegionInterval is the interval for scanning region
                    during patrol. Immutable, change should be made through pd-ctl
                    after cluster creation
                  type: string
                region-schedule-limit:
                  description: 'RegionScheduleLimit is the max coexist region schedules.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 2048'
                  format: int64
                  type: integer
                replica-schedule-limit:
                  description: 'ReplicaScheduleLimit is the max coexist replica schedules.
                    Immutable, change should be made through pd-ctl after cluster
                    creation Optional: Defaults to 64'
                  format: int64
                  type: integer
                schedulers-v2:
                  description: Schedulers support for loding customized schedulers
                    Immutable, change should be made through pd-ctl after cluster
                    creation
                  items:
                    description: PDSchedulerConfig is customized scheduler configuration
                    properties:
                      args:
                        description: Immutable, change should be made through pd-ctl
                          after cluster creation
                        items:
                          type: string
                        type: array
                      disable:
                        description: Immutable, change should be made through pd-ctl
                          after cluster creation
                        type: boolean
                      type:
                        description: Immutable, change should be made through pd-ctl
                          after cluster creation
                        type: string
                    type: object
                  type: array
                split-merge-interval:
                  description: 'SplitMergeInterval is the minimum interval time to
                    permit merge after split. Immutable, change should be made through
                    pd-ctl after cluster creation Optional: Defaults to 1h'
                  type: string
                tolerant-size-ratio:
                  description: TolerantSizeRatio is the ratio of buffer size for balance
                    scheduler. Immutable, change should be made through pd-ctl after
                    cluster creation
              type: object
            security:
              description: PDSecurityConfig is the configuration for supporting tls.
              properties:
                cacert-path:
                  description: CAPath is the path of file that contains list of trusted
                    SSL CAs. if set, following four settings shouldn't be empty
                  type: string
                cert-path:
                  description: CertPath is the path of file that contains X509 certificate
                    in PEM format.
                  type: string
                key-path:
                  description: KeyPath is the path of file that contains X509 key
                    in PEM format.
                  type: string
              type: object
            tikv-interval:
              description: TickInterval is the interval for etcd Raft tick.
              type: string
            tso-save-interval:
              description: 'TsoSaveInterval is the interval to save timestamp. Optional:
                Defaults to 3s'
              type: string
          type: object
        tidb-config:
          description: TiDBConfig is the configuration of tidb-server
          properties:
            alter-primary-key:
              description: 'Optional: Defaults to false'
              type: boolean
            binlog:
              description: Binlog is the config for binlog.
              properties:
                binlog-socket:
                  description: Use socket file to write binlog, for compatible with
                    kafka version tidb-binlog.
                  type: string
                ignore-error:
                  description: If IgnoreError is true, when writing binlog meets error,
                    TiDB would ignore the error.
                  type: boolean
                strategy:
                  description: 'The strategy for sending binlog to pump, value can
                    be "range,omitempty" or "hash,omitempty" now. Optional: Defaults
                    to range'
                  type: string
                write-timeout:
                  description: 'Optional: Defaults to 15s'
                  type: string
              type: object
            check-mb4-value-in-utf8:
              description: 'Optional: Defaults to true'
              type: boolean
            compatible-kill-query:
              type: boolean
            cors:
              type: string
            enable-batch-dml:
              description: 'Optional: Defaults to false'
              type: boolean
            enable-streaming:
              description: 'Optional: Defaults to false'
              type: boolean
            lease:
              description: 'Optional: Defaults to 45s'
              type: string
            log:
              description: Log is the log section of config.
              properties:
                disable-timestamp:
                  description: Disable automatic timestamps in output.
                  type: boolean
                expensive-threshold:
                  description: 'Optional: Defaults to 10000'
                  type: integer
                file:
                  description: File log config.
                  properties:
                    filename:
                      description: Log filename, leave empty to disable file log.
                      type: string
                    log-rotate:
                      description: Is log rotate enabled.
                      type: boolean
                    max-backups:
                      description: Maximum number of old log files to retain.
                      type: integer
                    max-days:
                      description: Max log keep days, default is never deleting.
                      type: integer
                    max-size:
                      description: Max size for a single file, in MB.
                      type: integer
                  type: object
                format:
                  description: 'Log format. one of json, text, or console. Optional:
                    Defaults to text'
                  type: string
                level:
                  description: 'Log level. Optional: Defaults to info'
                  type: string
                query-log-max-len:
                  description: 'Optional: Defaults to 2048'
                  format: int64
                  type: integer
                record-plan-in-slow-log:
                  description: 'Optional: Defaults to 1'
                  format: int32
                  type: integer
                slow-threshold:
                  description: 'Optional: Defaults to 300'
                  format: int64
                  type: integer
              type: object
            lower-case-table-names:
              type: integer
            mem-quota-query:
              description: 'Optional: Defaults to 34359738368'
              format: int64
              type: integer
            oom-action:
              description: 'Optional: Defaults to log'
              type: string
            opentracing:
              description: OpenTracing is the opentracing section of the config.
              properties:
                enable:
                  description: 'Optional: Defaults to false'
                  type: boolean
                reporter:
                  description: OpenTracingReporter is the config for opentracing reporter.
                    See https://godoc.org/github.com/uber/jaeger-client-go/config#ReporterConfig
                  properties:
                    buffer-flush-interval:
                      description: A Duration represents the elapsed time between
                        two instants as an int64 nanosecond count. The representation
                        limits the largest representable duration to approximately
                        290 years.
                      format: int64
                      type: integer
                    local-agent-host-port:
                      type: string
                    log-spans:
                      type: boolean
                    queue-size:
                      type: integer
                  type: object
                rpc-metrics:
                  type: boolean
                sampler:
                  description: OpenTracingSampler is the config for opentracing sampler.
                    See https://godoc.org/github.com/uber/jaeger-client-go/config#SamplerConfig
                  properties:
                    max-operations:
                      type: integer
                    param: {}
                    sampling-refresh-interval:
                      description: A Duration represents the elapsed time between
                        two instants as an int64 nanosecond count. The representation
                        limits the largest representable duration to approximately
                        290 years.
                      format: int64
                      type: integer
                    sampling-server-url:
                      type: string
                    type:
                      type: string
                  type: object
              type: object
            performance:
              description: Performance is the performance section of the config.
              properties:
                bind-info-lease:
                  description: 'Optional: Defaults to 3s'
                  type: string
                cross-join:
                  description: 'Optional: Defaults to true'
                  type: boolean
                feedback-probability:
                  description: 'Optional: Defaults to 0.05'
                force-priority:
                  description: 'Optional: Defaults to NO_PRIORITY'
                  type: string
                max-memory:
                  description: 'Optional: Defaults to 0'
                  format: int64
                  type: integer
                max-procs:
                  type: integer
                pseudo-estimate-ratio:
                  description: 'Optional: Defaults to 0.8'
                query-feedback-limit:
                  description: 'Optional: Defaults to 1024'
                  type: integer
                run-auto-analyze:
                  description: 'Optional: Defaults to true'
                  type: boolean
                stats-lease:
                  description: 'Optional: Defaults to 3s'
                  type: string
                stmt-count-limit:
                  description: 'Optional: Defaults to 5000'
                  type: integer
                tcp-keep-alive:
                  description: 'Optional: Defaults to true'
                  type: boolean
                txn-entry-count-limit:
                  description: 'Optional: Defaults to 300000'
                  format: int64
                  type: integer
                txn-total-size-limit:
                  description: 'Optional: Defaults to 104857600'
                  format: int64
                  type: integer
              type: object
            pessimistic-txn:
              description: PessimisticTxn is the config for pessimistic transaction.
              properties:
                enable:
                  description: 'Enable must be true for ''begin lock'' or session
                    variable to start a pessimistic transaction. Optional: Defaults
                    to true'
                  type: boolean
                max-retry-count:
                  description: 'The max count of retry for a single statement in a
                    pessimistic transaction. Optional: Defaults to 256'
                  type: integer
              type: object
            plugin:
              description: Plugin is the config for plugin
              properties:
                dir:
                  type: string
                load:
                  type: string
              type: object
            prepared-plan-cache:
              description: PreparedPlanCache is the PreparedPlanCache section of the
                config.
              properties:
                capacity:
                  description: 'Optional: Defaults to 100'
                  type: integer
                enabled:
                  description: 'Optional: Defaults to false'
                  type: boolean
                memory-guard-ratio:
                  description: 'Optional: Defaults to 0.1'
              type: object
            proxy-protocol:
              description: ProxyProtocol is the PROXY protocol section of the config.
              properties:
                header-timeout:
                  description: PROXY protocol header read timeout, Unit is second.
                  type: integer
                networks:
                  description: PROXY protocol acceptable client networks. Empty *string
                    means disable PROXY protocol, * means all networks.
                  type: string
              type: object
            run-ddl:
              description: 'Optional: Defaults to true'
              type: boolean
            security:
              description: Security is the security section of the config.
              properties:
                cluster-ssl-ca:
                  type: string
                cluster-ssl-cert:
                  type: string
                cluster-ssl-key:
                  type: string
                skip-grant-table:
                  type: boolean
                ssl-ca:
                  type: string
                ssl-cert:
                  type: string
                ssl-key:
                  type: string
              type: object
            socket:
              type: string
            split-region-max-num:
              description: 'Optional: Defaults to 1000'
              format: int64
              type: integer
            split-table:
              description: 'Optional: Defaults to true'
              type: boolean
            status:
              description: Status is the status section of the config.
              properties:
                metrics-addr:
                  type: string
                metrics-interval:
                  description: 'Optional: Defaults to 15'
                  type: integer
                record-db-qps:
                  description: 'Optional: Defaults to false'
                  type: boolean
                report-status:
                  description: 'Optional: Defaults to true'
                  type: boolean
              type: object
            stmt-summary:
              description: StmtSummary is the config for statement summary.
              properties:
                max-sql-length:
                  description: 'The maximum length of displayed normalized SQL and
                    sample SQL. Optional: Defaults to 4096'
                  type: integer
                max-stmt-count:
                  description: 'The maximum number of statements kept in memory. Optional:
                    Defaults to 100'
                  type: integer
              type: object
            tikv-client:
              description: TiKVClient is the config for tikv client.
              properties:
                batch-wait-size:
                  description: 'BatchWaitSize is the max wait size for batch. Optional:
                    Defaults to 8'
                  type: integer
                commit-timeout:
                  description: 'CommitTimeout is the max time which command ''commit''
                    will wait. Optional: Defaults to 41s'
                  type: string
                grpc-connection-count:
                  description: 'GrpcConnectionCount is the max gRPC connections that
                    will be established with each tikv-server. Optional: Defaults
                    to 16'
                  type: integer
                grpc-keepalive-time:
                  description: 'After a duration of this time in seconds if the client
                    doesn''t see any activity it pings the server to see if the transport
                    is still alive. Optional: Defaults to 10'
                  type: integer
                grpc-keepalive-timeout:
                  description: 'After having pinged for keepalive check, the client
                    waits for a duration of Timeout in seconds and if no activity
                    is seen even after that the connection is closed. Optional: Defaults
                    to 3'
                  type: integer
                max-batch-size:
                  description: 'MaxBatchSize is the max batch size when calling batch
                    commands API. Optional: Defaults to 128'
                  type: integer
                max-batch-wait-time:
                  description: 'MaxBatchWaitTime in nanosecond is the max wait time
                    for batch. Optional: Defaults to 0'
                  format: int64
                  type: integer
                max-txn-time-use:
                  description: 'MaxTxnTimeUse is the max time a Txn may use (in seconds)
                    from its startTS to commitTS. Optional: Defaults to 590'
                  type: integer
                overload-threshold:
                  description: 'If TiKV load is greater than this, TiDB will wait
                    for a while to avoid little batch. Optional: Defaults to 200'
                  type: integer
                region-cache-ttl:
                  description: 'If a Region has not been accessed for more than the
                    given duration (in seconds), it will be reloaded from the PD.
                    Optional: Defaults to 600'
                  type: integer
                store-limit:
                  description: 'If a store has been up to the limit, it will return
                    error for successive request to prevent the store occupying too
                    much token in dispatching level. Optional: Defaults to 0'
                  format: int64
                  type: integer
              type: object
            token-limit:
              description: 'Optional: Defaults to 1000'
              type: integer
            treat-old-version-utf8-as-utf8mb4:
              description: 'Optional: Defaults to true'
              type: boolean
            txn-local-latches:
              description: TxnLocalLatches is the TxnLocalLatches section of the config.
              properties:
                capacity:
                  type: integer
                enabled:
                  type: boolean
              type: object
          type: object
        tikv-config:
          description: TiKVConfig is the configuration of TiKV.
          properties:
            coprocessor:
              description: TiKVCoprocessorConfig is the configuration of TiKV Coprocessor
                component.
              properties:
                batch-split-limit:
                  description: One split check produces several split keys in batch.
                    This config limits the number of produced split keys in one batch.
                    optional
                  format: int64
                  type: integer
                region-max-keys:
                  description: 'When the number of keys in Region [a,e) exceeds the
                    region_max_keys, it will be split into several Regions [a,b),
                    [b,c), [c,d), [d,e) and the number of keys in [a,b), [b,c), [c,d)
                    will be region_split_keys. See also: region-split-keys Optional:
                    Defaults to 1440000 optional'
                  format: int64
                  type: integer
                region-max-size:
                  description: 'When Region [a,e) size exceeds region_max_size,
                    it will be split into several Regions [a,b), [b,c), [c,d), [d,e)
                    and the size of [a,b), [b,c), [c,d) will be region_split_size
                    (or a little larger). See also: region-split-size Optional: Defaults
                    to 144MB optional'
                  type: string
                region-split-keys:
                  description: 'When the number of keys in Region [a,e) exceeds the
                    region_max_keys, it will be split into several Regions [a,b),
                    [b,c), [c,d), [d,e) and the number of keys in [a,b), [b,c), [c,d)
                    will be region_split_keys. See also: region-max-keys Optional:
                    Defaults to 960000 optional'
                  format: int64
                  type: integer
                region-split-size:
                  description: 'When Region [a,e) size exceeds region_max_size,
                    it will be split into several Regions [a,b), [b,c), [c,d), [d,e)
                    and the size of [a,b), [b,c), [c,d) will be region_split_size
                    (or a little larger). See also: region-max-size Optional: Defaults
                    to 96MB optional'
                  type: string
                split-region-on-table:
                  description: 'When it is set to true, TiKV will try to split a
                    Region with table prefix if that Region crosses tables. It is
                    recommended to turn off this option if there will be a large number
                    of tables created. Optional: Defaults to false optional'
                  type: boolean
              type: object
            gc:
              properties:
                "\tbatch_keys":
                  description: 'Optional: Defaults to 512'
                  format: int64
                  type: integer
                "\tmax_write_bytes_per_sec":
                  type: string
              type: object
            import:
              properties:
                import_dir:
                  type: string
                max_open_engines:
                  format: int64
                  type: integer
                max_prepare_duration:
                  type: string
                num_import_jobs:
                  format: int64
                  type: integer
                num_import_sst_jobs:
                  format: int64
                  type: integer
                num_threads:
                  format: int64
                  type: integer
                region_split_size:
                  type: string
                stream_channel_window:
                  format: int64
                  type: integer
                upload_speed_limit:
                  type: string
              type: object
            log-file:
              type: string
            log-level:
              description: 'Optional: Defaults to info'
              type: string
            log-rotation-timespan:
              description: 'Optional: Defaults to 24h'
              type: string
            panic-when-unexpected-key-or-data:
              type: boolean
            pd:
              properties:
                endpoints:
                  description: "The PD endpoints for the client. \n Default is empty."
                  items:
                    type: string
                  type: array
                retry_interval:
                  description: "The interval at which to retry a PD connection initialization.
                    \n Default is 300ms. Optional: Defaults to 300ms"
                  type: string
                retry_log_every:
                  description: "If the client observes the same error message on retry,
                    it can repeat the message only every n times. \n Default is
                    10. Set to 1 to disable this feature. Optional: Defaults to 10"
                  format: int64
                  type: integer
                retry_max_count:
                  description: "The maximum number of times to retry a PD connection
                    initialization. \n Default is isize::MAX, represented by -1. Optional:
                    Defaults to -1"
                  format: int64
                  type: integer
              type: object
            raftdb:
              properties:
                allow_concurrent_memtable_write:
                  type: boolean
                bytes_per_sync:
                  type: string
                compaction_readahead_size:
                  type: string
                create_if_missing:
                  type: boolean
                defaultcf:
                  description: TiKVCfConfig is the config of a cf
                  properties:
                    block-based-bloom-filter:
                      type: boolean
                    block-cache-size:
                      type: string
                    block-size:
                      type: string
                    bloom-filter-bits-per-key:
                      format: int64
                      type: integer
                    cache-index-and-filter-blocks:
                      type: boolean
                    compaction-pri:
                      format: int64
                      type: integer
                    compaction-style:
                      format: int64
                      type: integer
                    compression-per-level:
                      items:
                        type: string
                      type: array
                    disable-auto-compactions:
                      type: boolean
                    disable-block-cache:
                      type: boolean
                    dynamic-level-bytes:
                      type: boolean
                    enable-doubly-skiplist:
                      type: boolean
                    force-consistency-checks:
                      type: boolean
                    hard-pending-compaction-bytes-limit:
                      type: string
                    level0-file-num-compaction-trigger:
                      format: int64
                      type: integer
                    level0-slowdown-writes-trigger:
                      format: int64
                      type: integer
                    level0-stop-writes-trigger:
                      format: int64
                      type: integer
                    max-bytes-for-level-base:
                      type: string
                    max-bytes-for-level-multiplier:
                      format: int64
                      type: integer
                    max-compaction-bytes:
                      type: string
                    max-write-buffer-number:
                      format: int64
                      type: integer
                    min-write-buffer-number-to-merge:
                      format: int64
                      type: integer
                    num-levels:
                      format: int64
                      type: integer
                    optimize-filters-for-hits:
                      type: boolean
                    pin-l0-filter-and-index-blocks:
                      type: boolean
                    prop-keys-index-distance:
                      format: int64
                      type: integer
                    prop-size-index-distance:
                      format: int64
                      type: integer
                    read-amp-bytes-per-bit:
                      format: int64
                      type: integer
                    soft-pending-compaction-bytes-limit:
                      type: string
                    target-file-size-base:
                      type: string
                    titan:
                      description: TiKVTitanCfConfig is the titian config.
                      properties:
                        blob-cache-size:
                          type: string
                        blob-file-compression:
                          type: string
                        blob-run-mode:
                          type: string
                        discardable-ratio: {}
                        max-gc-batch-size:
                          type: string
                        merge-small-file-threshold:
                          type: string
                        min-blob-size:
                          type: string
                        min-gc-batch-size:
                          type: string
                        sample-ratio: {}
                      type: object
                    use-bloom-filter:
                      type: boolean
                    whole-key-filtering:
                      type: boolean
                    write-buffer-size:
                      type: string
                  type: object
                enable_pipelined_write:
                  type: boolean
                enable_statistics:
                  type: boolean
                info_log_dir:
                  type: string
                info_log_keep_log_file_num:
                  format: int64
                  type: integer
                info_log_max_size:
                  type: string
                info_log_roll_time:
                  type: string
                max_background_jobs:
                  format: int64
                  type: integer
                max_manifest_file_size:
                  type: string
                max_open_files:
                  format: int64
                  type: integer
                max_sub_compactions:
                  format: int64
                  type: integer
                max_total_wal_size:
                  type: string
                stats_dump_period:
                  type: string
                use_direct_io_for_flush_and_compaction:
                  type: boolean
                wal_bytes_per_sync:
                  type: string
                wal_dir:
                  type: string
                wal_recovery_mode:
                  type: string
                wal_size_limit:
                  type: string
                wal_ttl_seconds:
                  format: int64
                  type: integer
                writable_file_max_buffer_size:
                  type: string
              type: object
            raftstore:
              description: TiKVRaftstoreConfig is the configuration of TiKV raftstore
                component.
              properties:
                abnormal-leader-missing-duration:
                  description: / Similar to the max-leader-missing-duration, instead
                    it will log warnings and / try to alert monitoring systems, if
                    there is any.
                  type: string
                allow-remove-leader:
                  type: boolean
                apply-max-batch-size:
                  format: int64
                  type: integer
                apply-pool-size:
                  description: 'Optional: Defaults to 2'
                  format: int64
                  type: integer
                clean-stale-peer-delay:
                  description: 'delay time before deleting a stale peer Optional:
                    Defaults to 10m'
                  type: string
                cleanup-import-sst-interval:
                  description: 'Optional: Defaults to 10m'
                  type: string
                consistency-check-interval:
                  description: 'Interval (ms) to check region whether the data is
                    consistent. Optional: Defaults to 0'
                  type: string
                hibernate-regions:
                  type: boolean
                leader-transfer-max-log-lag:
                  format: int64
                  type: integer
                lock-cf-compact-bytes-threshold:
                  description: 'Optional: Defaults to 256MB'
                  type: string
                lock-cf-compact-interval:
                  description: 'Optional: Defaults to 10m'
                  type: string
                max-leader-missing-duration:
                  description: / If the leader of a peer is missing for longer than
                    max-leader-missing-duration / the peer would ask pd to confirm
                    whether it is valid in any region. / If the peer is stale and
                    is not valid in any region, it will destroy itself.
                  type: string
                max-peer-down-duration:
                  description: '/ When a peer is not active for max-peer-down-duration
                    / the peer is considered to be down and is reported to PD. Optional:
                    Defaults to 5m'
                  type: string
                merge-check-tick-interval:
                  description: / Interval to re-propose merge.
                  type: string
                merge-max-log-gap:
                  description: / Max log gap allowed to propose merge.
                  format: int64
                  type: integer
                messages-per-tick:
                  format: int64
                  type: integer
                notify-capacity:
                  format: int64
                  type: integer
                pd-heartbeat-tick-interval:
                  description: 'Optional: Defaults to 60s'
                  type: string
                pd-store-heartbeat-tick-interval:
                  description: 'Optional: Defaults to 10s'
                  type: string
                peer-stale-state-check-interval:
                  type: string
                prevote:
                  description: 'Optional: Defaults to true'
                  type: boolean
                raft-base-tick-interval:
                  description: raft-base-tick-interval is a base tick interval (ms).
                  type: string
                raft-election-timeout-ticks:
                  format: int64
                  type: integer
                raft-entry-cache-life-time:
                  description: When a peer is not responding for this time, leader
                    will not keep entry cache for it.
                  type: string
                raft-entry-max-size:
                  description: 'When the entry exceed the max size, reject to propose
                    it. Optional: Defaults to 8MB'
                  type: string
                raft-heartbeat-ticks:
                  format: int64
                  type: integer
                raft-log-gc-count-limit:
                  description: 'When entry count exceed this value, gc will be forced
                    trigger. Optional: Defaults to 72000'
                  format: int64
                  type: integer
                raft-log-gc-size-limit:
                  description: 'When the approximate size of raft log entries exceed
                    this value gc will be forced trigger. Optional: Defaults to 72MB'
                  type: string
                raft-log-gc-threshold:
                  description: 'A threshold to gc stale raft log, must >= 1. Optional:
                    Defaults to 50'
                  format: int64
                  type: integer
                raft-log-gc-tick-interval:
                  description: 'Interval to gc unnecessary raft log (ms). Optional:
                    Defaults to 10s'
                  type: string
                raft-reject-transfer-leader-duration:
                  description: When a peer is newly added, reject transferring leader
                    to the peer for a while.
                  type: string
                raft-store-max-leader-lease:
                  description: The lease provided by a successfully proposed and applied
                    entry.
                  type: string
                region-compact-check-interval:
                  description: '/ Interval (ms) to check whether start compaction
                    for a region. Optional: Defaults to 5m'
                  type: string
                region-compact-check-step:
                  description: '/ Number of regions for each time checking. Optional:
                    Defaults to 100'
                  format: int64
                  type: integer
                region-compact-min-tombstones:
                  description: '/ Minimum number of tombstones to trigger manual compaction.
                    Optional: Defaults to 10000'
                  format: int64
                  type: integer
                region-compact-tombstones-percent:
                  description: '/ Minimum percentage of tombstones to trigger manual
                    compaction. / Should between 1 and 100. Optional: Defaults to
                    30'
                  format: int64
                  type: integer
                region-split-check-diff:
                  description: '/ When size change of region exceed the diff since
                    last check, it / will be checked again whether it should be split.
                    Optional: Defaults to 6MB'
                  type: string
                report-region-flow-interval:
                  type: string
                right-derive-when-split:
                  description: Right region derive origin region id when split.
                  type: boolean
                snap-apply-batch-size:
                  type: string
                snap-gc-timeout:
                  type: string
                snap-mgr-gc-tick-interval:
                  type: string
                split-region-check-tick-interval:
                  description: 'Interval (ms) to check region whether need to be split
                    or not. Optional: Defaults to 10s'
                  type: string
                store-max-batch-size:
                  format: int64
                  type: integer
                store-pool-size:
                  description: 'Optional: Defaults to 2'
                  format: int64
                  type: integer
                sync-log:
                  description: 'true for high reliability, prevent data loss when
                    power failure. Optional: Defaults to true'
                  type: boolean
                use-delete-range:
                  type: boolean
              type: object
            readpool:
              properties:
                coprocessor:
                  properties:
                    high_concurrency:
                      description: 'Optional: Defaults to 8'
                      format: int64
                      type: integer
                    low_concurrency:
                      description: 'Optional: Defaults to 8'
                      format: int64
                      type: integer
                    max_tasks_per_worker_high:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    max_tasks_per_worker_low:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    max_tasks_per_worker_normal:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    normal_concurrency:
                      description: 'Optional: Defaults to 8'
                      format: int64
                      type: integer
                    stack_size:
                      description: 'Optional: Defaults to 10MB'
                      type: string
                  type: object
                storage:
                  properties:
                    high_concurrency:
                      description: 'Optional: Defaults to 4'
                      format: int64
                      type: integer
                    low_concurrency:
                      description: 'Optional: Defaults to 4'
                      format: int64
                      type: integer
                    max_tasks_per_worker_high:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    max_tasks_per_worker_low:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    max_tasks_per_worker_normal:
                      description: 'Optional: Defaults to 2000'
                      format: int64
                      type: integer
                    normal_concurrency:
                      description: 'Optional: Defaults to 4'
                      format: int64
                      type: integer
                    stack_size:
                      description: 'Optional: Defaults to 10MB'
                      type: string
                  type: object
              type: object
            rocksdb:
              description: TiKVDbConfig is the rocksdb config.
              properties:
                auto-tuned:
                  type: boolean
                bytes-per-sync:
                  type: string
                compaction-readahead-size:
                  description: 'Optional: Defaults to 0'
                  type: string
                create-if-missing:
                  description: 'Optional: Defaults to true'
                  type: boolean
                defaultcf:
                  description: TiKVCfConfig is the config of a cf
                  properties:
                    block-based-bloom-filter:
                      type: boolean
                    block-cache-size:
                      type: string
                    block-size:
                      type: string
                    bloom-filter-bits-per-key:
                      format: int64
                      type: integer
                    cache-index-and-filter-blocks:
                      type: boolean
                    compaction-pri:
                      format: int64
                      type: integer
                    compaction-style:
                      format: int64
                      type: integer
                    compression-per-level:
                      items:
                        type: string
                      type: array
                    disable-auto-compactions:
                      type: boolean
                    disable-block-cache:
                      type: boolean
                    dynamic-level-bytes:
                      type: boolean
                    enable-doubly-skiplist:
                      type: boolean
                    force-consistency-checks:
                      type: boolean
                    hard-pending-compaction-bytes-limit:
                      type: string
                    level0-file-num-compaction-trigger:
                      format: int64
                      type: integer
                    level0-slowdown-writes-trigger:
                      format: int64
                      type: integer
                    level0-stop-writes-trigger:
                      format: int64
                      type: integer
                    max-bytes-for-level-base:
                      type: string
                    max-bytes-for-level-multiplier:
                      format: int64
                      type: integer
                    max-compaction-bytes:
                      type: string
                    max-write-buffer-number:
                      format: int64
                      type: integer
                    min-write-buffer-number-to-merge:
                      format: int64
                      type: integer
                    num-levels:
                      format: int64
                      type: integer
                    optimize-filters-for-hits:
                      type: boolean
                    pin-l0-filter-and-index-blocks:
                      type: boolean
                    prop-keys-index-distance:
                      format: int64
                      type: integer
                    prop-size-index-distance:
                      format: int64
                      type: integer
                    read-amp-bytes-per-bit:
                      format: int64
                      type: integer
                    soft-pending-compaction-bytes-limit:
                      type: string
                    target-file-size-base:
                      type: string
                    titan:
                      description: TiKVTitanCfConfig is the titian config.
                      properties:
                        blob-cache-size:
                          type: string
                        blob-file-compression:
                          type: string
                        blob-run-mode:
                          type: string
                        discardable-ratio: {}
                        max-gc-batch-size:
                          type: string
                        merge-small-file-threshold:
                          type: string
                        min-blob-size:
                          type: string
                        min-gc-batch-size:
                          type: string
                        sample-ratio: {}
                      type: object
                    use-bloom-filter:
                      type: boolean
                    whole-key-filtering:
                      type: boolean
                    write-buffer-size:
                      type: string
                  type: object
                enable-pipelined-write:
                  type: boolean
                enable-statistics:
                  description: 'Optional: Defaults to true'
                  type: boolean
                info-log-dir:
                  type: string
                info-log-keep-log-file-num:
                  format: int64
                  type: integer
                info-log-max-size:
                  type: string
                info-log-roll-time:
                  type: string
                lockcf:
                  description: TiKVCfConfig is the config of a cf
                  properties:
                    block-based-bloom-filter:
                      type: boolean
                    block-cache-size:
                      type: string
                    block-size:
                      type: string
                    bloom-filter-bits-per-key:
                      format: int64
                      type: integer
                    cache-index-and-filter-blocks:
                      type: boolean
                    compaction-pri:
                      format: int64
                      type: integer
                    compaction-style:
                      format: int64
                      type: integer
                    compression-per-level:
                      items:
                        type: string
                      type: array
                    disable-auto-compactions:
                      type: boolean
                    disable-block-cache:
                      type: boolean
                    dynamic-level-bytes:
                      type: boolean
                    enable-doubly-skiplist:
                      type: boolean
                    force-consistency-checks:
                      type: boolean
                    hard-pending-compaction-bytes-limit:
                      type: string
                    level0-file-num-compaction-trigger:
                      format: int64
                      type: integer
                    level0-slowdown-writes-trigger:
                      format: int64
                      type: integer
                    level0-stop-writes-trigger:
                      format: int64
                      type: integer
                    max-bytes-for-level-base:
                      type: string
                    max-bytes-for-level-multiplier:
                      format: int64
                      type: integer
                    max-compaction-bytes:
                      type: string
                    max-write-buffer-number:
                      format: int64
                      type: integer
                    min-write-buffer-number-to-merge:
                      format: int64
                      type: integer
                    num-levels:
                      format: int64
                      type: integer
                    optimize-filters-for-hits:
                      type: boolean
                    pin-l0-filter-and-index-blocks:
                      type: boolean
                    prop-keys-index-distance:
                      format: int64
                      type: integer
                    prop-size-index-distance:
                      format: int64
                      type: integer
                    read-amp-bytes-per-bit:
                      format: int64
                      type: integer
                    soft-pending-compaction-bytes-limit:
                      type: string
                    target-file-size-base:
                      type: string
                    titan:
                      description: TiKVTitanCfConfig is the titian config.
                      properties:
                        blob-cache-size:
                          type: string
                        blob-file-compression:
                          type: string
                        blob-run-mode:
                          type: string
                        discardable-ratio: {}
                        max-gc-batch-size:
                          type: string
                        merge-small-file-threshold:
                          type: string
                        min-blob-size:
                          type: string
                        min-gc-batch-size:
                          type: string
                        sample-ratio: {}
                      type: object
                    use-bloom-filter:
                      type: boolean
                    whole-key-filtering:
                      type: boolean
                    write-buffer-size:
                      type: string
                  type: object
                max-background-jobs:
                  description: 'Optional: Defaults to 8'
                  format: int64
                  type: integer
                max-manifest-file-size:
                  description: 'Optional: Defaults to 128MB'
                  type: string
                max-open-files:
                  description: 'Optional: Defaults to 40960'
                  format: int64
                  type: integer
                max-sub-compactions:
                  description: 'Optional: Defaults to 3'
                  format: int64
                  type: integer
                max-total-wal-size:
                  description: 'Optional: Defaults to 4GB'
                  type: string
                raftcf:
                  description: TiKVCfConfig is the config of a cf
                  properties:
                    block-based-bloom-filter:
                      type: boolean
                    block-cache-size:
                      type: string
                    block-size:
                      type: string
                    bloom-filter-bits-per-key:
                      format: int64
                      type: integer
                    cache-index-and-filter-blocks:
                      type: boolean
                    compaction-pri:
                      format: int64
                      type: integer
                    compaction-style:
                      format: int64
                      type: integer
                    compression-per-level:
                      items:
                        type: string
                      type: array
                    disable-auto-compactions:
                      type: boolean
                    disable-block-cache:
                      type: boolean
                    dynamic-level-bytes:
                      type: boolean
                    enable-doubly-skiplist:
                      type: boolean
                    force-consistency-checks:
                      type: boolean
                    hard-pending-compaction-bytes-limit:
                      type: string
                    level0-file-num-compaction-trigger:
                      format: int64
                      type: integer
                    level0-slowdown-writes-trigger:
                      format: int64
                      type: integer
                    level0-stop-writes-trigger:
                      format: int64
                      type: integer
                    max-bytes-for-level-base:
                      type: string
                    max-bytes-for-level-multiplier:
                      format: int64
                      type: integer
                    max-compaction-bytes:
                      type: string
                    max-write-buffer-number:
                      format: int64
                      type: integer
                    min-write-buffer-number-to-merge:
                      format: int64
                      type: integer
                    num-levels:
                      format: int64
                      type: integer
                    optimize-filters-for-hits:
                      type: boolean
                    pin-l0-filter-and-index-blocks:
                      type: boolean
                    prop-keys-index-distance:
                      format: int64
                      type: integer
                    prop-size-index-distance:
                      format: int64
                      type: integer
                    read-amp-bytes-per-bit:
                      format: int64
                      type: integer
                    soft-pending-compaction-bytes-limit:
                      type: string
                    target-file-size-base:
                      type: string
                    titan:
                      description: TiKVTitanCfConfig is the titian config.
                      properties:
                        blob-cache-size:
                          type: string
                        blob-file-compression:
                          type: string
                        blob-run-mode:
                          type: string
                        discardable-ratio: {}
                        max-gc-batch-size:
                          type: string
                        merge-small-file-threshold:
                          type: string
                        min-blob-size:
                          type: string
                        min-gc-batch-size:
                          type: string
                        sample-ratio: {}
                      type: object
                    use-bloom-filter:
                      type: boolean
                    whole-key-filtering:
                      type: boolean
                    write-buffer-size:
                      type: string
                  type: object
                rate-bytes-per-sec:
                  type: string
                rate-limiter-mode:
                  format: int64
                  type: integer
                stats-dump-period:
                  description: 'Optional: Defaults to 10m'
                  type: string
                titan:
                  description: TiKVTitanDBConfig is the config a titian db.
                  properties:
                    dirname:
                      type: string
                    disable-gc:
                      type: boolean
                    enabled:
                      type: boolean
                    max-background-gc:
                      format: int64
                      type: integer
                    purge-obsolete-files-period:
                      description: The value of this field will be truncated to seconds.
                      type: string
                  type: object
                use-direct-io-for-flush-and-compaction:
                  type: boolean
                wal-bytes-per-sync:
                  type: string
                wal-recovery-mode:
                  description: 'Optional: Defaults to 2'
                  format: int64
                  type: integer
                wal-size-limit:
                  type: string
                wal-ttl-seconds:
                  format: int64
                  type: integer
                writable-file-max-buffer-size:
                  type: string
                writecf:
                  description: TiKVCfConfig is the config of a cf
                  properties:
                    block-based-bloom-filter:
                      type: boolean
                    block-cache-size:
                      type: string
                    block-size:
                      type: string
                    bloom-filter-bits-per-key:
                      format: int64
                      type: integer
                    cache-index-and-filter-blocks:
                      type: boolean
                    compaction-pri:
                      format: int64
                      type: integer
                    compaction-style:
                      format: int64
                      type: integer
                    compression-per-level:
                      items:
                        type: string
                      type: array
                    disable-auto-compactions:
                      type: boolean
                    disable-block-cache:
                      type: boolean
                    dynamic-level-bytes:
                      type: boolean
                    enable-doubly-skiplist:
                      type: boolean
                    force-consistency-checks:
                      type: boolean
                    hard-pending-compaction-bytes-limit:
                      type: string
                    level0-file-num-compaction-trigger:
                      format: int64
                      type: integer
                    level0-slowdown-writes-trigger:
                      format: int64
                      type: integer
                    level0-stop-writes-trigger:
                      format: int64
                      type: integer
                    max-bytes-for-level-base:
                      type: string
                    max-bytes-for-level-multiplier:
                      format: int64
                      type: integer
                    max-compaction-bytes:
                      type: string
                    max-write-buffer-number:
                      format: int64
                      type: integer
                    min-write-buffer-number-to-merge:
                      format: int64
                      type: integer
                    num-levels:
                      format: int64
                      type: integer
                    optimize-filters-for-hits:
                      type: boolean
                    pin-l0-filter-and-index-blocks:
                      type: boolean
                    prop-keys-index-distance:
                      format: int64
                      type: integer
                    prop-size-index-distance:
                      format: int64
                      type: integer
                    read-amp-bytes-per-bit:
                      format: int64
                      type: integer
                    soft-pending-compaction-bytes-limit:
                      type: string
                    target-file-size-base:
                      type: string
                    titan:
                      description: TiKVTitanCfConfig is the titian config.
                      properties:
                        blob-cache-size:
                          type: string
                        blob-file-compression:
                          type: string
                        blob-run-mode:
                          type: string
                        discardable-ratio: {}
                        max-gc-batch-size:
                          type: string
                        merge-small-file-threshold:
                          type: string
                        min-blob-size:
                          type: string
                        min-gc-batch-size:
                          type: string
                        sample-ratio: {}
                      type: object
                    use-bloom-filter:
                      type: boolean
                    whole-key-filtering:
                      type: boolean
                    write-buffer-size:
                      type: string
                  type: object
              type: object
            security:
              properties:
                ca_path:
                  type: string
                cert_path:
                  type: string
                cipher_file:
                  type: string
                key_path:
                  type: string
                override_ssl_target:
                  type: string
              type: object
            server:
              description: TiKVServerConfig is the configuration of TiKV server.
              properties:
                concurrent-recv-snap-limit:
                  description: 'Optional: Defaults to 32'
                  type: integer
                concurrent-send-snap-limit:
                  description: 'Optional: Defaults to 32'
                  type: integer
                end-point-batch-row-limit:
                  type: integer
                end-point-enable-batch-if-possible:
                  type: integer
                end-point-recursion-limit:
                  description: 'Optional: Defaults to 1000'
                  type: integer
                end-point-request-max-handle-duration:
                  type: string
                end-point-stream-batch-row-limit:
                  type: integer
                end-point-stream-channel-size:
                  type: integer
                grpc-compression-type:
                  description: 'Optional: Defaults to none'
                  type: string
                grpc-concurrency:
                  description: 'Optional: Defaults to 4'
                  type: integer
                grpc-concurrent-stream:
                  description: 'Optional: Defaults to 1024'
                  type: integer
                grpc-keepalive-time:
                  description: 'Optional: Defaults to 10s'
                  type: string
                grpc-keepalive-timeout:
                  description: 'Optional: Defaults to 3s'
                  type: string
                grpc-raft-conn-num:
                  description: 'Optional: Defaults to 10'
                  type: integer
                grpc-stream-initial-window-size:
                  description: 'Optional: Defaults to 2MB'
                  type: string
                grpc_memory_pool_quota:
                  description: 'Optional: Defaults to 32G'
                  type: string
                heavy-load-threshold:
                  type: integer
                heavy-load-wait-duration:
                  description: 'Optional: Defaults to 60s'
                  type: string
                labels:
                  additionalProperties:
                    type: string
                  type: object
                snap-max-total-size:
                  type: string
                snap-max-write-bytes-per-sec:
                  description: 'Optional: Defaults to 100MB'
                  type: string
                stats-concurrency:
                  type: integer
                status-thread-pool-size:
                  description: 'Optional: Defaults to 1'
                  type: string
              type: object
            storage:
              description: TiKVStorageConfig is the config of storage
              properties:
                block-cache:
                  description: TiKVBlockCacheConfig is the config of a block cache
                  properties:
                    capacity:
                      type: string
                    high-pri-pool-ratio: {}
                    memory-allocator:
                      type: string
                    num-shard-bits:
                      format: int64
                      type: integer
                    shared:
                      description: 'Optional: Defaults to true'
                      type: boolean
                    strict-capacity-limit:
                      type: boolean
                  type: object
                max-key-size:
                  format: int64
                  type: integer
                scheduler-concurrency:
                  description: 'Optional: Defaults to 2048000'
                  format: int64
                  type: integer
                scheduler-notify-capacity:
                  format: int64
                  type: integer
                scheduler-pending-write-threshold:
                  description: 'Optional: Defaults to 100MB'
                  type: string
                scheduler-worker-pool-size:
                  description: 'Optional: Defaults to 4'
                  format: int64
                  type: integer
              type: object
          type: object
      required:
      - pd-config
      - tidb-config
      - tikv-config
      type: object
  version: apiserver
  versions:
  - name: apiserver
    served: true
    storage: false
  - name: v1alpha1
    served: true
    storage: false`

var crd v1beta1.CustomResourceDefinition

func init() {

	err := yaml.NewYAMLOrJSONDecoder(strings.NewReader(crdYaml), 1024).Decode(&crd)
	if err != nil {
		panic(fmt.Errorf("cannot load schema of tidb cluster configs: %v", err))
	}
	fillFloat64(crd.Spec.Validation.OpenAPIV3Schema)
}

func fillFloat64(s *v1beta1.JSONSchemaProps) {
	if s == nil {
		return
	}
	for k, v := range s.Properties {
		// kubebuilder do not accept float64 and will leave the type empty, fill it
		if v.Type == "object" {
			fillFloat64(&v)
			s.Properties[k] = v
		}
		if v.Type == "" {
			v.Type = "number"
			v.Format = "number"
			s.Properties[k] = v
		}
		if v.Format == "int64" || v.Format == "int32" {
			v.Format = "number"
			s.Properties[k] = v
		}
	}
}

func GetConfigSchema() *v1beta1.JSONSchemaProps {
	return crd.Spec.Validation.OpenAPIV3Schema
}
