fix: move v2 pkgs (#1331)

* fix: move eventstore pkgs

* fix: move eventstore pkgs

* fix: remove v2 view

* fix: remove v2 view
This commit is contained in:
Fabi
2021-02-23 15:13:04 +01:00
committed by GitHub
parent 57b277bc7c
commit d8e42744b4
797 changed files with 2116 additions and 2224 deletions

View File

@@ -3,17 +3,16 @@ package handler
import (
"context"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/domain"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/models"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/query"
"github.com/caos/zitadel/internal/eventstore/spooler"
"github.com/caos/zitadel/internal/eventstore/v1"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/eventstore/v1/query"
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
"github.com/caos/zitadel/internal/iam/repository/eventsourcing"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
iam_model "github.com/caos/zitadel/internal/iam/repository/view/model"
model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"github.com/caos/zitadel/internal/v2/domain"
)
const (
@@ -22,7 +21,7 @@ const (
type LoginPolicy struct {
handler
subscription *eventstore.Subscription
subscription *v1.Subscription
}
func newLoginPolicy(handler handler) *LoginPolicy {
@@ -48,11 +47,11 @@ func (p *LoginPolicy) ViewModel() string {
return loginPolicyTable
}
func (p *LoginPolicy) AggregateTypes() []models.AggregateType {
return []models.AggregateType{iam_es_model.IAMAggregate, model.OrgAggregate}
func (p *LoginPolicy) AggregateTypes() []es_models.AggregateType {
return []es_models.AggregateType{iam_es_model.IAMAggregate, model.OrgAggregate}
}
func (p *LoginPolicy) EventQuery() (*models.SearchQuery, error) {
func (p *LoginPolicy) EventQuery() (*es_models.SearchQuery, error) {
sequence, err := p.view.GetLatestLoginPolicySequence()
if err != nil {
return nil, err
@@ -70,7 +69,7 @@ func (p *LoginPolicy) CurrentSequence() (uint64, error) {
return sequence.CurrentSequence, nil
}
func (p *LoginPolicy) Reduce(event *models.Event) (err error) {
func (p *LoginPolicy) Reduce(event *es_models.Event) (err error) {
switch event.AggregateType {
case model.OrgAggregate, iam_es_model.IAMAggregate:
err = p.processLoginPolicy(event)
@@ -78,7 +77,7 @@ func (p *LoginPolicy) Reduce(event *models.Event) (err error) {
return err
}
func (p *LoginPolicy) processLoginPolicy(event *models.Event) (err error) {
func (p *LoginPolicy) processLoginPolicy(event *es_models.Event) (err error) {
policy := new(iam_model.LoginPolicyView)
switch event.Type {
case model.OrgAdded:
@@ -132,7 +131,7 @@ func (p *LoginPolicy) processLoginPolicy(event *models.Event) (err error) {
return p.view.PutLoginPolicy(policy, event)
}
func (p *LoginPolicy) OnError(event *models.Event, err error) error {
func (p *LoginPolicy) OnError(event *es_models.Event, err error) error {
logging.LogWithFields("SPOOL-Wj8sf", "id", event.AggregateID).WithError(err).Warn("something went wrong in login policy handler")
return spooler.HandleError(event, err, p.view.GetLatestLoginPolicyFailedEvent, p.view.ProcessedLoginPolicyFailedEvent, p.view.ProcessedLoginPolicySequence, p.errorCountUntilSkip)
}
@@ -162,7 +161,7 @@ func (p *LoginPolicy) getDefaultLoginPolicy() (*iam_model.LoginPolicyView, error
return &policyCopy, nil
}
func (p *LoginPolicy) getIAMEvents(sequence uint64) ([]*models.Event, error) {
func (p *LoginPolicy) getIAMEvents(sequence uint64) ([]*es_models.Event, error) {
query, err := eventsourcing.IAMByIDQuery(domain.IAMID, sequence)
if err != nil {
return nil, err