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:
Stefan Benz
2021-07-20 15:47:48 +02:00
committed by GitHub
co-authored by Elio Bischof
parent 413ed80611
commit 25c9d7371d
48 changed files with 1084 additions and 275 deletions
@@ -30,6 +30,7 @@ func AdaptFunc(
namespace string,
componentLabels *labels.Component,
databases []string,
users []string,
nodeselector map[string]string,
tolerations []corev1.Toleration,
checkDBReady operator.EnsureFunc,
@@ -42,7 +43,7 @@ func AdaptFunc(
err error,
) {
command := getCommand(databases)
command := getCommand(databases, users)
jobDef := getJob(
namespace,
@@ -20,6 +20,7 @@ func TestBackup_Adapt1(t *testing.T) {
monitor := mntr.Monitor{}
namespace := "testNs"
databases := []string{"testDb"}
users := []string{"testUser"}
nodeselector := map[string]string{"test": "test"}
tolerations := []corev1.Toleration{
{Key: "testKey", Operator: "testOp"}}
@@ -44,6 +45,7 @@ func TestBackup_Adapt1(t *testing.T) {
secretKey,
getCommand(
databases,
users,
),
image,
)
@@ -57,6 +59,7 @@ func TestBackup_Adapt1(t *testing.T) {
namespace,
componentLabels,
databases,
users,
nodeselector,
tolerations,
checkDBReady,
@@ -78,6 +81,7 @@ func TestBackup_Adapt2(t *testing.T) {
monitor := mntr.Monitor{}
namespace := "testNs2"
databases := []string{"testDb1", "testDb2"}
users := []string{"testUser1", "testUser2"}
nodeselector := map[string]string{"test2": "test2"}
tolerations := []corev1.Toleration{
{Key: "testKey2", Operator: "testOp2"}}
@@ -102,6 +106,7 @@ func TestBackup_Adapt2(t *testing.T) {
secretKey,
getCommand(
databases,
users,
),
image,
)
@@ -115,6 +120,7 @@ func TestBackup_Adapt2(t *testing.T) {
namespace,
componentLabels,
databases,
users,
nodeselector,
tolerations,
checkDBReady,
@@ -4,6 +4,7 @@ import "strings"
func getCommand(
databases []string,
users []string,
) string {
backupCommands := make([]string, 0)
for _, database := range databases {
@@ -14,12 +15,12 @@ func getCommand(
database,
}, " "))
}
for _, database := range databases {
for _, user := range users {
backupCommands = append(backupCommands,
strings.Join([]string{
"/scripts/clean-user.sh",
certPath,
database,
user,
}, " "))
}
backupCommands = append(backupCommands,
@@ -7,8 +7,9 @@ import (
func TestClean_Command1(t *testing.T) {
databases := []string{}
users := []string{}
cmd := getCommand(databases)
cmd := getCommand(databases, users)
equals := "/scripts/clean-migration.sh " + certPath
assert.Equal(t, equals, cmd)
@@ -16,8 +17,9 @@ func TestClean_Command1(t *testing.T) {
func TestClean_Command2(t *testing.T) {
databases := []string{"test"}
users := []string{"test"}
cmd := getCommand(databases)
cmd := getCommand(databases, users)
equals := "/scripts/clean-db.sh " + certPath + " test && /scripts/clean-user.sh " + certPath + " test && /scripts/clean-migration.sh " + certPath
assert.Equal(t, equals, cmd)
@@ -25,8 +27,9 @@ func TestClean_Command2(t *testing.T) {
func TestClean_Command3(t *testing.T) {
databases := []string{"test1", "test2", "test3"}
users := []string{"test1", "test2", "test3"}
cmd := getCommand(databases)
cmd := getCommand(databases, users)
equals := "/scripts/clean-db.sh " + certPath + " test1 && /scripts/clean-db.sh " + certPath + " test2 && /scripts/clean-db.sh " + certPath + " test3 && " +
"/scripts/clean-user.sh " + certPath + " test1 && /scripts/clean-user.sh " + certPath + " test2 && /scripts/clean-user.sh " + certPath + " test3 && " +
"/scripts/clean-migration.sh " + certPath