fix: migration from es v1 (#1462)

* handle old step1

* add migration ES V1 to operator
This commit is contained in:
Livio Amstutz 2021-03-24 09:30:45 +01:00 committed by GitHub
parent d5f54259d6
commit e7c11cb9e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 13 deletions

View File

@ -3,6 +3,7 @@ package iam
import (
"context"
"encoding/json"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/domain"
@ -34,6 +35,10 @@ func SetupStepMapper(event *repository.Event) (eventstore.EventReader, error) {
step := &SetupStepEvent{
BaseEvent: *eventstore.BaseEventFromRepo(event),
Done: eventstore.EventType(event.Type) == SetupDoneEventType,
Step: domain.Step1,
}
if len(event.Data) == 0 {
return step, nil
}
err := json.Unmarshal(event.Data, step)
if err != nil {

View File

@ -3,15 +3,16 @@ package configuration
import "github.com/caos/orbos/pkg/secret"
type Configuration struct {
Tracing *Tracing `yaml:"tracing,omitempty"`
Cache *Cache `yaml:"cache,omitempty"`
Secrets *Secrets `yaml:"secrets,omitempty"`
Notifications *Notifications `yaml:"notifications,omitempty"`
Passwords *Passwords `yaml:"passwords,omitempty"`
DebugMode bool `yaml:"debugMode"`
LogLevel string `yaml:"logLevel"`
DNS *DNS `yaml:"dns"`
ClusterDNS string `yaml:"clusterdns"`
Tracing *Tracing `yaml:"tracing,omitempty"`
Cache *Cache `yaml:"cache,omitempty"`
Secrets *Secrets `yaml:"secrets,omitempty"`
Notifications *Notifications `yaml:"notifications,omitempty"`
Passwords *Passwords `yaml:"passwords,omitempty"`
DebugMode bool `yaml:"debugMode"`
LogLevel string `yaml:"logLevel"`
MigrateEventStoreV1 bool `yaml:"migrateEventstoreV1"`
DNS *DNS `yaml:"dns"`
ClusterDNS string `yaml:"clusterdns"`
}
type DNS struct {

View File

@ -2,10 +2,12 @@ package configuration
import (
"encoding/json"
"github.com/caos/orbos/pkg/kubernetes"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database"
"strconv"
"strings"
"github.com/caos/orbos/pkg/kubernetes"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database"
)
const (
@ -31,6 +33,7 @@ func literalsConfigMap(
"ZITADEL_KEY_PATH": secretPath + "/" + zitadelKeysPath,
"ZITADEL_LOG_LEVEL": "info",
"DEBUG_MODE": strconv.FormatBool(desired.DebugMode),
"ZITADEL_MIGRATE_ES_V1": strconv.FormatBool(desired.MigrateEventStoreV1),
"SMTP_TLS": tls,
"CAOS_OIDC_DEV": "true",
"CR_SSL_MODE": "require",

View File

@ -1,14 +1,16 @@
package configuration
import (
"testing"
kubernetesmock "github.com/caos/orbos/pkg/kubernetes/mock"
"github.com/caos/orbos/pkg/secret"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"testing"
"github.com/caos/zitadel/operator/zitadel/kinds/iam/zitadel/database"
)
var (
@ -191,6 +193,7 @@ func TestConfiguration_LiteralsConfigMap(t *testing.T) {
"SMTP_HOST": "",
"CAOS_OIDC_DEV": "true",
"DEBUG_MODE": "false",
"ZITADEL_MIGRATE_ES_V1": "false",
"CR_AUTH_CERT": "test/client.auth.crt",
"ZITADEL_OIDC_KEYS_ID": "",
"CR_MIGRATION_CERT": "test/client.migration.crt",
@ -267,6 +270,7 @@ func TestConfiguration_LiteralsConfigMapFull(t *testing.T) {
"ZITADEL_ISSUER": "https://issuer.domain",
"ZITADEL_KEY_PATH": "test/test",
"ZITADEL_LOG_LEVEL": "debug",
"ZITADEL_MIGRATE_ES_V1": "false",
"ZITADEL_OAUTH": "https://api.domain/oauth/v2",
"ZITADEL_OIDC_KEYS_ID": "oidcid",
"ZITADEL_OTP_VERIFICATION_KEY": "otpid",