/
postgresql_types.go
85 lines (64 loc) · 3.27 KB
/
postgresql_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright (c) 2024 Aiven, Helsinki, Finland. https://aiven.io/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pguserconfig "github.com/aiven/aiven-operator/api/v1alpha1/userconfig/service/pg"
)
// PostgreSQLSpec defines the desired state of postgres instance
// +kubebuilder:validation:XValidation:rule="has(oldSelf.connInfoSecretTargetDisabled) == has(self.connInfoSecretTargetDisabled)",message="connInfoSecretTargetDisabled can only be set during resource creation."
type PostgreSQLSpec struct {
ServiceCommonSpec `json:",inline"`
// +kubebuilder:validation:Format="^[1-9][0-9]*(GiB|G)*"
// The disk space of the service, possible values depend on the service type, the cloud provider and the project. Reducing will result in the service re-balancing.
DiskSpace string `json:"disk_space,omitempty"`
// Authentication reference to Aiven token in a secret
AuthSecretRef *AuthSecretReference `json:"authSecretRef,omitempty"`
// Information regarding secret creation.
// Exposed keys: `POSTGRESQL_HOST`, `POSTGRESQL_PORT`, `POSTGRESQL_DATABASE`, `POSTGRESQL_USER`, `POSTGRESQL_PASSWORD`, `POSTGRESQL_SSLMODE`, `POSTGRESQL_DATABASE_URI`, `POSTGRESQL_CA_CERT`
ConnInfoSecretTarget ConnInfoSecretTarget `json:"connInfoSecretTarget,omitempty"`
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="connInfoSecretTargetDisabled is immutable."
// When true, the secret containing connection information will not be created, defaults to false. This field cannot be changed after resource creation.
ConnInfoSecretTargetDisabled *bool `json:"connInfoSecretTargetDisabled,omitempty"`
// PostgreSQL specific user configuration options
UserConfig *pguserconfig.PgUserConfig `json:"userConfig,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// PostgreSQL is the Schema for the postgresql API
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Project",type="string",JSONPath=".spec.project"
// +kubebuilder:printcolumn:name="Region",type="string",JSONPath=".spec.cloudName"
// +kubebuilder:printcolumn:name="Plan",type="string",JSONPath=".spec.plan"
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state"
type PostgreSQL struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PostgreSQLSpec `json:"spec,omitempty"`
Status ServiceStatus `json:"status,omitempty"`
}
var _ AivenManagedObject = &PostgreSQL{}
func (in *PostgreSQL) NoSecret() bool {
return in.Spec.ConnInfoSecretTargetDisabled != nil && *in.Spec.ConnInfoSecretTargetDisabled
}
func (in *PostgreSQL) AuthSecretRef() *AuthSecretReference {
return in.Spec.AuthSecretRef
}
func (in *PostgreSQL) Conditions() *[]metav1.Condition {
return &in.Status.Conditions
}
func (in *PostgreSQL) GetRefs() []*ResourceReferenceObject {
return in.Spec.GetRefs(in.GetNamespace())
}
func (in *PostgreSQL) GetConnInfoSecretTarget() ConnInfoSecretTarget {
return in.Spec.ConnInfoSecretTarget
}
// +kubebuilder:object:root=true
// PostgreSQLList contains a list of PostgreSQL instances
type PostgreSQLList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PostgreSQL `json:"items"`
}
func init() {
SchemeBuilder.Register(&PostgreSQL{}, &PostgreSQLList{})
}