-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelationaldatabaseprovider_types.go
More file actions
118 lines (94 loc) · 4.14 KB
/
relationaldatabaseprovider_types.go
File metadata and controls
118 lines (94 loc) · 4.14 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
/*
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"
)
// Connection defines the connection to a relational database like MySQL or PostgreSQL
type Connection struct {
//+kubebuilder:required
// Name is the name of the relational database like MySQL or PostgreSQL connection
// it is used to identify the connection. Please use a unique name
// for each connection. This field will be used in the DatabaseRequest
// to reference the connection. The relationaldatabaseprovider controller will
// error if the name is not unique.
Name string `json:"name"`
//+kubebuilder:required
// Hostname is the hostname of the relational database
Hostname string `json:"hostname"`
//+kubebuilder:optional
// ReplicaHostnames is the list of hostnames of the relational database replicas
ReplicaHostnames []string `json:"replicaHostnames,omitempty"`
//+kubebuilder:required
// PasswordSecretRef is the reference to the secret containing the password
PasswordSecretRef v1.SecretReference `json:"passwordSecretRef"`
//+kubebuilder:required
//+kubebuilder:validation:Required
//+kubebuilder:validation:Minimum=1
//+kubebuilder:validation:Maximum=65535
// Port is the port of the relational database
Port int `json:"port"`
//+kubebuilder:required
// Username is the username of the relational database
Username string `json:"username"`
//+kubebuilder:optional
//+kubebuilder:default:=true
// Enabled is a flag to enable or disable the relational database
Enabled bool `json:"enabled,omitempty"`
}
// RelationalDatabaseProviderSpec defines the desired state of RelationalDatabaseProvider
type RelationalDatabaseProviderSpec struct {
//+kubebuilder:required
//+kubebuilder:validation:Required
//+kubebuilder:validation:Enum=mysql;postgres
// Type is the type of the relational database provider
// it can be either "mysql" or "postgres"
Type string `json:"type"`
//+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:validation:MinItems=1
// Connections defines the connection to a relational database
Connections []Connection `json:"connections"`
}
// RelationalDatabaseProviderStatus defines the observed state of RelationalDatabaseProvider
type RelationalDatabaseProviderStatus struct {
// Conditions defines the status conditions
Conditions []metav1.Condition `json:"conditions,omitempty"`
// ConnectionStatus provides the status of the relational database
ConnectionStatus []ConnectionStatus `json:"connectionStatus,omitempty"` // nolint:lll
// ObservedGeneration is the last observed generation
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:resource:scope=Cluster
// RelationalDatabaseProvider is the Schema for the relationaldatabaseprovider API
type RelationalDatabaseProvider struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec RelationalDatabaseProviderSpec `json:"spec,omitempty"`
Status RelationalDatabaseProviderStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// RelationalDatabaseProviderList contains a list of RelationalDatabaseProvider
type RelationalDatabaseProviderList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []RelationalDatabaseProvider `json:"items"`
}
func init() {
SchemeBuilder.Register(&RelationalDatabaseProvider{}, &RelationalDatabaseProviderList{})
}