-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mongodb & postgres archiver (#1016)
Signed-off-by: Mohammad Fahim Abrar <fahimabrar@appscode.com> Co-authored-by: Rakibul-Hossain <rakibul.hossain@appscode.com> Co-authored-by: Arnob Kumar Saha <arnob@appscode.com> Co-authored-by: Tamal Saha <tamal@appscode.com> Co-authored-by: Mehedi Hasan <mehedi.hasan@appscode.com> Co-authored-by: hmsayem <hmsayem@appscode.com>
- Loading branch information
1 parent
47793c9
commit 2b06b6e
Showing
198 changed files
with
193,926 additions
and
747 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 fuzzer | ||
|
||
import ( | ||
"kubedb.dev/apimachinery/apis/archiver/v1alpha1" | ||
|
||
fuzz "github.com/google/gofuzz" | ||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" | ||
) | ||
|
||
// Funcs returns the fuzzer functions for this api group. | ||
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { | ||
return []interface{}{ | ||
func(s *v1alpha1.MongoDBArchiver, c fuzz.Continue) { | ||
c.FuzzNoCustom(s) // fuzz self without calling this function again | ||
}, | ||
func(s *v1alpha1.PostgresArchiver, c fuzz.Continue) { | ||
c.FuzzNoCustom(s) // fuzz self without calling this function again | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 install | ||
|
||
import ( | ||
"kubedb.dev/apimachinery/apis/archiver/v1alpha1" | ||
|
||
"k8s.io/apimachinery/pkg/runtime" | ||
utilruntime "k8s.io/apimachinery/pkg/util/runtime" | ||
) | ||
|
||
// Install registers the API group and adds types to a scheme | ||
func Install(scheme *runtime.Scheme) { | ||
utilruntime.Must(v1alpha1.AddToScheme(scheme)) | ||
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 install | ||
|
||
import ( | ||
"testing" | ||
|
||
"kubedb.dev/apimachinery/apis/archiver/fuzzer" | ||
"kubedb.dev/apimachinery/apis/archiver/v1alpha1" | ||
|
||
clientsetscheme "k8s.io/client-go/kubernetes/scheme" | ||
crdfuzz "kmodules.xyz/crd-schema-fuzz" | ||
) | ||
|
||
func TestPruneTypes(t *testing.T) { | ||
Install(clientsetscheme.Scheme) | ||
|
||
// CRD v1 | ||
if crd := (v1alpha1.MongoDBArchiver{}).CustomResourceDefinition(); crd.V1 != nil { | ||
crdfuzz.SchemaFuzzTestForV1CRD(t, clientsetscheme.Scheme, crd.V1, fuzzer.Funcs) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 install | ||
|
||
import ( | ||
"testing" | ||
|
||
"k8s.io/apimachinery/pkg/api/apitesting/roundtrip" | ||
) | ||
|
||
func TestRoundTripTypes(t *testing.T) { | ||
roundtrip.RoundTripTestForAPIGroup(t, Install, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 contains API Schema definitions for the archiver v1alpha1 API group | ||
|
||
// +k8s:deepcopy-gen=package,register | ||
// +k8s:openapi-gen=true | ||
// +k8s:defaulter-gen=TypeMeta | ||
// +kubebuilder:object:generate=true | ||
// +groupName=archiver.kubedb.com | ||
package v1alpha1 | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"sigs.k8s.io/controller-runtime/pkg/scheme" | ||
) | ||
|
||
var ( | ||
// SchemeGroupVersion is group version used to register these objects | ||
SchemeGroupVersion = schema.GroupVersion{Group: "archiver.kubedb.com", Version: "v1alpha1"} | ||
|
||
// SchemeBuilder is used to add go types to the GroupVersionKind scheme | ||
SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion} | ||
|
||
// AddToScheme adds the types in this group-version to the given scheme. | ||
AddToScheme = SchemeBuilder.AddToScheme | ||
) | ||
|
||
// Kind takes an unqualified kind and returns a Group qualified GroupKind | ||
func Kind(kind string) schema.GroupKind { | ||
return SchemeGroupVersion.WithKind(kind).GroupKind() | ||
} | ||
|
||
// Resource takes an unqualified resource and returns a Group qualified GroupResource | ||
func Resource(resource string) schema.GroupResource { | ||
return SchemeGroupVersion.WithResource(resource).GroupResource() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright AppsCode Inc. and Contributors | ||
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 ( | ||
"kubedb.dev/apimachinery/crds" | ||
|
||
"kmodules.xyz/client-go/apiextensions" | ||
) | ||
|
||
func GetFinalizer() string { | ||
return SchemeGroupVersion.Group | ||
} | ||
|
||
func (_ MongoDBArchiver) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { | ||
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralMongoDBArchiver)) | ||
} | ||
|
||
func (_ PostgresArchiver) CustomResourceDefinition() *apiextensions.CustomResourceDefinition { | ||
return crds.MustCustomResourceDefinition(SchemeGroupVersion.WithResource(ResourcePluralPostgresArchiver)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ( | ||
ResourceKindMongoDBArchiver = "MongoDBArchiver" | ||
ResourceSingularMongoDBArchiver = "mongodbarchiver" | ||
ResourcePluralMongoDBArchiver = "mongodbarchivers" | ||
) | ||
|
||
// +genclient | ||
// +k8s:openapi-gen=true | ||
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:path=mongodbarchivers,singular=mongodbarchiver,shortName=mgarchiver,categories={archiver,kubedb,appscode} | ||
// +kubebuilder:subresource:status | ||
type MongoDBArchiver struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
Spec MongoDBArchiverSpec `json:"spec,omitempty"` | ||
Status MongoDBArchiverStatus `json:"status,omitempty"` | ||
} | ||
|
||
// MongoDBArchiverSpec defines the desired state of MongoDBArchiver | ||
type MongoDBArchiverSpec struct { | ||
// Databases define which MongoDB 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 field is the RetentionPolicy of the backupConfiguration's backend | ||
// +optional | ||
RetentionPolicy *kmapi.ObjectReference `json:"retentionPolicy"` | ||
// FullBackup defines the sessionConfig of the fullBackup | ||
// This options will eventually go to the full-backup job's yaml | ||
// +optional | ||
FullBackup *FullBackupOptions `json:"fullBackup"` | ||
// WalBackup defines the config of the WalBackup | ||
// +optional | ||
WalBackup *WalBackupOptions `json:"walBackup"` | ||
// ManifestBackup defines the sessionConfig of the manifestBackup | ||
// This options will eventually go to the manifest-backup job's yaml | ||
// +optional | ||
ManifestBackup *ManifestBackupOptions `json:"manifestBackup"` | ||
// +optional | ||
EncryptionSecret *kmapi.ObjectReference `json:"encryptionSecret"` | ||
// BackupStorage is the backend storageRef of the BackupConfiguration | ||
// +optional | ||
BackupStorage *BackupStorage `json:"backupStorage"` | ||
// DeletionPolicy defines the created repository's deletionPolicy | ||
// +optional | ||
DeletionPolicy *DeletionPolicy `json:"deletionPolicy"` | ||
} | ||
|
||
// MongoDBArchiverStatus defines the observed state of MongoDBArchiver | ||
type MongoDBArchiverStatus 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 MongoDBArchiverList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []MongoDBArchiver `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&MongoDBArchiver{}, &MongoDBArchiverList{}) | ||
} |
Oops, something went wrong.