Skip to content

Commit

Permalink
Add MariaDB Archiver API (#1170)
Browse files Browse the repository at this point in the history
Signed-off-by: Md. Alif Biswas <alif@appscode.com>
Signed-off-by: hmsayem <hmsayem@appscode.com>
Co-authored-by: Md. Alif Biswas <alif@appscode.com>
  • Loading branch information
hmsayem and Md. Alif Biswas authored Mar 8, 2024
1 parent 403b738 commit bfad33d
Show file tree
Hide file tree
Showing 29 changed files with 13,342 additions and 6 deletions.
3 changes: 3 additions & 0 deletions apis/archiver/fuzzer/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
func(s *v1alpha1.PostgresArchiver, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
},
func(s *v1alpha1.MariaDBArchiver, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
},
}
}
4 changes: 4 additions & 0 deletions apis/archiver/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ func (_ PostgresArchiver) CustomResourceDefinition() *apiextensions.CustomResour
func (_ MySQLArchiver) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMySQLArchiver))
}

func (_ MariaDBArchiver) CustomResourceDefinition() *apiextensions.CustomResourceDefinition {
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMariaDBArchiver))
}
95 changes: 95 additions & 0 deletions apis/archiver/v1alpha1/mariadbarchiver_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
Copyright 2022.
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 (
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1alpha2"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kmapi "kmodules.xyz/client-go/api/v1"
)

const (
ResourceKindMariaDBArchiver = "MariaDBArchiver"
ResourceSingularMariaDBArchiver = "mariadbarchiver"
ResourcePluralMariaDBArchiver = "mariadbarchivers"
)

// +genclient
// +k8s:openapi-gen=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=mariadbarchivers,singular=mariadbarchiver,shortName=mdarchiver,categories={archiver,kubedb,appscode}
// +kubebuilder:subresource:status
type MariaDBArchiver struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec MariaDBArchiverSpec `json:"spec,omitempty"`
Status MariaDBArchiverStatus `json:"status,omitempty"`
}

// MariaDBArchiverSpec defines the desired state of MariaDBArchiver
type MariaDBArchiverSpec struct {
// Databases define which MariaDB databases are allowed to consume this archiver
Databases *dbapi.AllowedConsumers `json:"databases"`
// Pause defines if the backup process should be paused or not
// +optional
Pause bool `json:"pause,omitempty"`
// RetentionPolicy refers to a RetentionPolicy CR which defines how to cleanup the old Snapshots
// +optional
RetentionPolicy *kmapi.ObjectReference `json:"retentionPolicy"`
// FullBackup defines the session configuration for the full backup
// +optional
FullBackup *FullBackupOptions `json:"fullBackup"`
// WalBackup defines the sidekick configuration for the wal backup
// +optional
WalBackup *WalBackupOptions `json:"walBackup"`
// ManifestBackup defines the session configuration for the manifest backup
// This options will eventually go to the manifest-backup job's yaml
// +optional
ManifestBackup *ManifestBackupOptions `json:"manifestBackup"`
// EncryptionSecret refers to the Secret containing the encryption key used to encode backed-up data.
// +optional
EncryptionSecret *kmapi.ObjectReference `json:"encryptionSecret"`
// BackupStorage holds the storage information for storing backup data
// +optional
BackupStorage *BackupStorage `json:"backupStorage"`
// DeletionPolicy defines the DeletionPolicy for the backup repository
// +optional
DeletionPolicy *DeletionPolicy `json:"deletionPolicy"`
}

// MariaDBArchiverStatus defines the observed state of MariaDBArchiver
type MariaDBArchiverStatus struct {
// Specifies the information of all the databases managed by this archiver
// +optional
DatabaseRefs []ArchiverDatabaseRef `json:"databaseRefs,omitempty"`
}

// +kubebuilder:object:root=true
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type MariaDBArchiverList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MariaDBArchiver `json:"items"`
}

func init() {
SchemeBuilder.Register(&MariaDBArchiver{}, &MariaDBArchiverList{})
}
199 changes: 199 additions & 0 deletions apis/archiver/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bfad33d

Please sign in to comment.