mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 04:18:01 +00:00
425a8b5fd5
* fix(zitadelctl): implement takedown command * fix(zitadelctl): correct destroy flow * fix(zitadelctl): correct backup commands to read crds beforehand * fix: add of destroyfile * fix: clean for userlist * fix: change backup and restore to crdb native * fix: timeout for delete pvc for cockroachdb * fix: corrected unit tests * fix: add ignored file for scale * fix: correct handling of gitops in backup command * feat: add s3 backup kind * fix: backuplist for s3 and timeout for pv deletion * fix(database): fix nil pointer with binary version * fix(database): cleanup of errors which cam with merging of the s3 logic * fix: correct unit tests * fix: cleanup monitor output Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix: backup imagepullpolixy to ifnotpresent Co-authored-by: Elio Bischof <eliobischof@gmail.com>
108 lines
2.4 KiB
Go
108 lines
2.4 KiB
Go
package backups
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/caos/orbos/mntr"
|
|
"github.com/caos/orbos/pkg/kubernetes"
|
|
"github.com/caos/orbos/pkg/labels"
|
|
"github.com/caos/orbos/pkg/secret"
|
|
"github.com/caos/orbos/pkg/tree"
|
|
"github.com/caos/zitadel/operator"
|
|
"github.com/caos/zitadel/operator/database/kinds/backups/bucket"
|
|
"github.com/caos/zitadel/operator/database/kinds/backups/s3"
|
|
corev1 "k8s.io/api/core/v1"
|
|
)
|
|
|
|
func Adapt(
|
|
monitor mntr.Monitor,
|
|
desiredTree *tree.Tree,
|
|
currentTree *tree.Tree,
|
|
name string,
|
|
namespace string,
|
|
componentLabels *labels.Component,
|
|
checkDBReady operator.EnsureFunc,
|
|
timestamp string,
|
|
nodeselector map[string]string,
|
|
tolerations []corev1.Toleration,
|
|
version string,
|
|
dbURL string,
|
|
dbPort int32,
|
|
features []string,
|
|
customImageRegistry string,
|
|
) (
|
|
operator.QueryFunc,
|
|
operator.DestroyFunc,
|
|
operator.ConfigureFunc,
|
|
map[string]*secret.Secret,
|
|
map[string]*secret.Existing,
|
|
bool,
|
|
error,
|
|
) {
|
|
switch desiredTree.Common.Kind {
|
|
case "databases.caos.ch/BucketBackup":
|
|
return bucket.AdaptFunc(
|
|
name,
|
|
namespace,
|
|
labels.MustForComponent(
|
|
labels.MustReplaceAPI(
|
|
labels.GetAPIFromComponent(componentLabels),
|
|
"BucketBackup",
|
|
desiredTree.Common.Version(),
|
|
),
|
|
"backup"),
|
|
checkDBReady,
|
|
timestamp,
|
|
nodeselector,
|
|
tolerations,
|
|
version,
|
|
dbURL,
|
|
dbPort,
|
|
features,
|
|
customImageRegistry,
|
|
)(monitor, desiredTree, currentTree)
|
|
case "databases.caos.ch/S3Backup":
|
|
return s3.AdaptFunc(
|
|
name,
|
|
namespace,
|
|
labels.MustForComponent(
|
|
labels.MustReplaceAPI(
|
|
labels.GetAPIFromComponent(componentLabels),
|
|
"S3Backup",
|
|
desiredTree.Common.Version(),
|
|
),
|
|
"backup"),
|
|
checkDBReady,
|
|
timestamp,
|
|
nodeselector,
|
|
tolerations,
|
|
version,
|
|
dbURL,
|
|
dbPort,
|
|
features,
|
|
customImageRegistry,
|
|
)(monitor, desiredTree, currentTree)
|
|
default:
|
|
return nil, nil, nil, nil, nil, false, mntr.ToUserError(fmt.Errorf("unknown database kind %s", desiredTree.Common.Kind))
|
|
}
|
|
}
|
|
|
|
func GetBackupList(
|
|
monitor mntr.Monitor,
|
|
k8sClient kubernetes.ClientInt,
|
|
name string,
|
|
desiredTree *tree.Tree,
|
|
) (
|
|
[]string,
|
|
error,
|
|
) {
|
|
switch desiredTree.Common.Kind {
|
|
case "databases.caos.ch/BucketBackup":
|
|
return bucket.BackupList()(monitor, k8sClient, name, desiredTree)
|
|
case "databases.caos.ch/S3Backup":
|
|
return s3.BackupList()(monitor, k8sClient, name, desiredTree)
|
|
default:
|
|
return nil, mntr.ToUserError(fmt.Errorf("unknown database kind %s", desiredTree.Common.Kind))
|
|
}
|
|
}
|