@@ -35,110 +35,129 @@ const (
3535 DatabaseReclaimRetain DatabaseReclaimPolicy = "retain"
3636)
3737
38- // DatabaseSpec is the specification of a Postgresql Database
38+ // DatabaseSpec is the specification of a Postgresql Database, built around the
39+ // `CREATE DATABASE`, `ALTER DATABASE`, and `DROP DATABASE` SQL commands of
40+ // PostgreSQL.
3941// +kubebuilder:validation:XValidation:rule="!has(self.builtinLocale) || self.localeProvider == 'builtin'",message="builtinLocale is only available when localeProvider is set to `builtin`"
4042// +kubebuilder:validation:XValidation:rule="!has(self.icuLocale) || self.localeProvider == 'icu'",message="icuLocale is only available when localeProvider is set to `icu`"
4143// +kubebuilder:validation:XValidation:rule="!has(self.icuRules) || self.localeProvider == 'icu'",message="icuRules is only available when localeProvider is set to `icu`"
4244type DatabaseSpec struct {
43- // The corresponding cluster
45+ // The name of the PostgreSQL cluster hosting the database.
4446 ClusterRef corev1.LocalObjectReference `json:"cluster"`
4547
46- // Ensure the PostgreSQL database is `present` or `absent` - defaults to "present"
48+ // Ensure the PostgreSQL database is `present` or `absent` - defaults to "present".
4749 // +kubebuilder:default:="present"
4850 // +kubebuilder:validation:Enum=present;absent
4951 // +optional
5052 Ensure EnsureOption `json:"ensure,omitempty"`
5153
52- // The name inside PostgreSQL
54+ // The name of the database to create inside PostgreSQL. This setting cannot be changed.
5355 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
5456 // +kubebuilder:validation:XValidation:rule="self != 'postgres'",message="the name postgres is reserved"
5557 // +kubebuilder:validation:XValidation:rule="self != 'template0'",message="the name template0 is reserved"
5658 // +kubebuilder:validation:XValidation:rule="self != 'template1'",message="the name template1 is reserved"
5759 Name string `json:"name"`
5860
59- // The owner
61+ // Maps to the `OWNER` parameter of `CREATE DATABASE`.
62+ // Maps to the `OWNER TO` command of `ALTER DATABASE`.
63+ // The role name of the user who owns the database inside PostgreSQL.
6064 Owner string `json:"owner"`
6165
62- // The name of the template from which to create the new database
66+ // Maps to the `TEMPLATE` parameter of `CREATE DATABASE`. This setting
67+ // cannot be changed. The name of the template from which to create
68+ // this database.
6369 // +optional
6470 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="template is immutable"
6571 Template string `json:"template,omitempty"`
6672
67- // The encoding (cannot be changed)
73+ // Maps to the `ENCODING` parameter of `CREATE DATABASE`. This setting
74+ // cannot be changed. Character set encoding to use in the database.
6875 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="encoding is immutable"
6976 // +optional
7077 Encoding string `json:"encoding,omitempty"`
7178
72- // The locale (cannot be changed)
73- // Sets the default collation order and character classification in the new database.
79+ // Maps to the `LOCALE` parameter of `CREATE DATABASE`. This setting
80+ // cannot be changed. Sets the default collation order and character
81+ // classification in the new database.
7482 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="locale is immutable"
7583 // +optional
7684 Locale string `json:"locale,omitempty"`
7785
78- // The LOCALE_PROVIDER (cannot be changed)
79- // This option sets the locale provider for databases created in the new cluster.
80- // Available from PostgreSQL 16.
86+ // Maps to the ` LOCALE_PROVIDER` parameter of `CREATE DATABASE`. This
87+ // setting cannot be changed. This option sets the locale provider for
88+ // databases created in the new cluster. Available from PostgreSQL 16.
8189 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="localeProvider is immutable"
8290 // +optional
8391 LocaleProvider string `json:"localeProvider,omitempty"`
8492
85- // The LC_COLLATE (cannot be changed)
93+ // Maps to the `LC_COLLATE` parameter of `CREATE DATABASE`. This
94+ // setting cannot be changed.
8695 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="localeCollate is immutable"
8796 // +optional
8897 LcCollate string `json:"localeCollate,omitempty"`
8998
90- // The LC_CTYPE (cannot be changed)
99+ // Maps to the `LC_CTYPE` parameter of `CREATE DATABASE`. This setting
100+ // cannot be changed.
91101 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="localeCType is immutable"
92102 // +optional
93103 LcCtype string `json:"localeCType,omitempty"`
94104
95- // The ICU_LOCALE (cannot be changed)
96- // Specifies the ICU locale when the ICU provider is used.
97- // This option requires `localeProvider` to be set to `icu`.
98- // Available from PostgreSQL 15.
105+ // Maps to the ` ICU_LOCALE` parameter of `CREATE DATABASE`. This
106+ // setting cannot be changed. Specifies the ICU locale when the ICU
107+ // provider is used. This option requires `localeProvider` to be set to
108+ // `icu`. Available from PostgreSQL 15.
99109 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="icuLocale is immutable"
100110 // +optional
101111 IcuLocale string `json:"icuLocale,omitempty"`
102112
103- // The ICU_RULES (cannot be changed)
104- // Specifies additional collation rules to customize the behavior of the default collation.
105- // This option requires `localeProvider` to be set to `icu`.
106- // Available from PostgreSQL 16.
113+ // Maps to the ` ICU_RULES` parameter of `CREATE DATABASE`. This setting
114+ // cannot be changed. Specifies additional collation rules to customize
115+ // the behavior of the default collation. This option requires
116+ // `localeProvider` to be set to `icu`. Available from PostgreSQL 16.
107117 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="icuRules is immutable"
108118 // +optional
109119 IcuRules string `json:"icuRules,omitempty"`
110120
111- // The BUILTIN_LOCALE (cannot be changed)
112- // Specifies the locale name when the builtin provider is used.
113- // This option requires `localeProvider` to be set to `builtin`.
114- // Available from PostgreSQL 17.
121+ // Maps to the ` BUILTIN_LOCALE` parameter of `CREATE DATABASE`. This
122+ // setting cannot be changed. Specifies the locale name when the
123+ // builtin provider is used. This option requires `localeProvider` to
124+ // be set to `builtin`. Available from PostgreSQL 17.
115125 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="builtinLocale is immutable"
116126 // +optional
117127 BuiltinLocale string `json:"builtinLocale,omitempty"`
118128
119- // The COLLATION_VERSION (cannot be changed)
129+ // Maps to the `COLLATION_VERSION` parameter of `CREATE DATABASE`. This
130+ // setting cannot be changed.
120131 // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="collationVersion is immutable"
121132 // +optional
122133 CollationVersion string `json:"collationVersion,omitempty"`
123134
124- // True when the database is a template
135+ // Maps to the `IS_TEMPLATE` parameter of `CREATE DATABASE` and `ALTER
136+ // DATABASE`. If true, this database is considered a template and can
137+ // be cloned by any user with `CREATEDB` privileges.
125138 // +optional
126139 IsTemplate * bool `json:"isTemplate,omitempty"`
127140
128- // True when connections to this database are allowed
141+ // Maps to the `ALLOW_CONNECTIONS` parameter of `CREATE DATABASE` and
142+ // `ALTER DATABASE`. If false then no one can connect to this database.
129143 // +optional
130144 AllowConnections * bool `json:"allowConnections,omitempty"`
131145
132- // Connection limit, -1 means no limit and -2 means the
133- // database is not valid
146+ // Maps to the `CONNECTION LIMIT` clause of `CREATE DATABASE` and
147+ // `ALTER DATABASE`. How many concurrent connections can be made to
148+ // this database. -1 (the default) means no limit.
134149 // +optional
135150 ConnectionLimit * int `json:"connectionLimit,omitempty"`
136151
137- // The default tablespace of this database
152+ // Maps to the `TABLESPACE` parameter of `CREATE DATABASE`.
153+ // Maps to the `SET TABLESPACE` command of `ALTER DATABASE`.
154+ // The name of the tablespace (in PostgreSQL) that will be associated
155+ // with the new database. This tablespace will be the default
156+ // tablespace used for objects created in this database.
138157 // +optional
139158 Tablespace string `json:"tablespace,omitempty"`
140159
141- // The policy for end-of-life maintenance of this database
160+ // The policy for end-of-life maintenance of this database.
142161 // +kubebuilder:validation:Enum=delete;retain
143162 // +kubebuilder:default:=retain
144163 // +optional
0 commit comments