fix: update config to commands (and queries) (#1342)

* fix: adaot config to commands (and queries)

* remove dependency on vv2 in v1

* add queries user to operator

* set password for queries on tests

* set password for queries on tests

* fix config
This commit is contained in:
Livio Amstutz
2021-02-24 11:17:39 +01:00
committed by GitHub
parent 438daebdb9
commit 8dcbbc87ca
101 changed files with 1122 additions and 1078 deletions

View File

@@ -2,6 +2,8 @@ package query
import (
"context"
"github.com/caos/zitadel/internal/config/types"
"github.com/caos/zitadel/internal/eventstore"
usr_repo "github.com/caos/zitadel/internal/repository/user"
@@ -13,7 +15,7 @@ import (
"github.com/caos/zitadel/internal/telemetry/tracing"
)
type QuerySide struct {
type Queries struct {
iamID string
eventstore *eventstore.Eventstore
idGenerator id.Generator
@@ -21,27 +23,26 @@ type QuerySide struct {
}
type Config struct {
Eventstore *eventstore.Eventstore
SystemDefaults sd.SystemDefaults
Eventstore types.SQLUser
}
func StartQuerySide(config *Config) (repo *QuerySide, err error) {
repo = &QuerySide{
iamID: config.SystemDefaults.IamID,
eventstore: config.Eventstore,
func StartQueries(eventstore *eventstore.Eventstore, defaults sd.SystemDefaults) (repo *Queries, err error) {
repo = &Queries{
iamID: defaults.IamID,
eventstore: eventstore,
idGenerator: id.SonyFlakeGenerator,
}
iam_repo.RegisterEventMappers(repo.eventstore)
usr_repo.RegisterEventMappers(repo.eventstore)
repo.secretCrypto, err = crypto.NewAESCrypto(config.SystemDefaults.IDPConfigVerificationKey)
repo.secretCrypto, err = crypto.NewAESCrypto(defaults.IDPConfigVerificationKey)
if err != nil {
return nil, err
}
return repo, nil
}
func (r *QuerySide) IAMByID(ctx context.Context, id string) (_ *iam_model.IAM, err error) {
func (r *Queries) IAMByID(ctx context.Context, id string) (_ *iam_model.IAM, err error) {
readModel, err := r.iamByID(ctx, id)
if err != nil {
return nil, err
@@ -50,7 +51,7 @@ func (r *QuerySide) IAMByID(ctx context.Context, id string) (_ *iam_model.IAM, e
return readModelToIAM(readModel), nil
}
func (r *QuerySide) iamByID(ctx context.Context, id string) (_ *ReadModel, err error) {
func (r *Queries) iamByID(ctx context.Context, id string) (_ *ReadModel, err error) {
ctx, span := tracing.NewSpan(ctx)
defer func() { span.EndWithError(err) }()