mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
25c9d7371d
* 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 <eliobischof@gmail.com> * fix(destroy): needs no self-reconciling Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> * fix(logs): fix double handled error Co-authored-by: Elio Bischof <eliobischof@gmail.com> Co-authored-by: Elio Bischof <eliobischof@gmail.com>
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
package zitadel
|
|
|
|
import (
|
|
"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/orbos/pkg/tree"
|
|
"github.com/caos/zitadel/operator/api/zitadel"
|
|
"github.com/caos/zitadel/operator/zitadel/kinds/orb"
|
|
)
|
|
|
|
func CrdScaleDown(
|
|
monitor mntr.Monitor,
|
|
k8sClient *kubernetes.Client,
|
|
version *string,
|
|
) error {
|
|
desired, err := zitadel.ReadCrd(k8sClient)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return scaleDown(monitor, nil, k8sClient, false, version, desired)
|
|
}
|
|
|
|
func GitOpsScaleDown(
|
|
monitor mntr.Monitor,
|
|
orbCfg *orbconfig.Orb,
|
|
gitClient *git.Client,
|
|
k8sClient *kubernetes.Client,
|
|
version *string,
|
|
) error {
|
|
desired, err := gitClient.ReadTree(git.ZitadelFile)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return scaleDown(monitor, orbCfg, k8sClient, true, version, desired)
|
|
}
|
|
|
|
//Take care! to use this function you have to include migration files into the binary
|
|
func scaleDown(
|
|
monitor mntr.Monitor,
|
|
orbCfg *orbconfig.Orb,
|
|
k8sClient *kubernetes.Client,
|
|
gitops bool,
|
|
version *string,
|
|
desired *tree.Tree,
|
|
) error {
|
|
current := &tree.Tree{}
|
|
query, _, _, _, _, _, err := orb.AdaptFunc(orbCfg, "scaledown", version, gitops, []string{"scaledown"})(monitor, desired, current)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
ensure, err := query(k8sClient, map[string]interface{}{})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := ensure(k8sClient); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|