/
keycloakbackup_types.go
148 lines (134 loc) · 5.31 KB
/
keycloakbackup_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
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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// KeycloakBackupSpec defines the desired state of KeycloakBackup.
// +k8s:openapi-gen=true
type KeycloakBackupSpec struct {
// Controls automatic restore behavior.
// Currently not implemented.
//
// In the future this will be used to trigger automatic restore for a given KeycloakBackup.
// Each backup will correspond to a single snapshot of the database (stored either in a
// Persistent Volume or AWS). If a user wants to restore it, all he/she needs to do is to
// change this flag to true.
// Potentially, it will be possible to restore a single backup multiple times.
// +optional
Restore bool `json:"restore,omitempty"`
// If provided, an automatic database backup will be created on AWS S3 instead of
// a local Persistent Volume. If this property is not provided - a local
// Persistent Volume backup will be chosen.
// +optional
AWS KeycloakAWSSpec `json:"aws,omitempty"`
// Selector for looking up Keycloak Custom Resources.
// +kubebuilder:validation:Required
InstanceSelector *metav1.LabelSelector `json:"instanceSelector,omitempty"`
// Name of the StorageClass for Postgresql Backup Persistent Volume Claim
// +optional
StorageClassName *string `json:"storageClassName,omitempty"`
}
// KeycloakAWSSpec defines the desired state of KeycloakBackupSpec.
// +k8s:openapi-gen=true
type KeycloakAWSSpec struct {
// If provided, the database backup will be encrypted.
// Provides a secret name used for encrypting database data.
// The secret needs to be in the following form:
//
// apiVersion: v1
// kind: Secret
// metadata:
// name: <Secret name>
// type: Opaque
// stringData:
// GPG_PUBLIC_KEY: <GPG Public Key>
// GPG_TRUST_MODEL: <GPG Trust Model>
// GPG_RECIPIENT: <GPG Recipient>
//
// For more information, please refer to the Operator documentation.
// +optional
EncryptionKeySecretName string `json:"encryptionKeySecretName,omitempty"`
// Provides a secret name used for connecting to AWS S3 Service.
// The secret needs to be in the following form:
//
// apiVersion: v1
// kind: Secret
// metadata:
// name: <Secret name>
// type: Opaque
// stringData:
// AWS_S3_BUCKET_NAME: <S3 Bucket Name>
// AWS_ACCESS_KEY_ID: <AWS Access Key ID>
// AWS_SECRET_ACCESS_KEY: <AWS Secret Key>
//
// For more information, please refer to the Operator documentation.
// +kubebuilder:validation:Required
CredentialsSecretName string `json:"credentialsSecretName,omitempty"`
// If specified, it will be used as a schedule for creating a CronJob.
// +optional
Schedule string `json:"schedule,omitempty"`
}
// BackupStatusPhase ...
type BackupStatusPhase string
var (
// BackupPhaseNone ...
BackupPhaseNone BackupStatusPhase
// BackupPhaseReconciling ...
BackupPhaseReconciling BackupStatusPhase = "reconciling"
// BackupPhaseCreated ...
BackupPhaseCreated BackupStatusPhase = "created"
// BackupPhaseRestored ...
BackupPhaseRestored BackupStatusPhase = "restored"
// BackupPhaseFailing ...
BackupPhaseFailing BackupStatusPhase = "failing"
)
// +k8s:openapi-gen=true
// KeycloakBackupStatus defines the observed state of KeycloakBackup.
type KeycloakBackupStatus struct {
// Current phase of the operator.
Phase BackupStatusPhase `json:"phase"`
// Human-readable message indicating details about current operator phase or error.
Message string `json:"message"`
// True if all resources are in a ready state and all work is done.
Ready bool `json:"ready"`
// A map of all the secondary resources types and names created for this CR. e.g "Deployment": [ "DeploymentName1", "DeploymentName2" ]
SecondaryResources map[string][]string `json:"secondaryResources,omitempty"`
}
// +genclient
// +k8s:openapi-gen=true
// +kubebuilder:subresource:status
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KeycloakBackup is the Schema for the keycloakbackups API.
type KeycloakBackup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec KeycloakBackupSpec `json:"spec,omitempty"`
Status KeycloakBackupStatus `json:"status,omitempty"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// KeycloakBackupList contains a list of KeycloakBackup.
type KeycloakBackupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []KeycloakBackup `json:"items"`
}
func init() {
SchemeBuilder.Register(&KeycloakBackup{}, &KeycloakBackupList{})
}