controller/
defaults.rs

1use k8s_openapi::{api::core::v1::ResourceRequirements, apimachinery::pkg::api::resource::Quantity};
2use std::collections::BTreeMap;
3
4use crate::{
5    apis::coredb_types::{Backup, ServiceAccountTemplate},
6    extensions::Extension,
7};
8
9pub fn default_replicas() -> i32 {
10    1
11}
12
13pub fn default_resources() -> ResourceRequirements {
14    let limits: BTreeMap<String, Quantity> = BTreeMap::from([
15        ("cpu".to_owned(), Quantity("2".to_string())),
16        ("memory".to_owned(), Quantity("2Gi".to_string())),
17    ]);
18    let requests: BTreeMap<String, Quantity> = BTreeMap::from([
19        ("cpu".to_owned(), Quantity("500m".to_string())),
20        ("memory".to_owned(), Quantity("512Mi".to_string())),
21    ]);
22    ResourceRequirements {
23        limits: Some(limits),
24        requests: Some(requests),
25    }
26}
27
28pub fn default_postgres_exporter_enabled() -> bool {
29    true
30}
31
32pub fn default_uid() -> i32 {
33    999
34}
35
36pub fn default_port() -> i32 {
37    5432
38}
39
40pub fn default_image() -> String {
41    "quay.io/coredb/coredb-pg-slim:370c253".to_owned()
42}
43
44pub fn default_storage() -> Quantity {
45    Quantity("8Gi".to_string())
46}
47
48pub fn default_sharedir_storage() -> Quantity {
49    Quantity("1Gi".to_string())
50}
51
52pub fn default_pkglibdir_storage() -> Quantity {
53    Quantity("1Gi".to_string())
54}
55
56pub fn default_postgres_exporter_image() -> String {
57    "quay.io/prometheuscommunity/postgres-exporter:v0.12.0".to_owned()
58}
59
60pub fn default_extensions() -> Vec<Extension> {
61    vec![]
62}
63
64pub fn default_database() -> String {
65    "postrgres".to_owned()
66}
67
68pub fn default_schema() -> String {
69    "public".to_owned()
70}
71
72pub fn default_description() -> String {
73    "No description provided".to_owned()
74}
75
76pub fn default_stop() -> bool {
77    false
78}
79
80pub fn default_extensions_updating() -> bool {
81    false
82}
83
84pub fn default_service_account_template() -> ServiceAccountTemplate {
85    ServiceAccountTemplate { metadata: None }
86}
87
88pub fn default_backup() -> Backup {
89    Backup {
90        destinationPath: default_destination_path(),
91        encryption: default_encryption(),
92        retentionPolicy: default_retention_policy(),
93        schedule: default_backup_schedule(),
94    }
95}
96
97pub fn default_destination_path() -> Option<String> {
98    Some("s3://".to_string())
99}
100
101pub fn default_encryption() -> Option<String> {
102    Some("AES256".to_owned())
103}
104
105pub fn default_retention_policy() -> Option<String> {
106    Some("30".to_owned())
107}
108
109pub fn default_backup_schedule() -> Option<String> {
110    // Every day at midnight
111    Some("0 0 * * *".to_owned())
112}