/
connectionpool_types.go
83 lines (65 loc) · 2.84 KB
/
connectionpool_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
// Copyright (c) 2021 Aiven, Helsinki, Finland. https://aiven.io/
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// ConnectionPoolSpec defines the desired state of ConnectionPool
type ConnectionPoolSpec struct {
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Format="^[a-zA-Z0-9_-]*$"
// Target project.
Project string `json:"project"`
// +kubebuilder:validation:MaxLength=63
// Service name.
ServiceName string `json:"serviceName"`
// +kubebuilder:validation:MaxLength=40
// Name of the database the pool connects to
DatabaseName string `json:"databaseName"`
// +kubebuilder:validation:MaxLength=64
// Name of the service user used to connect to the database
Username string `json:"username"`
// +kubebuilder:validation:Min=1
// +kubebuilder:validation:Max=1000
// Number of connections the pool may create towards the backend server
PoolSize int `json:"poolSize,omitempty"`
// +kubebuilder:validation:Enum=session;transaction;statement
// Mode the pool operates in (session, transaction, statement)
PoolMode string `json:"poolMode,omitempty"`
// Information regarding secret creation
ConnInfoSecretTarget ConnInfoSecretTarget `json:"connInfoSecretTarget,omitempty"`
// Authentication reference to Aiven token in a secret
AuthSecretRef AuthSecretReference `json:"authSecretRef"`
}
// ConnectionPoolStatus defines the observed state of ConnectionPool
type ConnectionPoolStatus struct {
// Conditions represent the latest available observations of an ConnectionPool state
Conditions []metav1.Condition `json:"conditions"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// ConnectionPool is the Schema for the connectionpools API
// +kubebuilder:printcolumn:name="Service Name",type="string",JSONPath=".spec.serviceName"
// +kubebuilder:printcolumn:name="Project",type="string",JSONPath=".spec.project"
// +kubebuilder:printcolumn:name="Database",type="string",JSONPath=".spec.databaseName"
// +kubebuilder:printcolumn:name="Username",type="string",JSONPath=".spec.username"
// +kubebuilder:printcolumn:name="Pool Size",type="string",JSONPath=".spec.poolSize"
// +kubebuilder:printcolumn:name="Pool Mode",type="string",JSONPath=".spec.poolMode"
type ConnectionPool struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ConnectionPoolSpec `json:"spec,omitempty"`
Status ConnectionPoolStatus `json:"status,omitempty"`
}
func (cp ConnectionPool) AuthSecretRef() AuthSecretReference {
return cp.Spec.AuthSecretRef
}
// +kubebuilder:object:root=true
// ConnectionPoolList contains a list of ConnectionPool
type ConnectionPoolList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ConnectionPool `json:"items"`
}
func init() {
SchemeBuilder.Register(&ConnectionPool{}, &ConnectionPoolList{})
}