mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-19 19:48:45 +00:00
fix(zitadelctl): implementation for commands in crd mode (#1685)
* 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: determine mode by --gitops flag for backups * refactor: return error instead of higher order function * fix(destroy): needs no self-reconciling Co-authored-by: Elio Bischof <[email protected]> * fix(destroy): needs no self-reconciling Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <[email protected]> Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
co-authored by
Elio Bischof
parent
413ed80611
commit
25c9d7371d
@@ -0,0 +1,44 @@
|
||||
package crtlgitops
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/caos/orbos/mntr"
|
||||
"github.com/caos/orbos/pkg/git"
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
orbconfig "github.com/caos/orbos/pkg/orb"
|
||||
"github.com/caos/zitadel/operator/database"
|
||||
orbdb "github.com/caos/zitadel/operator/database/kinds/orb"
|
||||
"github.com/caos/zitadel/operator/zitadel"
|
||||
orbz "github.com/caos/zitadel/operator/zitadel/kinds/orb"
|
||||
)
|
||||
|
||||
func DestroyOperator(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.Client, version *string, gitops bool) error {
|
||||
|
||||
orbConfig, err := orbconfig.ParseOrbConfig(orbConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gitClient := git.New(context.Background(), monitor, "orbos", "[email protected]")
|
||||
if err := gitClient.Configure(orbConfig.URL, []byte(orbConfig.Repokey)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return zitadel.Destroy(monitor, gitClient, orbz.AdaptFunc(orbConfig, "ensure", version, gitops, []string{"zitadel", "iam"}), k8sClient)
|
||||
}
|
||||
|
||||
func DestroyDatabase(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.Client, version *string, gitops bool) error {
|
||||
|
||||
orbConfig, err := orbconfig.ParseOrbConfig(orbConfigPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gitClient := git.New(context.Background(), monitor, "orbos", "[email protected]")
|
||||
if err := gitClient.Configure(orbConfig.URL, []byte(orbConfig.Repokey)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return database.Destroy(monitor, gitClient, orbdb.AdaptFunc("", version, gitops, "operator", "database", "backup"), k8sClient)
|
||||
}
|
||||
@@ -13,8 +13,6 @@ import (
|
||||
"github.com/caos/orbos/pkg/kubernetes"
|
||||
orbconfig "github.com/caos/orbos/pkg/orb"
|
||||
"github.com/caos/zitadel/operator/zitadel/kinds/orb"
|
||||
"github.com/caos/zitadel/pkg/databases"
|
||||
kubernetes2 "github.com/caos/zitadel/pkg/kubernetes"
|
||||
)
|
||||
|
||||
func Operator(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.Client, version *string, gitops bool) error {
|
||||
@@ -54,61 +52,6 @@ func Operator(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.
|
||||
return nil
|
||||
}
|
||||
|
||||
func Restore(
|
||||
monitor mntr.Monitor,
|
||||
gitClient *git.Client,
|
||||
orbCfg *orbconfig.Orb,
|
||||
k8sClient *kubernetes.Client,
|
||||
backup string,
|
||||
gitops bool,
|
||||
version *string,
|
||||
) error {
|
||||
databasesList := []string{
|
||||
"notification",
|
||||
"adminapi",
|
||||
"auth",
|
||||
"authz",
|
||||
"eventstore",
|
||||
"management",
|
||||
}
|
||||
|
||||
if err := kubernetes2.ScaleZitadelOperator(monitor, k8sClient, 0); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := zitadel.Takeoff(monitor, gitClient, orb.AdaptFunc(orbCfg, "scaledown", version, gitops, []string{"scaledown"}), k8sClient)(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := databases.Clear(monitor, k8sClient, gitClient, databasesList); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := zitadel.Takeoff(monitor, gitClient, orb.AdaptFunc(orbCfg, "migration", version, gitops, []string{"migration"}), k8sClient)(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := databases.Restore(
|
||||
monitor,
|
||||
k8sClient,
|
||||
gitClient,
|
||||
backup,
|
||||
databasesList,
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := zitadel.Takeoff(monitor, gitClient, orb.AdaptFunc(orbCfg, "scaleup", version, gitops, []string{"scaleup"}), k8sClient)(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := kubernetes2.ScaleZitadelOperator(monitor, k8sClient, 1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Database(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.Client, binaryVersion *string, gitops bool) error {
|
||||
takeoffChan := make(chan struct{})
|
||||
go func() {
|
||||
@@ -145,20 +88,3 @@ func Database(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Backup(monitor mntr.Monitor, orbConfigPath string, k8sClient *kubernetes.Client, backup string, binaryVersion *string) error {
|
||||
orbConfig, err := orbconfig.ParseOrbConfig(orbConfigPath)
|
||||
if err != nil {
|
||||
monitor.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
gitClient := git.New(context.Background(), monitor, "orbos", "[email protected]")
|
||||
if err := gitClient.Configure(orbConfig.URL, []byte(orbConfig.Repokey)); err != nil {
|
||||
monitor.Error(err)
|
||||
return err
|
||||
}
|
||||
|
||||
database.Takeoff(monitor, gitClient, orbdb.AdaptFunc(backup, binaryVersion, false, "instantbackup"), k8sClient)()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user