diff --git a/pkg/kube_resource/generator/testdata/map_default_value/crd.golden.yaml b/pkg/kube_resource/generator/testdata/map_default_value/crd.golden.yaml new file mode 100644 index 0000000..779e518 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/map_default_value/crd.golden.yaml @@ -0,0 +1,1407 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: operatorconfigurations.acid.zalan.do +spec: + group: acid.zalan.do + names: + categories: + - all + kind: OperatorConfiguration + listKind: OperatorConfigurationList + plural: operatorconfigurations + shortNames: + - opconfig + singular: operatorconfiguration + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Spilo image to be used for Pods + jsonPath: .configuration.docker_image + name: Image + type: string + - description: Label for K8s resources created by operator + jsonPath: .configuration.kubernetes.cluster_name_label + name: Cluster-Label + type: string + - description: Name of service account to be used + jsonPath: .configuration.kubernetes.pod_service_account_name + name: Service-Account + type: string + - description: Minimum number of instances per Postgres cluster + jsonPath: .configuration.min_instances + name: Min-Instances + type: integer + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + enum: + - acid.zalan.do/v1 + type: string + configuration: + properties: + aws_or_gcp: + properties: + additional_secret_mount: + type: string + additional_secret_mount_path: + default: /meta/credentials + type: string + aws_region: + default: eu-central-1 + type: string + enable_ebs_gp3_migration: + default: false + type: boolean + enable_ebs_gp3_migration_max_size: + default: 1000 + type: integer + gcp_credentials: + type: string + kube_iam_role: + type: string + log_s3_bucket: + type: string + wal_az_storage_account: + type: string + wal_gs_bucket: + type: string + wal_s3_bucket: + type: string + type: object + connection_pooler: + properties: + connection_pooler_default_cpu_limit: + default: "1" + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + connection_pooler_default_cpu_request: + default: 500m + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + connection_pooler_default_memory_limit: + default: 100Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + connection_pooler_default_memory_request: + default: 100Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + connection_pooler_image: + default: registry.opensource.zalan.do/acid/pgbouncer:master-27 + type: string + connection_pooler_max_db_connections: + default: 60 + type: integer + connection_pooler_mode: + default: transaction + enum: + - session + - transaction + type: string + connection_pooler_number_of_instances: + default: 2 + minimum: 1 + type: integer + connection_pooler_schema: + default: pooler + type: string + connection_pooler_user: + default: pooler + type: string + type: object + crd_categories: + items: + type: string + nullable: true + type: array + debug: + properties: + debug_logging: + default: true + type: boolean + enable_database_access: + default: true + type: boolean + type: object + docker_image: + default: ghcr.io/zalando/spilo-15:3.0-p1 + type: string + enable_crd_registration: + default: true + type: boolean + enable_crd_validation: + default: true + description: deprecated + type: boolean + enable_lazy_spilo_upgrade: + default: false + type: boolean + enable_pgversion_env_var: + default: true + type: boolean + enable_shm_volume: + default: true + type: boolean + enable_spilo_wal_path_compat: + default: false + type: boolean + enable_team_id_clustername_prefix: + default: false + type: boolean + etcd_host: + default: "" + type: string + ignore_instance_limits_annotation_key: + type: string + kubernetes: + properties: + additional_pod_capabilities: + items: + type: string + type: array + cluster_domain: + default: cluster.local + type: string + cluster_labels: + additionalProperties: + type: string + default: + application: spilo + type: object + cluster_name_label: + default: cluster-name + type: string + custom_pod_annotations: + additionalProperties: + type: string + type: object + delete_annotation_date_key: + type: string + delete_annotation_name_key: + type: string + downscaler_annotations: + items: + type: string + type: array + enable_cross_namespace_secret: + default: false + type: boolean + enable_init_containers: + default: true + type: boolean + enable_pod_antiaffinity: + default: false + type: boolean + enable_pod_disruption_budget: + default: true + type: boolean + enable_readiness_probe: + default: false + type: boolean + enable_sidecars: + default: true + type: boolean + ignored_annotations: + items: + type: string + type: array + infrastructure_roles_secret_name: + type: string + infrastructure_roles_secrets: + items: + properties: + defaultrolevalue: + type: string + defaultuservalue: + type: string + details: + type: string + passwordkey: + type: string + rolekey: + type: string + secretname: + type: string + template: + type: boolean + userkey: + type: string + required: + - secretname + - userkey + - passwordkey + type: object + nullable: true + type: array + inherited_annotations: + items: + type: string + type: array + inherited_labels: + items: + type: string + type: array + master_pod_move_timeout: + default: 20m + type: string + node_readiness_label: + additionalProperties: + type: string + type: object + node_readiness_label_merge: + enum: + - AND + - OR + type: string + oauth_token_secret_name: + default: postgresql-operator + type: string + pdb_name_format: + default: postgres-{cluster}-pdb + type: string + pod_antiaffinity_preferred_during_scheduling: + default: false + type: boolean + pod_antiaffinity_topology_key: + default: kubernetes.io/hostname + type: string + pod_environment_configmap: + type: string + pod_environment_secret: + type: string + pod_management_policy: + default: ordered_ready + enum: + - ordered_ready + - parallel + type: string + pod_priority_class_name: + type: string + pod_role_label: + default: spilo-role + type: string + pod_service_account_definition: + default: "" + type: string + pod_service_account_name: + default: postgres-pod + type: string + pod_service_account_role_binding_definition: + default: "" + type: string + pod_terminate_grace_period: + default: 5m + type: string + secret_name_template: + default: '{username}.{cluster}.credentials.{tprkind}.{tprgroup}' + type: string + share_pgsocket_with_sidecars: + default: false + type: boolean + spilo_allow_privilege_escalation: + default: true + type: boolean + spilo_fsgroup: + type: integer + spilo_privileged: + default: false + type: boolean + spilo_runasgroup: + type: integer + spilo_runasuser: + type: integer + storage_resize_mode: + default: pvc + enum: + - ebs + - mixed + - pvc + - "off" + type: string + toleration: + additionalProperties: + type: string + type: object + watched_namespace: + type: string + type: object + kubernetes_use_configmaps: + default: false + type: boolean + load_balancer: + properties: + custom_service_annotations: + additionalProperties: + type: string + type: object + db_hosted_zone: + default: db.example.com + type: string + enable_master_load_balancer: + default: true + type: boolean + enable_master_pooler_load_balancer: + default: false + type: boolean + enable_replica_load_balancer: + default: false + type: boolean + enable_replica_pooler_load_balancer: + default: false + type: boolean + external_traffic_policy: + default: Cluster + enum: + - Cluster + - Local + type: string + master_dns_name_format: + default: '{cluster}.{namespace}.{hostedzone}' + type: string + master_legacy_dns_name_format: + default: '{cluster}.{team}.{hostedzone}' + type: string + replica_dns_name_format: + default: '{cluster}-repl.{namespace}.{hostedzone}' + type: string + replica_legacy_dns_name_format: + default: '{cluster}-repl.{team}.{hostedzone}' + type: string + type: object + logging_rest_api: + properties: + api_port: + default: 8080 + type: integer + cluster_history_entries: + default: 1000 + type: integer + ring_log_lines: + default: 100 + type: integer + type: object + logical_backup: + properties: + logical_backup_azure_storage_account_key: + type: string + logical_backup_azure_storage_account_name: + type: string + logical_backup_azure_storage_container: + type: string + logical_backup_cpu_limit: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + logical_backup_cpu_request: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + logical_backup_docker_image: + default: registry.opensource.zalan.do/acid/logical-backup:v1.10.1 + type: string + logical_backup_google_application_credentials: + type: string + logical_backup_job_prefix: + default: logical-backup- + type: string + logical_backup_memory_limit: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + logical_backup_memory_request: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + logical_backup_provider: + default: s3 + enum: + - az + - gcs + - s3 + type: string + logical_backup_s3_access_key_id: + type: string + logical_backup_s3_bucket: + type: string + logical_backup_s3_endpoint: + type: string + logical_backup_s3_region: + type: string + logical_backup_s3_retention_time: + type: string + logical_backup_s3_secret_access_key: + type: string + logical_backup_s3_sse: + type: string + logical_backup_schedule: + default: 30 00 * * * + pattern: ^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$ + type: string + type: object + major_version_upgrade: + properties: + major_version_upgrade_mode: + default: "off" + type: string + major_version_upgrade_team_allow_list: + items: + type: string + type: array + minimal_major_version: + default: "11" + type: string + target_major_version: + default: "15" + type: string + type: object + max_instances: + default: -1 + description: -1 = disabled + minimum: -1 + type: integer + min_instances: + default: -1 + description: -1 = disabled + minimum: -1 + type: integer + patroni: + properties: + enable_patroni_failsafe_mode: + default: false + type: boolean + type: object + postgres_pod_resources: + properties: + default_cpu_limit: + default: "1" + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + default_cpu_request: + default: 100m + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + default_memory_limit: + default: 500Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + default_memory_request: + default: 100Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + max_cpu_request: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + max_memory_request: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + min_cpu_limit: + default: 250m + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + min_memory_limit: + default: 250Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + type: object + repair_period: + default: 5m + type: string + resync_period: + default: 30m + type: string + scalyr: + properties: + scalyr_api_key: + type: string + scalyr_cpu_limit: + default: "1" + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + scalyr_cpu_request: + default: 100m + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + scalyr_image: + type: string + scalyr_memory_limit: + default: 500Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + scalyr_memory_request: + default: 50Mi + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + scalyr_server_url: + default: https://upload.eu.scalyr.com + type: string + type: object + set_memory_request_to_limit: + default: false + type: boolean + sidecar_docker_images: + additionalProperties: + type: string + type: object + sidecars: + items: + type: object + x-kubernetes-preserve-unknown-fields: true + nullable: true + type: array + teams_api: + properties: + enable_admin_role_for_users: + default: true + type: boolean + enable_postgres_team_crd: + default: true + type: boolean + enable_postgres_team_crd_superusers: + default: false + type: boolean + enable_team_member_deprecation: + default: false + type: boolean + enable_team_superuser: + default: false + type: boolean + enable_teams_api: + default: true + type: boolean + pam_configuration: + default: https://info.example.com/oauth2/tokeninfo?access_token= + uid realm=/employees + type: string + pam_role_name: + default: zalandos + type: string + postgres_superuser_teams: + items: + type: string + type: array + protected_role_names: + default: + - admin + - cron_admin + items: + type: string + type: array + role_deletion_suffix: + default: _deleted + type: string + team_admin_role: + default: admin + type: string + team_api_role_configuration: + additionalProperties: + type: string + default: + log_statement: all + type: object + teams_api_url: + default: https://teams.example.com/api/ + type: string + type: object + timeouts: + properties: + patroni_api_check_interval: + default: 1s + type: string + patroni_api_check_timeout: + default: 5s + type: string + pod_deletion_wait_timeout: + default: 10m + type: string + pod_label_wait_timeout: + default: 10m + type: string + ready_wait_interval: + default: 4s + type: string + ready_wait_timeout: + default: 30s + type: string + resource_check_interval: + default: 3s + type: string + resource_check_timeout: + default: 10m + type: string + type: object + users: + properties: + additional_owner_roles: + items: + type: string + nullable: true + type: array + enable_password_rotation: + default: false + type: boolean + password_rotation_interval: + default: 90 + type: integer + password_rotation_user_retention: + default: 180 + type: integer + replication_username: + default: standby + type: string + super_username: + default: postgres + type: string + type: object + workers: + default: 8 + minimum: 1 + type: integer + type: object + kind: + enum: + - OperatorConfiguration + type: string + status: + additionalProperties: + type: string + type: object + required: + - kind + - apiVersion + - configuration + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: null + storedVersions: + - v1 + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: postgresqls.acid.zalan.do +spec: + group: acid.zalan.do + names: + categories: + - all + kind: postgresql + listKind: postgresqlList + plural: postgresqls + shortNames: + - pg + singular: postgresql + scope: Namespaced + versions: + - additionalPrinterColumns: + - description: Team responsible for Postgres cluster + jsonPath: .spec.teamId + name: Team + type: string + - description: PostgreSQL version + jsonPath: .spec.postgresql.version + name: Version + type: string + - description: Number of Pods per Postgres cluster + jsonPath: .spec.numberOfInstances + name: Pods + type: integer + - description: Size of the bound volume + jsonPath: .spec.volume.size + name: Volume + type: string + - description: Requested CPU for Postgres containers + jsonPath: .spec.resources.requests.cpu + name: CPU-Request + type: string + - description: Requested memory for Postgres containers + jsonPath: .spec.resources.requests.memory + name: Memory-Request + type: string + - jsonPath: .metadata.creationTimestamp + name: Age + type: date + - description: Current sync status of postgresql resource + jsonPath: .status.PostgresClusterStatus + name: Status + type: string + name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + enum: + - acid.zalan.do/v1 + type: string + kind: + enum: + - postgresql + type: string + spec: + properties: + additionalVolumes: + items: + properties: + mountPath: + type: string + name: + type: string + subPath: + type: string + targetContainers: + items: + type: string + nullable: true + type: array + volumeSource: + type: object + x-kubernetes-preserve-unknown-fields: true + required: + - name + - mountPath + - volumeSource + type: object + type: array + allowedSourceRanges: + items: + pattern: ^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\/(\d|[1-2]\d|3[0-2])$ + type: string + nullable: true + type: array + clone: + properties: + cluster: + type: string + s3_access_key_id: + type: string + s3_endpoint: + type: string + s3_force_path_style: + type: boolean + s3_secret_access_key: + type: string + s3_wal_path: + type: string + timestamp: + pattern: ^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([+-]([01][0-9]|2[0-3]):[0-5][0-9]))$ + type: string + uid: + format: uuid + type: string + required: + - cluster + type: object + connectionPooler: + properties: + dockerImage: + type: string + maxDBConnections: + type: integer + mode: + enum: + - session + - transaction + type: string + numberOfInstances: + minimum: 1 + type: integer + resources: + properties: + limits: + properties: + cpu: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + memory: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + type: object + requests: + properties: + cpu: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + memory: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + type: object + type: object + schema: + type: string + user: + type: string + type: object + databases: + additionalProperties: + type: string + type: object + dockerImage: + type: string + enableConnectionPooler: + type: boolean + enableLogicalBackup: + type: boolean + enableMasterLoadBalancer: + type: boolean + enableMasterPoolerLoadBalancer: + type: boolean + enableReplicaConnectionPooler: + type: boolean + enableReplicaLoadBalancer: + type: boolean + enableReplicaPoolerLoadBalancer: + type: boolean + enableShmVolume: + type: boolean + env: + items: + type: object + x-kubernetes-preserve-unknown-fields: true + nullable: true + type: array + init_containers: + description: deprecated + items: + type: object + x-kubernetes-preserve-unknown-fields: true + nullable: true + type: array + initContainers: + items: + type: object + x-kubernetes-preserve-unknown-fields: true + nullable: true + type: array + logicalBackupSchedule: + pattern: ^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$ + type: string + maintenanceWindows: + items: + pattern: ^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ + *$ + type: string + type: array + masterServiceAnnotations: + additionalProperties: + type: string + type: object + nodeAffinity: + properties: + preferredDuringSchedulingIgnoredDuringExecution: + items: + properties: + preference: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + weight: + format: int32 + type: integer + required: + - preference + - weight + type: object + type: array + requiredDuringSchedulingIgnoredDuringExecution: + properties: + nodeSelectorTerms: + items: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchFields: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + type: object + type: array + required: + - nodeSelectorTerms + type: object + type: object + numberOfInstances: + minimum: 0 + type: integer + patroni: + properties: + failsafe_mode: + type: boolean + initdb: + additionalProperties: + type: string + type: object + loop_wait: + type: integer + maximum_lag_on_failover: + type: integer + pg_hba: + items: + type: string + type: array + retry_timeout: + type: integer + slots: + additionalProperties: + additionalProperties: + type: string + type: object + type: object + synchronous_mode: + type: boolean + synchronous_mode_strict: + type: boolean + synchronous_node_count: + type: integer + ttl: + type: integer + type: object + pod_priority_class_name: + description: deprecated + type: string + podAnnotations: + additionalProperties: + type: string + type: object + podPriorityClassName: + type: string + postgresql: + properties: + parameters: + additionalProperties: + type: string + type: object + version: + enum: + - "10" + - "11" + - "12" + - "13" + - "14" + - "15" + type: string + required: + - version + type: object + preparedDatabases: + additionalProperties: + properties: + defaultUsers: + type: boolean + extensions: + additionalProperties: + type: string + type: object + schemas: + additionalProperties: + properties: + defaultRoles: + type: boolean + defaultUsers: + type: boolean + type: object + type: object + secretNamespace: + type: string + type: object + type: object + replicaLoadBalancer: + description: deprecated + type: boolean + replicaServiceAnnotations: + additionalProperties: + type: string + type: object + resources: + properties: + limits: + properties: + cpu: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + memory: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + type: object + requests: + properties: + cpu: + pattern: ^(\d+m|\d+(\.\d{1,3})?)$ + type: string + memory: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + type: object + type: object + schedulerName: + type: string + serviceAnnotations: + additionalProperties: + type: string + type: object + sidecars: + items: + type: object + x-kubernetes-preserve-unknown-fields: true + nullable: true + type: array + spiloFSGroup: + type: integer + spiloRunAsGroup: + type: integer + spiloRunAsUser: + type: integer + standby: + oneOf: + - required: + - s3_wal_path + - required: + - gs_wal_path + - required: + - standby_host + properties: + gs_wal_path: + type: string + s3_wal_path: + type: string + standby_host: + type: string + standby_port: + type: string + type: object + streams: + items: + properties: + applicationId: + type: string + batchSize: + type: integer + database: + type: string + filter: + additionalProperties: + type: string + type: object + tables: + additionalProperties: + properties: + eventType: + type: string + idColumn: + type: string + payloadColumn: + type: string + required: + - eventType + type: object + type: object + required: + - applicationId + - database + - tables + type: object + type: array + teamId: + type: string + tls: + properties: + caFile: + type: string + caSecretName: + type: string + certificateFile: + type: string + privateKeyFile: + type: string + secretName: + type: string + required: + - secretName + type: object + tolerations: + items: + properties: + effect: + enum: + - NoExecute + - NoSchedule + - PreferNoSchedule + type: string + key: + type: string + operator: + enum: + - Equal + - Exists + type: string + tolerationSeconds: + type: integer + value: + type: string + type: object + type: array + useLoadBalancer: + description: deprecated + type: boolean + users: + additionalProperties: + items: + enum: + - bypassrls + - BYPASSRLS + - nobypassrls + - NOBYPASSRLS + - createdb + - CREATEDB + - nocreatedb + - NOCREATEDB + - createrole + - CREATEROLE + - nocreaterole + - NOCREATEROLE + - inherit + - INHERIT + - noinherit + - NOINHERIT + - login + - LOGIN + - nologin + - NOLOGIN + - replication + - REPLICATION + - noreplication + - NOREPLICATION + - superuser + - SUPERUSER + - nosuperuser + - NOSUPERUSER + type: string + nullable: true + type: array + type: object + usersWithInPlaceSecretRotation: + items: + type: string + nullable: true + type: array + usersWithSecretRotation: + items: + type: string + nullable: true + type: array + volume: + properties: + iops: + type: integer + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + enum: + - DoesNotExist + - Exists + - In + - NotIn + type: string + values: + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + type: object + x-kubernetes-preserve-unknown-fields: true + type: object + size: + pattern: ^(\d+(e\d+)?|\d+(\.\d+)?(e\d+)?[EPTGMK]i?)$ + type: string + storageClass: + type: string + subPath: + type: string + throughput: + type: integer + required: + - size + type: object + required: + - numberOfInstances + - teamId + - postgresql + - volume + type: object + status: + additionalProperties: + type: string + type: object + required: + - kind + - apiVersion + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: null + storedVersions: + - v1 + +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + creationTimestamp: null + name: postgresteams.acid.zalan.do +spec: + group: acid.zalan.do + names: + categories: + - all + kind: PostgresTeam + listKind: PostgresTeamList + plural: postgresteams + shortNames: + - pgteam + singular: postgresteam + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + properties: + apiVersion: + enum: + - acid.zalan.do/v1 + type: string + kind: + enum: + - PostgresTeam + type: string + spec: + properties: + additionalMembers: + additionalProperties: + description: List of users who will also be added to the Postgres + cluster + items: + type: string + nullable: true + type: array + description: Map for teamId and associated additional users + type: object + additionalSuperuserTeams: + additionalProperties: + description: List of teams to become Postgres superusers + items: + type: string + nullable: true + type: array + description: Map for teamId and associated additional superuser teams + type: object + additionalTeams: + additionalProperties: + description: List of teams whose members will also be added to the + Postgres cluster + items: + type: string + nullable: true + type: array + description: Map for teamId and associated additional teams + type: object + type: object + required: + - kind + - apiVersion + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: null + storedVersions: + - v1 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 new file mode 100644 index 0000000..9db881d --- /dev/null +++ b/pkg/kube_resource/generator/testdata/map_default_value/models/acid_zalan_do_v1_operator_configuration.k @@ -0,0 +1,1002 @@ +""" +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" +import regex +import k8s.apimachinery.pkg.apis.meta.v1 + + +schema OperatorConfiguration: + """ + acid zalan do v1 operator configuration + + Attributes + ---------- + apiVersion : str, default is "acid.zalan.do/v1", required + 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 + kind : str, default is "OperatorConfiguration", required + 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 + status : {str:str}, default is Undefined, optional + status + configuration : AcidZalanDoV1OperatorConfigurationConfiguration, default is Undefined, required + configuration + metadata : v1.ObjectMeta, default is Undefined, optional + metadata + """ + + + apiVersion: "acid.zalan.do/v1" = "acid.zalan.do/v1" + + kind: "OperatorConfiguration" = "OperatorConfiguration" + + status?: {str:str} + + configuration: AcidZalanDoV1OperatorConfigurationConfiguration + + metadata?: v1.ObjectMeta + + +schema AcidZalanDoV1OperatorConfigurationConfiguration: + """ + acid zalan do v1 operator configuration configuration + + Attributes + ---------- + crd_categories : [str], default is Undefined, optional + crd categories + docker_image : str, default is "ghcr.io/zalando/spilo-15:3.0-p1", optional + docker image + enable_crd_registration : bool, default is True, optional + enable crd registration + enable_crd_validation : bool, default is True, optional + deprecated + enable_lazy_spilo_upgrade : bool, default is Undefined, optional + enable lazy spilo upgrade + enable_pgversion_env_var : bool, default is True, optional + enable pgversion env var + enable_shm_volume : bool, default is True, optional + enable shm volume + enable_spilo_wal_path_compat : bool, default is Undefined, optional + enable spilo wal path compat + enable_team_id_clustername_prefix : bool, default is Undefined, optional + enable team id clustername prefix + etcd_host : str, default is Undefined, optional + etcd host + ignore_instance_limits_annotation_key : str, default is Undefined, optional + ignore instance limits annotation key + kubernetes_use_configmaps : bool, default is Undefined, optional + kubernetes use configmaps + max_instances : int, default is -1, optional + -1 = disabled + min_instances : int, default is -1, optional + -1 = disabled + repair_period : str, default is "5m", optional + repair period + resync_period : str, default is "30m", optional + resync period + set_memory_request_to_limit : bool, default is Undefined, optional + set memory request to limit + sidecar_docker_images : {str:str}, default is Undefined, optional + sidecar docker images + sidecars : [any], default is Undefined, optional + sidecars + workers : int, default is 8, optional + workers + aws_or_gcp : AcidZalanDoV1OperatorConfigurationConfigurationAwsOrGcp, default is Undefined, optional + aws or gcp + connection_pooler : AcidZalanDoV1OperatorConfigurationConfigurationConnectionPooler, default is Undefined, optional + connection pooler + debug : AcidZalanDoV1OperatorConfigurationConfigurationDebug, default is Undefined, optional + debug + kubernetes : AcidZalanDoV1OperatorConfigurationConfigurationKubernetes, default is Undefined, optional + kubernetes + load_balancer : AcidZalanDoV1OperatorConfigurationConfigurationLoadBalancer, default is Undefined, optional + load balancer + logging_rest_api : AcidZalanDoV1OperatorConfigurationConfigurationLoggingRestAPI, default is Undefined, optional + logging rest api + logical_backup : AcidZalanDoV1OperatorConfigurationConfigurationLogicalBackup, default is Undefined, optional + logical backup + major_version_upgrade : AcidZalanDoV1OperatorConfigurationConfigurationMajorVersionUpgrade, default is Undefined, optional + major version upgrade + patroni : AcidZalanDoV1OperatorConfigurationConfigurationPatroni, default is Undefined, optional + patroni + postgres_pod_resources : AcidZalanDoV1OperatorConfigurationConfigurationPostgresPodResources, default is Undefined, optional + postgres pod resources + scalyr : AcidZalanDoV1OperatorConfigurationConfigurationScalyr, default is Undefined, optional + scalyr + teams_api : AcidZalanDoV1OperatorConfigurationConfigurationTeamsAPI, default is Undefined, optional + teams api + timeouts : AcidZalanDoV1OperatorConfigurationConfigurationTimeouts, default is Undefined, optional + timeouts + users : AcidZalanDoV1OperatorConfigurationConfigurationUsers, default is Undefined, optional + users + """ + + + crd_categories?: [str] + + docker_image?: str = "ghcr.io/zalando/spilo-15:3.0-p1" + + enable_crd_registration?: bool = True + + enable_crd_validation?: bool = True + + enable_lazy_spilo_upgrade?: bool = False + + enable_pgversion_env_var?: bool = True + + enable_shm_volume?: bool = True + + enable_spilo_wal_path_compat?: bool = False + + enable_team_id_clustername_prefix?: bool = False + + etcd_host?: str = "" + + ignore_instance_limits_annotation_key?: str + + kubernetes_use_configmaps?: bool = False + + max_instances?: int = -1 + + min_instances?: int = -1 + + repair_period?: str = "5m" + + resync_period?: str = "30m" + + set_memory_request_to_limit?: bool = False + + sidecar_docker_images?: {str:str} + + sidecars?: [any] + + workers?: int = 8 + + aws_or_gcp?: AcidZalanDoV1OperatorConfigurationConfigurationAwsOrGcp + + connection_pooler?: AcidZalanDoV1OperatorConfigurationConfigurationConnectionPooler + + debug?: AcidZalanDoV1OperatorConfigurationConfigurationDebug + + kubernetes?: AcidZalanDoV1OperatorConfigurationConfigurationKubernetes + + load_balancer?: AcidZalanDoV1OperatorConfigurationConfigurationLoadBalancer + + logging_rest_api?: AcidZalanDoV1OperatorConfigurationConfigurationLoggingRestAPI + + logical_backup?: AcidZalanDoV1OperatorConfigurationConfigurationLogicalBackup + + major_version_upgrade?: AcidZalanDoV1OperatorConfigurationConfigurationMajorVersionUpgrade + + patroni?: AcidZalanDoV1OperatorConfigurationConfigurationPatroni + + postgres_pod_resources?: AcidZalanDoV1OperatorConfigurationConfigurationPostgresPodResources + + scalyr?: AcidZalanDoV1OperatorConfigurationConfigurationScalyr + + teams_api?: AcidZalanDoV1OperatorConfigurationConfigurationTeamsAPI + + timeouts?: AcidZalanDoV1OperatorConfigurationConfigurationTimeouts + + users?: AcidZalanDoV1OperatorConfigurationConfigurationUsers + + + check: + max_instances >= -1 + min_instances >= -1 + workers >= 1 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationAwsOrGcp: + """ + acid zalan do v1 operator configuration configuration aws or gcp + + Attributes + ---------- + additional_secret_mount : str, default is Undefined, optional + additional secret mount + additional_secret_mount_path : str, default is "/meta/credentials", optional + additional secret mount path + aws_region : str, default is "eu-central-1", optional + aws region + enable_ebs_gp3_migration : bool, default is Undefined, optional + enable ebs gp3 migration + enable_ebs_gp3_migration_max_size : int, default is 1000, optional + enable ebs gp3 migration max size + gcp_credentials : str, default is Undefined, optional + gcp credentials + kube_iam_role : str, default is Undefined, optional + kube iam role + log_s3_bucket : str, default is Undefined, optional + log s3 bucket + wal_az_storage_account : str, default is Undefined, optional + wal az storage account + wal_gs_bucket : str, default is Undefined, optional + wal gs bucket + wal_s3_bucket : str, default is Undefined, optional + wal s3 bucket + """ + + + additional_secret_mount?: str + + additional_secret_mount_path?: str = "/meta/credentials" + + aws_region?: str = "eu-central-1" + + enable_ebs_gp3_migration?: bool = False + + enable_ebs_gp3_migration_max_size?: int = 1000 + + gcp_credentials?: str + + kube_iam_role?: str + + log_s3_bucket?: str + + wal_az_storage_account?: str + + wal_gs_bucket?: str + + wal_s3_bucket?: str + + +schema AcidZalanDoV1OperatorConfigurationConfigurationConnectionPooler: + """ + acid zalan do v1 operator configuration configuration connection pooler + + Attributes + ---------- + connection_pooler_default_cpu_limit : str, default is "1", optional + connection pooler default cpu limit + connection_pooler_default_cpu_request : str, default is "500m", optional + connection pooler default cpu request + connection_pooler_default_memory_limit : str, default is "100Mi", optional + connection pooler default memory limit + connection_pooler_default_memory_request : str, default is "100Mi", optional + connection pooler default memory request + connection_pooler_image : str, default is "registry.opensource.zalan.do/acid/pgbouncer:master-27", optional + connection pooler image + connection_pooler_max_db_connections : int, default is 60, optional + connection pooler max db connections + connection_pooler_mode : str, default is "transaction", optional + connection pooler mode + connection_pooler_number_of_instances : int, default is 2, optional + connection pooler number of instances + connection_pooler_schema : str, default is "pooler", optional + connection pooler schema + connection_pooler_user : str, default is "pooler", optional + connection pooler user + """ + + + connection_pooler_default_cpu_limit?: str = "1" + + connection_pooler_default_cpu_request?: str = "500m" + + connection_pooler_default_memory_limit?: str = "100Mi" + + connection_pooler_default_memory_request?: str = "100Mi" + + connection_pooler_image?: str = "registry.opensource.zalan.do/acid/pgbouncer:master-27" + + connection_pooler_max_db_connections?: int = 60 + + connection_pooler_mode?: "session" | "transaction" = "transaction" + + connection_pooler_number_of_instances?: int = 2 + + connection_pooler_schema?: str = "pooler" + + connection_pooler_user?: str = "pooler" + + + 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 + connection_pooler_number_of_instances >= 1 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationDebug: + """ + acid zalan do v1 operator configuration configuration debug + + Attributes + ---------- + debug_logging : bool, default is True, optional + debug logging + enable_database_access : bool, default is True, optional + enable database access + """ + + + debug_logging?: bool = True + + enable_database_access?: bool = True + + +schema AcidZalanDoV1OperatorConfigurationConfigurationKubernetes: + """ + acid zalan do v1 operator configuration configuration kubernetes + + Attributes + ---------- + additional_pod_capabilities : [str], default is Undefined, optional + additional pod capabilities + cluster_domain : str, default is "cluster.local", optional + cluster domain + cluster_labels : {str:str}, default is {"application": "spilo"}, optional + cluster labels + cluster_name_label : str, default is "cluster-name", optional + cluster name label + custom_pod_annotations : {str:str}, default is Undefined, optional + custom pod annotations + delete_annotation_date_key : str, default is Undefined, optional + delete annotation date key + delete_annotation_name_key : str, default is Undefined, optional + delete annotation name key + downscaler_annotations : [str], default is Undefined, optional + downscaler annotations + enable_cross_namespace_secret : bool, default is Undefined, optional + enable cross namespace secret + enable_init_containers : bool, default is True, optional + enable init containers + enable_pod_antiaffinity : bool, default is Undefined, optional + enable pod antiaffinity + enable_pod_disruption_budget : bool, default is True, optional + enable pod disruption budget + enable_readiness_probe : bool, default is Undefined, optional + enable readiness probe + enable_sidecars : bool, default is True, optional + enable sidecars + ignored_annotations : [str], default is Undefined, optional + ignored annotations + infrastructure_roles_secret_name : str, default is Undefined, optional + infrastructure roles secret name + infrastructure_roles_secrets : [AcidZalanDoV1OperatorConfigurationConfigurationKubernetesInfrastructureRolesSecretsItems0], default is Undefined, optional + infrastructure roles secrets + inherited_annotations : [str], default is Undefined, optional + inherited annotations + inherited_labels : [str], default is Undefined, optional + inherited labels + master_pod_move_timeout : str, default is "20m", optional + master pod move timeout + node_readiness_label : {str:str}, default is Undefined, optional + node readiness label + node_readiness_label_merge : str, default is Undefined, optional + node readiness label merge + oauth_token_secret_name : str, default is "postgresql-operator", optional + oauth token secret name + pdb_name_format : str, default is "postgres-{cluster}-pdb", optional + pdb name format + pod_antiaffinity_preferred_during_scheduling : bool, default is Undefined, optional + pod antiaffinity preferred during scheduling + pod_antiaffinity_topology_key : str, default is "kubernetes.io/hostname", optional + pod antiaffinity topology key + pod_environment_configmap : str, default is Undefined, optional + pod environment configmap + pod_environment_secret : str, default is Undefined, optional + pod environment secret + pod_management_policy : str, default is "ordered_ready", optional + pod management policy + pod_priority_class_name : str, default is Undefined, optional + pod priority class name + pod_role_label : str, default is "spilo-role", optional + pod role label + pod_service_account_definition : str, default is Undefined, optional + pod service account definition + pod_service_account_name : str, default is "postgres-pod", optional + pod service account name + pod_service_account_role_binding_definition : str, default is Undefined, optional + pod service account role binding definition + pod_terminate_grace_period : str, default is "5m", optional + pod terminate grace period + secret_name_template : str, default is "{username}.{cluster}.credentials.{tprkind}.{tprgroup}", optional + secret name template + share_pgsocket_with_sidecars : bool, default is Undefined, optional + share pgsocket with sidecars + spilo_allow_privilege_escalation : bool, default is True, optional + spilo allow privilege escalation + spilo_fsgroup : int, default is Undefined, optional + spilo fsgroup + spilo_privileged : bool, default is Undefined, optional + spilo privileged + spilo_runasgroup : int, default is Undefined, optional + spilo runasgroup + spilo_runasuser : int, default is Undefined, optional + spilo runasuser + storage_resize_mode : str, default is "pvc", optional + storage resize mode + toleration : {str:str}, default is Undefined, optional + toleration + watched_namespace : str, default is Undefined, optional + watched namespace + """ + + + additional_pod_capabilities?: [str] + + cluster_domain?: str = "cluster.local" + + cluster_labels?: {str:str} = {"application": "spilo"} + + cluster_name_label?: str = "cluster-name" + + custom_pod_annotations?: {str:str} + + delete_annotation_date_key?: str + + delete_annotation_name_key?: str + + downscaler_annotations?: [str] + + enable_cross_namespace_secret?: bool = False + + enable_init_containers?: bool = True + + enable_pod_antiaffinity?: bool = False + + enable_pod_disruption_budget?: bool = True + + enable_readiness_probe?: bool = False + + enable_sidecars?: bool = True + + ignored_annotations?: [str] + + infrastructure_roles_secret_name?: str + + infrastructure_roles_secrets?: [AcidZalanDoV1OperatorConfigurationConfigurationKubernetesInfrastructureRolesSecretsItems0] + + inherited_annotations?: [str] + + inherited_labels?: [str] + + master_pod_move_timeout?: str = "20m" + + node_readiness_label?: {str:str} + + node_readiness_label_merge?: "AND" | "OR" + + oauth_token_secret_name?: str = "postgresql-operator" + + pdb_name_format?: str = "postgres-{cluster}-pdb" + + pod_antiaffinity_preferred_during_scheduling?: bool = False + + pod_antiaffinity_topology_key?: str = "kubernetes.io/hostname" + + pod_environment_configmap?: str + + pod_environment_secret?: str + + pod_management_policy?: "ordered_ready" | "parallel" = "ordered_ready" + + pod_priority_class_name?: str + + pod_role_label?: str = "spilo-role" + + pod_service_account_definition?: str = "" + + pod_service_account_name?: str = "postgres-pod" + + pod_service_account_role_binding_definition?: str = "" + + pod_terminate_grace_period?: str = "5m" + + secret_name_template?: str = "{username}.{cluster}.credentials.{tprkind}.{tprgroup}" + + share_pgsocket_with_sidecars?: bool = False + + spilo_allow_privilege_escalation?: bool = True + + spilo_fsgroup?: int + + spilo_privileged?: bool = False + + spilo_runasgroup?: int + + spilo_runasuser?: int + + storage_resize_mode?: "ebs" | "mixed" | "pvc" | "off" = "pvc" + + toleration?: {str:str} + + watched_namespace?: str + + +schema AcidZalanDoV1OperatorConfigurationConfigurationKubernetesInfrastructureRolesSecretsItems0: + """ + acid zalan do v1 operator configuration configuration kubernetes infrastructure roles secrets items0 + + Attributes + ---------- + defaultrolevalue : str, default is Undefined, optional + defaultrolevalue + defaultuservalue : str, default is Undefined, optional + defaultuservalue + details : str, default is Undefined, optional + details + passwordkey : str, default is Undefined, required + passwordkey + rolekey : str, default is Undefined, optional + rolekey + secretname : str, default is Undefined, required + secretname + template : bool, default is Undefined, optional + template + userkey : str, default is Undefined, required + userkey + """ + + + defaultrolevalue?: str + + defaultuservalue?: str + + details?: str + + passwordkey: str + + rolekey?: str + + secretname: str + + template?: bool + + userkey: str + + +schema AcidZalanDoV1OperatorConfigurationConfigurationLoadBalancer: + """ + acid zalan do v1 operator configuration configuration load balancer + + Attributes + ---------- + custom_service_annotations : {str:str}, default is Undefined, optional + custom service annotations + db_hosted_zone : str, default is "db.example.com", optional + db hosted zone + enable_master_load_balancer : bool, default is True, optional + enable master load balancer + enable_master_pooler_load_balancer : bool, default is Undefined, optional + enable master pooler load balancer + enable_replica_load_balancer : bool, default is Undefined, optional + enable replica load balancer + enable_replica_pooler_load_balancer : bool, default is Undefined, optional + enable replica pooler load balancer + external_traffic_policy : str, default is "Cluster", optional + external traffic policy + master_dns_name_format : str, default is "{cluster}.{namespace}.{hostedzone}", optional + master dns name format + master_legacy_dns_name_format : str, default is "{cluster}.{team}.{hostedzone}", optional + master legacy dns name format + replica_dns_name_format : str, default is "{cluster}-repl.{namespace}.{hostedzone}", optional + replica dns name format + replica_legacy_dns_name_format : str, default is "{cluster}-repl.{team}.{hostedzone}", optional + replica legacy dns name format + """ + + + custom_service_annotations?: {str:str} + + db_hosted_zone?: str = "db.example.com" + + enable_master_load_balancer?: bool = True + + enable_master_pooler_load_balancer?: bool = False + + enable_replica_load_balancer?: bool = False + + enable_replica_pooler_load_balancer?: bool = False + + external_traffic_policy?: "Cluster" | "Local" = "Cluster" + + master_dns_name_format?: str = "{cluster}.{namespace}.{hostedzone}" + + master_legacy_dns_name_format?: str = "{cluster}.{team}.{hostedzone}" + + replica_dns_name_format?: str = "{cluster}-repl.{namespace}.{hostedzone}" + + replica_legacy_dns_name_format?: str = "{cluster}-repl.{team}.{hostedzone}" + + +schema AcidZalanDoV1OperatorConfigurationConfigurationLoggingRestAPI: + """ + acid zalan do v1 operator configuration configuration logging rest API + + Attributes + ---------- + api_port : int, default is 8080, optional + api port + cluster_history_entries : int, default is 1000, optional + cluster history entries + ring_log_lines : int, default is 100, optional + ring log lines + """ + + + api_port?: int = 8080 + + cluster_history_entries?: int = 1000 + + ring_log_lines?: int = 100 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationLogicalBackup: + """ + acid zalan do v1 operator configuration configuration logical backup + + Attributes + ---------- + logical_backup_azure_storage_account_key : str, default is Undefined, optional + logical backup azure storage account key + logical_backup_azure_storage_account_name : str, default is Undefined, optional + logical backup azure storage account name + logical_backup_azure_storage_container : str, default is Undefined, optional + logical backup azure storage container + logical_backup_cpu_limit : str, default is Undefined, optional + logical backup cpu limit + logical_backup_cpu_request : str, default is Undefined, optional + logical backup cpu request + logical_backup_docker_image : str, default is "registry.opensource.zalan.do/acid/logical-backup:v1.10.1", optional + logical backup docker image + logical_backup_google_application_credentials : str, default is Undefined, optional + logical backup google application credentials + logical_backup_job_prefix : str, default is "logical-backup-", optional + logical backup job prefix + logical_backup_memory_limit : str, default is Undefined, optional + logical backup memory limit + logical_backup_memory_request : str, default is Undefined, optional + logical backup memory request + logical_backup_provider : str, default is "s3", optional + logical backup provider + logical_backup_s3_access_key_id : str, default is Undefined, optional + logical backup s3 access key id + logical_backup_s3_bucket : str, default is Undefined, optional + logical backup s3 bucket + logical_backup_s3_endpoint : str, default is Undefined, optional + logical backup s3 endpoint + logical_backup_s3_region : str, default is Undefined, optional + logical backup s3 region + logical_backup_s3_retention_time : str, default is Undefined, optional + logical backup s3 retention time + logical_backup_s3_secret_access_key : str, default is Undefined, optional + logical backup s3 secret access key + logical_backup_s3_sse : str, default is Undefined, optional + logical backup s3 sse + logical_backup_schedule : str, default is "30 00 * * *", optional + logical backup schedule + """ + + + logical_backup_azure_storage_account_key?: str + + logical_backup_azure_storage_account_name?: str + + logical_backup_azure_storage_container?: str + + logical_backup_cpu_limit?: str + + logical_backup_cpu_request?: str + + logical_backup_docker_image?: str = "registry.opensource.zalan.do/acid/logical-backup:v1.10.1" + + logical_backup_google_application_credentials?: str + + logical_backup_job_prefix?: str = "logical-backup-" + + logical_backup_memory_limit?: str + + logical_backup_memory_request?: str + + logical_backup_provider?: "az" | "gcs" | "s3" = "s3" + + logical_backup_s3_access_key_id?: str + + logical_backup_s3_bucket?: str + + logical_backup_s3_endpoint?: str + + logical_backup_s3_region?: str + + logical_backup_s3_retention_time?: str + + logical_backup_s3_secret_access_key?: str + + logical_backup_s3_sse?: str + + logical_backup_schedule?: str = "30 00 * * *" + + + 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 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationMajorVersionUpgrade: + """ + acid zalan do v1 operator configuration configuration major version upgrade + + Attributes + ---------- + major_version_upgrade_mode : str, default is "off", optional + major version upgrade mode + major_version_upgrade_team_allow_list : [str], default is Undefined, optional + major version upgrade team allow list + minimal_major_version : str, default is "11", optional + minimal major version + target_major_version : str, default is "15", optional + target major version + """ + + + major_version_upgrade_mode?: str = "off" + + major_version_upgrade_team_allow_list?: [str] + + minimal_major_version?: str = "11" + + target_major_version?: str = "15" + + +schema AcidZalanDoV1OperatorConfigurationConfigurationPatroni: + """ + acid zalan do v1 operator configuration configuration patroni + + Attributes + ---------- + enable_patroni_failsafe_mode : bool, default is Undefined, optional + enable patroni failsafe mode + """ + + + enable_patroni_failsafe_mode?: bool = False + + +schema AcidZalanDoV1OperatorConfigurationConfigurationPostgresPodResources: + """ + acid zalan do v1 operator configuration configuration postgres pod resources + + Attributes + ---------- + default_cpu_limit : str, default is "1", optional + default cpu limit + default_cpu_request : str, default is "100m", optional + default cpu request + default_memory_limit : str, default is "500Mi", optional + default memory limit + default_memory_request : str, default is "100Mi", optional + default memory request + max_cpu_request : str, default is Undefined, optional + max cpu request + max_memory_request : str, default is Undefined, optional + max memory request + min_cpu_limit : str, default is "250m", optional + min cpu limit + min_memory_limit : str, default is "250Mi", optional + min memory limit + """ + + + default_cpu_limit?: str = "1" + + default_cpu_request?: str = "100m" + + default_memory_limit?: str = "500Mi" + + default_memory_request?: str = "100Mi" + + max_cpu_request?: str + + max_memory_request?: str + + min_cpu_limit?: str = "250m" + + min_memory_limit?: str = "250Mi" + + + 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 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationScalyr: + """ + acid zalan do v1 operator configuration configuration scalyr + + Attributes + ---------- + scalyr_api_key : str, default is Undefined, optional + scalyr api key + scalyr_cpu_limit : str, default is "1", optional + scalyr cpu limit + scalyr_cpu_request : str, default is "100m", optional + scalyr cpu request + scalyr_image : str, default is Undefined, optional + scalyr image + scalyr_memory_limit : str, default is "500Mi", optional + scalyr memory limit + scalyr_memory_request : str, default is "50Mi", optional + scalyr memory request + scalyr_server_url : str, default is "https://upload.eu.scalyr.com", optional + scalyr server url + """ + + + scalyr_api_key?: str + + scalyr_cpu_limit?: str = "1" + + scalyr_cpu_request?: str = "100m" + + scalyr_image?: str + + scalyr_memory_limit?: str = "500Mi" + + scalyr_memory_request?: str = "50Mi" + + scalyr_server_url?: str = "https://upload.eu.scalyr.com" + + + 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 + + +schema AcidZalanDoV1OperatorConfigurationConfigurationTeamsAPI: + """ + acid zalan do v1 operator configuration configuration teams API + + Attributes + ---------- + enable_admin_role_for_users : bool, default is True, optional + enable admin role for users + enable_postgres_team_crd : bool, default is True, optional + enable postgres team crd + enable_postgres_team_crd_superusers : bool, default is Undefined, optional + enable postgres team crd superusers + enable_team_member_deprecation : bool, default is Undefined, optional + enable team member deprecation + enable_team_superuser : bool, default is Undefined, optional + enable team superuser + enable_teams_api : bool, default is True, optional + enable teams api + pam_configuration : str, default is "https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees", optional + pam configuration + pam_role_name : str, default is "zalandos", optional + pam role name + postgres_superuser_teams : [str], default is Undefined, optional + postgres superuser teams + protected_role_names : [str], default is ["admin", "cron_admin"], optional + protected role names + role_deletion_suffix : str, default is "_deleted", optional + role deletion suffix + team_admin_role : str, default is "admin", optional + team admin role + team_api_role_configuration : {str:str}, default is {"log_statement": "all"}, optional + team api role configuration + teams_api_url : str, default is "https://teams.example.com/api/", optional + teams api url + """ + + + enable_admin_role_for_users?: bool = True + + enable_postgres_team_crd?: bool = True + + enable_postgres_team_crd_superusers?: bool = False + + enable_team_member_deprecation?: bool = False + + enable_team_superuser?: bool = False + + enable_teams_api?: bool = True + + pam_configuration?: str = "https://info.example.com/oauth2/tokeninfo?access_token= uid realm=/employees" + + pam_role_name?: str = "zalandos" + + postgres_superuser_teams?: [str] + + protected_role_names?: [str] = ["admin", "cron_admin"] + + role_deletion_suffix?: str = "_deleted" + + team_admin_role?: str = "admin" + + team_api_role_configuration?: {str:str} = {"log_statement": "all"} + + teams_api_url?: str = "https://teams.example.com/api/" + + +schema AcidZalanDoV1OperatorConfigurationConfigurationTimeouts: + """ + acid zalan do v1 operator configuration configuration timeouts + + Attributes + ---------- + patroni_api_check_interval : str, default is "1s", optional + patroni api check interval + patroni_api_check_timeout : str, default is "5s", optional + patroni api check timeout + pod_deletion_wait_timeout : str, default is "10m", optional + pod deletion wait timeout + pod_label_wait_timeout : str, default is "10m", optional + pod label wait timeout + ready_wait_interval : str, default is "4s", optional + ready wait interval + ready_wait_timeout : str, default is "30s", optional + ready wait timeout + resource_check_interval : str, default is "3s", optional + resource check interval + resource_check_timeout : str, default is "10m", optional + resource check timeout + """ + + + patroni_api_check_interval?: str = "1s" + + patroni_api_check_timeout?: str = "5s" + + pod_deletion_wait_timeout?: str = "10m" + + pod_label_wait_timeout?: str = "10m" + + ready_wait_interval?: str = "4s" + + ready_wait_timeout?: str = "30s" + + resource_check_interval?: str = "3s" + + resource_check_timeout?: str = "10m" + + +schema AcidZalanDoV1OperatorConfigurationConfigurationUsers: + """ + acid zalan do v1 operator configuration configuration users + + Attributes + ---------- + additional_owner_roles : [str], default is Undefined, optional + additional owner roles + enable_password_rotation : bool, default is Undefined, optional + enable password rotation + password_rotation_interval : int, default is 90, optional + password rotation interval + password_rotation_user_retention : int, default is 180, optional + password rotation user retention + replication_username : str, default is "standby", optional + replication username + super_username : str, default is "postgres", optional + super username + """ + + + additional_owner_roles?: [str] + + enable_password_rotation?: bool = False + + password_rotation_interval?: int = 90 + + password_rotation_user_retention?: int = 180 + + replication_username?: str = "standby" + + super_username?: str = "postgres" + + diff --git a/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k new file mode 100644 index 0000000..8d20935 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/managed_fields_entry.k @@ -0,0 +1,41 @@ +""" +This is the managed_fields_entry module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema ManagedFieldsEntry: + """ + ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the resource that the fieldset applies to. + + Attributes + ---------- + apiVersion : str, default is Undefined, optional + APIVersion defines the version of this resource that this field set applies to. The format is "group/version" just like the top-level APIVersion field. It is necessary to track the version of a field set because it cannot be automatically converted. + fieldsType : str, default is Undefined, optional + FieldsType is the discriminator for the different fields format and version. There is currently only one possible value: "FieldsV1" + fieldsV1 : any, default is Undefined, optional + FieldsV1 holds the first JSON version format as described in the "FieldsV1" type. + manager : str, default is Undefined, optional + Manager is an identifier of the workflow managing these fields. + operation : str, default is Undefined, optional + Operation is the type of operation which lead to this ManagedFieldsEntry being created. The only valid values for this field are 'Apply' and 'Update'. + time : str, default is Undefined, optional + Time is timestamp of when these fields were set. It should always be empty if Operation is 'Apply' + """ + + + apiVersion?: str + + fieldsType?: str + + fieldsV1?: any + + manager?: str + + operation?: str + + time?: str + + diff --git a/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k new file mode 100644 index 0000000..c84b5e3 --- /dev/null +++ b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/object_meta.k @@ -0,0 +1,97 @@ +""" +This is the object_meta module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema ObjectMeta: + """ + ObjectMeta is metadata that all persisted resources must have, which includes all objects users must create. + + Attributes + ---------- + annotations : {str:str}, default is Undefined, optional + Annotations is an unstructured key value map stored with a resource that may be set by external tools to store and retrieve arbitrary metadata. They are not queryable and should be preserved when modifying objects. More info: http://kubernetes.io/docs/user-guide/annotations + clusterName : str, default is Undefined, optional + The name of the cluster which the object belongs to. This is used to distinguish resources with same name and namespace in different clusters. This field is not set anywhere right now and apiserver is going to ignore it if set in create or update request. + creationTimestamp : str, default is Undefined, optional + CreationTimestamp is a timestamp representing the server time when this object was created. It is not guaranteed to be set in happens-before order across separate operations. Clients may not set this value. It is represented in RFC3339 form and is in UTC. + + Populated by the system. Read-only. Null for lists. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + deletionGracePeriodSeconds : int, default is Undefined, optional + Number of seconds allowed for this object to gracefully terminate before it will be removed from the system. Only set when deletionTimestamp is also set. May only be shortened. Read-only. + deletionTimestamp : str, default is Undefined, optional + DeletionTimestamp is RFC 3339 date and time at which this resource will be deleted. This field is set by the server when a graceful deletion is requested by the user, and is not directly settable by a client. The resource is expected to be deleted (no longer visible from resource lists, and not reachable by name) after the time in this field, once the finalizers list is empty. As long as the finalizers list contains items, deletion is blocked. Once the deletionTimestamp is set, this value may not be unset or be set further into the future, although it may be shortened or the resource may be deleted prior to this time. For example, a user may request that a pod is deleted in 30 seconds. The Kubelet will react by sending a graceful termination signal to the containers in the pod. After that 30 seconds, the Kubelet will send a hard termination signal (SIGKILL) to the container and after cleanup, remove the pod from the API. In the presence of network partitions, this object may still exist after this timestamp, until an administrator or automated process can determine the resource is fully terminated. If not set, graceful deletion of the object has not been requested. + + Populated by the system when a graceful deletion is requested. Read-only. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + finalizers : [str], default is Undefined, optional + Must be empty before the object is deleted from the registry. Each entry is an identifier for the responsible component that will remove the entry from the list. If the deletionTimestamp of the object is non-nil, entries in this list can only be removed. Finalizers may be processed and removed in any order. Order is NOT enforced because it introduces significant risk of stuck finalizers. finalizers is a shared field, any actor with permission can reorder it. If the finalizer list is processed in order, then this can lead to a situation in which the component responsible for the first finalizer in the list is waiting for a signal (field value, external system, or other) produced by a component responsible for a finalizer later in the list, resulting in a deadlock. Without enforced ordering finalizers are free to order amongst themselves and are not vulnerable to ordering changes in the list. + generateName : str, default is Undefined, optional + GenerateName is an optional prefix, used by the server, to generate a unique name ONLY IF the Name field has not been provided. If this field is used, the name returned to the client will be different than the name passed. This value will also be combined with a unique suffix. The provided value has the same validation rules as the Name field, and may be truncated by the length of the suffix required to make the value unique on the server. + + If this field is specified and the generated name exists, the server will NOT return a 409 - instead, it will either return 201 Created or 500 with Reason ServerTimeout indicating a unique name could not be found in the time allotted, and the client should retry (optionally after the time indicated in the Retry-After header). + + Applied only if Name is not specified. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#idempotency + generation : int, default is Undefined, optional + A sequence number representing a specific generation of the desired state. Populated by the system. Read-only. + labels : {str:str}, default is Undefined, optional + Map of string keys and values that can be used to organize and categorize (scope and select) objects. May match selectors of replication controllers and services. More info: http://kubernetes.io/docs/user-guide/labels + managedFields : [ManagedFieldsEntry], default is Undefined, optional + ManagedFields maps workflow-id and version to the set of fields that are managed by that workflow. This is mostly for internal housekeeping, and users typically shouldn't need to set or understand this field. A workflow can be the user's name, a controller's name, or the name of a specific apply path like "ci-cd". The set of fields is always in the version that the workflow used when modifying the object. + name : str, default is Undefined, optional + Name must be unique within a namespace. Is required when creating resources, although some resources may allow a client to request the generation of an appropriate name automatically. Name is primarily intended for creation idempotence and configuration definition. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/identifiers#names + namespace : str, default is Undefined, optional + Namespace defines the space within each name must be unique. An empty namespace is equivalent to the "default" namespace, but "default" is the canonical representation. Not all objects are required to be scoped to a namespace - the value of this field for those objects will be empty. + + Must be a DNS_LABEL. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/namespaces + ownerReferences : [OwnerReference], default is Undefined, optional + List of objects depended by this object. If ALL objects in the list have been deleted, this object will be garbage collected. If this object is managed by a controller, then an entry in this list will point to this controller, with the controller field set to true. There cannot be more than one managing controller. + resourceVersion : str, default is Undefined, optional + An opaque value that represents the internal version of this object that can be used by clients to determine when objects have changed. May be used for optimistic concurrency, change detection, and the watch operation on a resource or set of resources. Clients must treat these values as opaque and passed unmodified back to the server. They may only be valid for a particular resource or set of resources. + + Populated by the system. Read-only. Value must be treated as opaque by clients and . More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#concurrency-control-and-consistency + selfLink : str, default is Undefined, optional + SelfLink is a URL representing this object. Populated by the system. Read-only. + + DEPRECATED Kubernetes will stop propagating this field in 1.20 release and the field is planned to be removed in 1.21 release. + uid : str, default is Undefined, optional + UID is the unique in time and space value for this object. It is typically generated by the server on successful creation of a resource and is not allowed to change on PUT operations. + + Populated by the system. Read-only. More info: http://kubernetes.io/docs/user-guide/identifiers#uids + """ + + + annotations?: {str:str} + + clusterName?: str + + creationTimestamp?: str + + deletionGracePeriodSeconds?: int + + deletionTimestamp?: str + + finalizers?: [str] + + generateName?: str + + generation?: int + + labels?: {str:str} + + managedFields?: [ManagedFieldsEntry] + + name?: str + + namespace?: str + + ownerReferences?: [OwnerReference] + + resourceVersion?: str + + selfLink?: str + + uid?: str + + diff --git a/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k new file mode 100644 index 0000000..8d4037b --- /dev/null +++ b/pkg/kube_resource/generator/testdata/map_default_value/models/k8s/apimachinery/pkg/apis/meta/v1/owner_reference.k @@ -0,0 +1,41 @@ +""" +This is the owner_reference module in k8s.apimachinery.pkg.apis.meta.v1 package. +This file was generated by the KCL auto-gen tool. DO NOT EDIT. +Editing this file might prove futile when you re-run the KCL auto-gen generate command. +""" + + +schema OwnerReference: + """ + OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field. + + Attributes + ---------- + apiVersion : str, default is Undefined, required + API version of the referent. + blockOwnerDeletion : bool, default is Undefined, optional + If true, AND if the owner has the "foregroundDeletion" finalizer, then the owner cannot be deleted from the key-value store until this reference is removed. Defaults to false. To set this field, a user needs "delete" permission of the owner, otherwise 422 (Unprocessable Entity) will be returned. + controller : bool, default is Undefined, optional + If true, this reference points to the managing controller. + kind : str, default is Undefined, required + Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + name : str, default is Undefined, required + Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names + uid : str, default is Undefined, required + UID of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#uids + """ + + + apiVersion: str + + blockOwnerDeletion?: bool + + controller?: bool + + kind: str + + name: str + + uid: str + + diff --git a/pkg/swagger/generator/language.go b/pkg/swagger/generator/language.go index a94faa2..418f849 100644 --- a/pkg/swagger/generator/language.go +++ b/pkg/swagger/generator/language.go @@ -135,6 +135,14 @@ func (l *LanguageOpts) ToKclValue(data interface{}) string { } value := reflect.ValueOf(data) switch value.Kind() { + case reflect.Map: + var mapContents []string + iter := value.MapRange() + for iter.Next() { + mapContents = append(mapContents, fmt.Sprintf("%s: %s", l.ToKclValue(iter.Key()), l.ToKclValue(iter.Value()))) + } + content := strings.Join(mapContents, ", ") + return fmt.Sprintf("{%s}", content) case reflect.Slice: // if is a MapSlice if dataSlice, ok := data.(yaml.MapSlice); ok {