@@ -27,34 +27,34 @@ const (
27
27
DEFAULT_POSTGRESQL_ROOT_AUTHENTICATION_DATABASE = "postgres"
28
28
)
29
29
30
- type PostgreSQLRootSecretLookup struct {
30
+ type PostgreSQLDatabaseRootSecretLookup struct {
31
31
Name string `json:"name"`
32
32
Namespace string `json:"namespace"`
33
33
Field string `json:"field"`
34
34
}
35
35
36
- type PostgreSQLCredentials []PostgreSQLCredential
37
- type PostgreSQLCredential struct {
36
+ type PostgreSQLDatabaseCredentials []PostgreSQLDatabaseCredential
37
+ type PostgreSQLDatabaseCredential struct {
38
38
UserName string `json:"username"`
39
39
Vault Vault `json:"vault"`
40
40
}
41
41
42
- // PostgreSQLSpec defines the desired state of PostgreSQL
42
+ // PostgreSQLDatabaseSpec defines the desired state of PostgreSQLDatabase
43
43
// IMPORTANT: Run "make" to regenerate code after modifying this file
44
- type PostgreSQLSpec struct {
44
+ type PostgreSQLDatabaseSpec struct {
45
45
DatabaseName string `json:"databaseName"`
46
46
HostName string `json:"hostName"`
47
47
// +optional
48
48
RootUsername string `json:"rootUsername"`
49
49
// +optional
50
- RootAuthenticationDatabase string `json:"rootAuthDatabase"`
51
- RootSecretLookup PostgreSQLRootSecretLookup `json:"rootSecretLookup"`
52
- Credentials PostgreSQLCredentials `json:"credentials"`
50
+ RootAuthenticationDatabase string `json:"rootAuthDatabase"`
51
+ RootSecretLookup PostgreSQLDatabaseRootSecretLookup `json:"rootSecretLookup"`
52
+ Credentials PostgreSQLDatabaseCredentials `json:"credentials"`
53
53
}
54
54
55
- // PostgreSQLStatus defines the observed state of PostgreSQL
55
+ // PostgreSQLDatabaseStatus defines the observed state of PostgreSQLDatabase
56
56
// IMPORTANT: Run "make" to regenerate code after modifying this file
57
- type PostgreSQLStatus struct {
57
+ type PostgreSQLDatabaseStatus struct {
58
58
DatabaseStatus DatabaseStatus `json:"database"`
59
59
CredentialsStatus CredentialsStatus `json:"credentials"`
60
60
LastUpdateTime metav1.Time `json:"lastUpdateTime"`
@@ -63,36 +63,36 @@ type PostgreSQLStatus struct {
63
63
// +kubebuilder:object:root=true
64
64
// +kubebuilder:subresource:status
65
65
66
- // PostgreSQL is the Schema for the postgresqls API
67
- type PostgreSQL struct {
66
+ // PostgreSQLDatabase is the Schema for the postgresqls API
67
+ type PostgreSQLDatabase struct {
68
68
metav1.TypeMeta `json:",inline"`
69
69
metav1.ObjectMeta `json:"metadata,omitempty"`
70
70
71
- Spec PostgreSQLSpec `json:"spec,omitempty"`
72
- Status PostgreSQLStatus `json:"status,omitempty"`
71
+ Spec PostgreSQLDatabaseSpec `json:"spec,omitempty"`
72
+ Status PostgreSQLDatabaseStatus `json:"status,omitempty"`
73
73
}
74
74
75
75
// +kubebuilder:object:root=true
76
76
77
- // PostgreSQLList contains a list of PostgreSQL
78
- type PostgreSQLList struct {
77
+ // PostgreSQLDatabaseList contains a list of PostgreSQLDatabase
78
+ type PostgreSQLDatabaseList struct {
79
79
metav1.TypeMeta `json:",inline"`
80
80
metav1.ListMeta `json:"metadata,omitempty"`
81
- Items []PostgreSQL `json:"items"`
81
+ Items []PostgreSQLDatabase `json:"items"`
82
82
}
83
83
84
84
/*
85
85
Alignes credentials status with spec by removing unneeded statuses. Mutates the original.
86
86
Returns removed statuses.
87
87
*/
88
- func (postgresql * PostgreSQL ) RemoveUnneededCredentialsStatus () * CredentialsStatus {
88
+ func (d * PostgreSQLDatabase ) RemoveUnneededCredentialsStatus () * CredentialsStatus {
89
89
removedStatuses := make (CredentialsStatus , 0 )
90
- statuses := & postgresql .Status .CredentialsStatus
90
+ statuses := & d .Status .CredentialsStatus
91
91
for i := 0 ; i < len (* statuses ); i ++ {
92
92
status := (* statuses )[i ]
93
93
found := false
94
94
if status != nil {
95
- for _ , credential := range postgresql .Spec .Credentials {
95
+ for _ , credential := range d .Spec .Credentials {
96
96
if credential .UserName == status .Username {
97
97
found = true
98
98
}
@@ -105,32 +105,32 @@ func (postgresql *PostgreSQL) RemoveUnneededCredentialsStatus() *CredentialsStat
105
105
i --
106
106
}
107
107
}
108
- postgresql .Status .CredentialsStatus = * statuses
108
+ d .Status .CredentialsStatus = * statuses
109
109
return & removedStatuses
110
110
}
111
111
112
- func (this * PostgreSQL ) SetDefaults () error {
113
- if this .Spec .RootUsername == "" {
114
- this .Spec .RootUsername = DEFAULT_POSTGRESQL_ROOT_USER
112
+ func (d * PostgreSQLDatabase ) SetDefaults () error {
113
+ if d .Spec .RootUsername == "" {
114
+ d .Spec .RootUsername = DEFAULT_POSTGRESQL_ROOT_USER
115
115
}
116
- if this .Spec .RootAuthenticationDatabase == "" {
117
- this .Spec .RootAuthenticationDatabase = DEFAULT_POSTGRESQL_ROOT_AUTHENTICATION_DATABASE
116
+ if d .Spec .RootAuthenticationDatabase == "" {
117
+ d .Spec .RootAuthenticationDatabase = DEFAULT_POSTGRESQL_ROOT_AUTHENTICATION_DATABASE
118
118
}
119
- if this .Spec .RootSecretLookup .Name == "" {
119
+ if d .Spec .RootSecretLookup .Name == "" {
120
120
return errors .New ("must specify root secret" )
121
121
}
122
- if this .Spec .RootSecretLookup .Field == "" {
122
+ if d .Spec .RootSecretLookup .Field == "" {
123
123
return errors .New ("must specify root secret field" )
124
124
}
125
- if this .Spec .RootSecretLookup .Namespace == "" {
126
- this .Spec .RootSecretLookup .Namespace = this .ObjectMeta .Namespace
125
+ if d .Spec .RootSecretLookup .Namespace == "" {
126
+ d .Spec .RootSecretLookup .Namespace = d .ObjectMeta .Namespace
127
127
}
128
- if this .Status .CredentialsStatus == nil || len (this .Status .CredentialsStatus ) == 0 {
129
- this .Status .CredentialsStatus = make ([]* CredentialStatus , 0 )
128
+ if d .Status .CredentialsStatus == nil || len (d .Status .CredentialsStatus ) == 0 {
129
+ d .Status .CredentialsStatus = make ([]* CredentialStatus , 0 )
130
130
}
131
131
return nil
132
132
}
133
133
134
134
func init () {
135
- SchemeBuilder .Register (& PostgreSQL {}, & PostgreSQLList {})
135
+ SchemeBuilder .Register (& PostgreSQLDatabase {}, & PostgreSQLDatabaseList {})
136
136
}
0 commit comments