-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabaserequest_types.go
More file actions
150 lines (122 loc) · 5.42 KB
/
databaserequest_types.go
File metadata and controls
150 lines (122 loc) · 5.42 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// AdditionalUser defines the additional user to be created
type AdditionalUser struct {
//+kubebuilder:validation:Required
//+kubebuilder:validation:Enum=read-only;read-write
//+kubebuilder:default:=read-only
// Type is the type of user to be created
// it can be either "read-only" or "read-write"
Type string `json:"type"`
//+kubebuilder:required
//+kubebuilder:validation:Required
// Name is the name of the service we are creating. Similar to the name of the DatabaseRequestSpec.
// for example mariadb-read-only-0
Name string `json:"name"`
}
// DatabaseConnectionReference defines the reference to a database connection
type DatabaseConnectionReference struct {
//+kubebuilder:required
// DatabaseObjectReference is the reference to the database object.
// Note that this is a way for the provider to find all database requests
// that are using the same database connection and update them if necessary.
DatabaseObjectReference v1.ObjectReference `json:"databaseObjectReference"`
//+kubebuilder:required
// Name is the name of the database connection.
Name string `json:"name"`
}
// DatabaseRequestSpec defines the desired state of DatabaseRequest
type DatabaseRequestSpec struct {
//+kubebuilder:required
//+kubebuilder:validation:Required
// Name is used for the service name and the prefix in the secret data
// for example mariadb-0
Name string `json:"name"`
//+kubebuilder:required
//+kubebuilder:validation:Required
// Selector is the name of the database request, this is used to select a provider from a pool of providers with the same selector
Selector string `json:"selector"`
//+kubebuilder:required
//+kubebuilder:validation:Required
//+kubebuilder:validation:Enum=mysql;mariadb;postgres;mongodb
// Type is the type of the database request
// it can be either "mysql" or "mariadb" or "postgres" or "mongodb"
Type string `json:"type"`
//+kubebuilder:optional
// Seed is the seed for the database request
// it is a reference to a local secret within the same namespace
Seed *v1.SecretReference `json:"seed,omitempty"`
//+kubebuilder:optional
// AdditionalUsers defines the additional users to be created
AdditionalUsers []AdditionalUser `json:"additionalUsers,omitempty"`
//+kubebuilder:optional
// DatabaseConnectionReference is the reference to a database connection. This makes it possible for the
// database provider to update the database request if necessary by updating the referenced object.
DatabaseConnectionReference *DatabaseConnectionReference `json:"databaseConnectionReference,omitempty"`
//+kubebuilder:default:=true
// DropDatabaseOnDelete defines if the database should be dropped when the request is deleted
DropDatabaseOnDelete bool `json:"dropDatabaseOnDelete,omitempty"`
//+kubebuilder:optional
// ForcedReconcilation is a timestamp based field to force the reconciliation of the database request
// This field is used to force the reconciliation of the database request.
ForcedReconcilation *metav1.Time `json:"forcedReconcilation,omitempty"`
}
// DatabaseInfo provides some database information
type DatabaseInfo struct {
//+kubebuilder:required
// Username is the username of the database
Username string `json:"username"`
//+kubebuilder:required
// DatabaseName is the name of the database
Databasename string `json:"databasename"`
}
// DatabaseRequestStatus defines the observed state of DatabaseRequest
type DatabaseRequestStatus struct {
//+kubebuilder:optional
// Conditions is the observed conditions
Conditions []metav1.Condition `json:"conditions,omitempty"`
//+kubebuilder:optional
// ObservedGeneration is the last observed generation
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
//+kubebuilder:optional
// ObservedDatabaseConnectionReference is the observed database connection reference
// This is a way for the controller to know if the database provider has updated the database connection.
ObservedDatabaseConnectionReference *DatabaseConnectionReference `json:"observedDatabaseConnectionReference,omitempty"`
//+kubebuilder:optional
// DatabaseInfo is the database information
DatabaseInfo *DatabaseInfo `json:"databaseInfo,omitempty"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
// DatabaseRequest is the Schema for the databaserequests API
type DatabaseRequest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec DatabaseRequestSpec `json:"spec,omitempty"`
Status DatabaseRequestStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// DatabaseRequestList contains a list of DatabaseRequest
type DatabaseRequestList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []DatabaseRequest `json:"items"`
}
func init() {
SchemeBuilder.Register(&DatabaseRequest{}, &DatabaseRequestList{})
}