-
Notifications
You must be signed in to change notification settings - Fork 187
/
mysqlserver_types.go
112 lines (99 loc) · 3.88 KB
/
mysqlserver_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
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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
package v1alpha2
import (
"github.com/Azure/go-autorest/autorest/to"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// MySQLServerSpec defines the desired state of MySQLServer
type MySQLServerSpec struct {
Location string `json:"location"`
// +kubebuilder:validation:Pattern=^[-\w\._\(\)]+$
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
ResourceGroup string `json:"resourceGroup"`
Sku AzureDBsSQLSku `json:"sku,omitempty"`
ServerVersion ServerVersion `json:"serverVersion,omitempty"`
SSLEnforcement SslEnforcementEnum `json:"sslEnforcement,omitempty"`
CreateMode string `json:"createMode,omitempty"`
ReplicaProperties ReplicaProperties `json:"replicaProperties,omitempty"`
StorageProfile *MySQLStorageProfile `json:"storageProfile,omitempty"`
KeyVaultToStoreSecrets string `json:"keyVaultToStoreSecrets,omitempty"`
// +kubebuilder:validation:MinLength=1
// AdminSecret is the name of a Kubernetes secret containing the username and password of the
// MySQLServer administrator account. When specified, the `username` and `password` fields of this
// secret will be included in the generated secret associated with this MySQLServer.
// If AdminSecret is specified but a secret with the given name is not found in the same namespace
// as the MySQLServer, then reconciliation will block until the secret is created.
// If this is not specified, a username and password will be automatically generated.
AdminSecret string `json:"adminSecret,omitempty"`
}
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// MySQLServer is the Schema for the mysqlservers API
// +kubebuilder:resource:shortName=mysqls
// +kubebuilder:printcolumn:name="Provisioned",type="string",JSONPath=".status.provisioned"
// +kubebuilder:printcolumn:name="Message",type="string",JSONPath=".status.message"
type MySQLServer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec MySQLServerSpec `json:"spec,omitempty"`
Status ASOStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// MySQLServerList contains a list of MySQLServer
type MySQLServerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MySQLServer `json:"items"`
}
func init() {
SchemeBuilder.Register(&MySQLServer{}, &MySQLServerList{})
}
func NewDefaultMySQLServer(name, resourceGroup, location string) *MySQLServer {
return &MySQLServer{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
},
Spec: MySQLServerSpec{
Location: location,
ResourceGroup: resourceGroup,
Sku: AzureDBsSQLSku{
Name: "GP_Gen5_4",
Tier: SkuTier("GeneralPurpose"),
Family: "Gen5",
Size: "107374182400",
Capacity: 4,
},
ServerVersion: ServerVersion("8.0"),
SSLEnforcement: SslEnforcementEnumEnabled,
CreateMode: "Default",
StorageProfile: &MySQLStorageProfile{
BackupRetentionDays: to.Int32Ptr(10),
GeoRedundantBackup: "Disabled",
StorageMB: to.Int32Ptr(100 * 1024),
StorageAutogrow: "Disabled",
},
},
}
}
func NewReplicaMySQLServer(name, resourceGroup, location string, sourceserverid string) *MySQLServer {
return &MySQLServer{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: "default",
},
Spec: MySQLServerSpec{
Location: location,
ResourceGroup: resourceGroup,
CreateMode: "Replica",
ReplicaProperties: ReplicaProperties{
SourceServerId: sourceserverid,
},
},
}
}