zitadel/pkg/zitadel/zitadel.go
Stefan Benz 25c9d7371d
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 <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>
2021-07-20 15:47:48 +02:00

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
}