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

@@ -2,7 +2,7 @@ package eventstore
import (
"context"
"github.com/caos/zitadel/internal/v2/query"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/internal/iam/model"
)

View File

@@ -2,17 +2,17 @@ package eventstore
import (
"context"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/eventstore/v1"
es_sdk "github.com/caos/zitadel/internal/eventstore/v1/sdk"
iam_model "github.com/caos/zitadel/internal/iam/model"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
iam_view "github.com/caos/zitadel/internal/iam/repository/view"
"github.com/caos/zitadel/internal/v2/domain"
"k8s.io/apimachinery/pkg/api/errors"
"strings"
"time"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
usr_view "github.com/caos/zitadel/internal/user/repository/view"
"github.com/caos/logging"
@@ -28,7 +28,7 @@ import (
type TokenVerifierRepo struct {
TokenVerificationKey [32]byte
IAMID string
Eventstore eventstore.Eventstore
Eventstore v1.Eventstore
View *view.View
}

View File

@@ -2,9 +2,9 @@ package eventstore
import (
"context"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/models"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/zitadel/internal/eventstore/v1/models"
es_sdk "github.com/caos/zitadel/internal/eventstore/v1/sdk"
iam_model "github.com/caos/zitadel/internal/iam/model"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
iam_view "github.com/caos/zitadel/internal/iam/repository/view"
@@ -12,12 +12,12 @@ import (
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/authz/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/domain"
caos_errs "github.com/caos/zitadel/internal/errors"
global_model "github.com/caos/zitadel/internal/model"
user_model "github.com/caos/zitadel/internal/user/model"
user_view_model "github.com/caos/zitadel/internal/user/repository/view/model"
grant_model "github.com/caos/zitadel/internal/usergrant/model"
"github.com/caos/zitadel/internal/v2/domain"
)
type UserGrantRepo struct {
@@ -25,7 +25,7 @@ type UserGrantRepo struct {
IamID string
IamProjectID string
Auth authz.Config
Eventstore eventstore.Eventstore
Eventstore v1.Eventstore
}
func (repo *UserGrantRepo) Health() error {

View File

@@ -2,11 +2,11 @@ package handler
import (
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/zitadel/internal/eventstore"
"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/models"
"github.com/caos/zitadel/internal/eventstore/v1/query"
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
es_model "github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
"github.com/caos/zitadel/internal/project/repository/view"
view_model "github.com/caos/zitadel/internal/project/repository/view/model"
@@ -18,7 +18,7 @@ const (
type Application struct {
handler
subscription *eventstore.Subscription
subscription *v1.Subscription
}
func newApplication(handler handler) *Application {

View File

@@ -1,13 +1,13 @@
package handler
import (
"github.com/caos/zitadel/internal/eventstore/v1"
"time"
"github.com/caos/zitadel/internal/authz/repository/eventsourcing/view"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/config/types"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/query"
"github.com/caos/zitadel/internal/eventstore/v1/query"
)
type Configs map[string]*Config
@@ -22,14 +22,14 @@ type handler struct {
cycleDuration time.Duration
errorCountUntilSkip uint64
es eventstore.Eventstore
es v1.Eventstore
}
func (h *handler) Eventstore() eventstore.Eventstore {
func (h *handler) Eventstore() v1.Eventstore {
return h.es
}
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es eventstore.Eventstore, systemDefaults sd.SystemDefaults) []query.Handler {
func Register(configs Configs, bulkLimit, errorCount uint64, view *view.View, es v1.Eventstore, systemDefaults sd.SystemDefaults) []query.Handler {
return []query.Handler{
newUserGrant(
handler{view, bulkLimit, configs.cycleDuration("UserGrants"), errorCount, es},

View File

@@ -2,12 +2,12 @@ package handler
import (
"github.com/caos/logging"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/zitadel/internal/org/repository/view"
"github.com/caos/zitadel/internal/eventstore"
es_models "github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/query"
"github.com/caos/zitadel/internal/eventstore/spooler"
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/org/repository/eventsourcing/model"
org_model "github.com/caos/zitadel/internal/org/repository/view/model"
)
@@ -18,7 +18,7 @@ const (
type Org struct {
handler
subscription *eventstore.Subscription
subscription *v1.Subscription
}
func newOrg(handler handler) *Org {

View File

@@ -2,25 +2,24 @@ package handler
import (
"context"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
"github.com/caos/zitadel/internal/eventstore/v1"
es_sdk "github.com/caos/zitadel/internal/eventstore/v1/sdk"
iam_model "github.com/caos/zitadel/internal/iam/model"
iam_view "github.com/caos/zitadel/internal/iam/repository/view"
"strings"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/domain"
"github.com/caos/zitadel/internal/errors"
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"
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"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
proj_es_model "github.com/caos/zitadel/internal/project/repository/eventsourcing/model"
view_model "github.com/caos/zitadel/internal/usergrant/repository/view/model"
"github.com/caos/zitadel/internal/v2/domain"
)
const (
@@ -31,7 +30,7 @@ type UserGrant struct {
handler
iamID string
iamProjectID string
subscription *eventstore.Subscription
subscription *v1.Subscription
}
func newUserGrant(
@@ -73,7 +72,7 @@ func (u *UserGrant) CurrentSequence() (uint64, error) {
return sequence.CurrentSequence, nil
}
func (u *UserGrant) EventQuery() (*models.SearchQuery, error) {
func (u *UserGrant) EventQuery() (*es_models.SearchQuery, error) {
if u.iamProjectID == "" {
err := u.setIamProjectID()
if err != nil {
@@ -89,7 +88,7 @@ func (u *UserGrant) EventQuery() (*models.SearchQuery, error) {
LatestSequenceFilter(sequence.CurrentSequence), nil
}
func (u *UserGrant) Reduce(event *models.Event) (err error) {
func (u *UserGrant) Reduce(event *es_models.Event) (err error) {
switch event.AggregateType {
case proj_es_model.ProjectAggregate:
err = u.processProject(event)
@@ -101,7 +100,7 @@ func (u *UserGrant) Reduce(event *models.Event) (err error) {
return err
}
func (u *UserGrant) processProject(event *models.Event) (err error) {
func (u *UserGrant) processProject(event *es_models.Event) (err error) {
switch event.Type {
case proj_es_model.ProjectMemberAdded, proj_es_model.ProjectMemberChanged, proj_es_model.ProjectMemberRemoved:
member := new(proj_es_model.ProjectMember)
@@ -116,7 +115,7 @@ func (u *UserGrant) processProject(event *models.Event) (err error) {
}
}
func (u *UserGrant) processOrg(event *models.Event) (err error) {
func (u *UserGrant) processOrg(event *es_models.Event) (err error) {
switch event.Type {
case org_es_model.OrgMemberAdded, org_es_model.OrgMemberChanged, org_es_model.OrgMemberRemoved:
member := new(org_es_model.OrgMember)
@@ -127,7 +126,7 @@ func (u *UserGrant) processOrg(event *models.Event) (err error) {
}
}
func (u *UserGrant) processIAMMember(event *models.Event, rolePrefix string, suffix bool) error {
func (u *UserGrant) processIAMMember(event *es_models.Event, rolePrefix string, suffix bool) error {
member := new(iam_es_model.IAMMember)
switch event.Type {
@@ -174,7 +173,7 @@ func (u *UserGrant) processIAMMember(event *models.Event, rolePrefix string, suf
}
}
func (u *UserGrant) processMember(event *models.Event, rolePrefix, roleSuffix string, userID string, roleKeys []string) error {
func (u *UserGrant) processMember(event *es_models.Event, rolePrefix, roleSuffix string, userID string, roleKeys []string) error {
switch event.Type {
case org_es_model.OrgMemberAdded, proj_es_model.ProjectMemberAdded, proj_es_model.ProjectGrantMemberAdded,
org_es_model.OrgMemberChanged, proj_es_model.ProjectMemberChanged, proj_es_model.ProjectGrantMemberChanged:
@@ -268,7 +267,7 @@ func (u *UserGrant) setIamProjectID() error {
return nil
}
func (u *UserGrant) OnError(event *models.Event, err error) error {
func (u *UserGrant) OnError(event *es_models.Event, err error) error {
logging.LogWithFields("SPOOL-VcVoJ", "id", event.AggregateID).WithError(err).Warn("something went wrong in user grant handler")
return spooler.HandleError(event, err, u.view.GetLatestUserGrantFailedEvent, u.view.ProcessedUserGrantFailedEvent, u.view.ProcessedUserGrantSequence, u.errorCountUntilSkip)
}
@@ -283,7 +282,7 @@ func (u *UserGrant) getIAMByID(ctx context.Context) (*iam_model.IAM, error) {
return nil, err
}
iam := &iam_es_model.IAM{
ObjectRoot: models.ObjectRoot{
ObjectRoot: es_models.ObjectRoot{
AggregateID: domain.IAMID,
},
}

View File

@@ -2,16 +2,15 @@ package handler
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/logging"
"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"
es_sdk "github.com/caos/zitadel/internal/eventstore/sdk"
"github.com/caos/zitadel/internal/eventstore/spooler"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/eventstore/v1/query"
es_sdk "github.com/caos/zitadel/internal/eventstore/v1/sdk"
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
org_model "github.com/caos/zitadel/internal/org/model"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
@@ -30,7 +29,7 @@ const (
type UserMembership struct {
handler
subscription *eventstore.Subscription
subscription *v1.Subscription
}
func newUserMembership(
@@ -70,7 +69,7 @@ func (m *UserMembership) CurrentSequence() (uint64, error) {
return sequence.CurrentSequence, nil
}
func (m *UserMembership) EventQuery() (*models.SearchQuery, error) {
func (m *UserMembership) EventQuery() (*es_models.SearchQuery, error) {
sequence, err := m.view.GetLatestUserMembershipSequence()
if err != nil {
return nil, err
@@ -80,7 +79,7 @@ func (m *UserMembership) EventQuery() (*models.SearchQuery, error) {
LatestSequenceFilter(sequence.CurrentSequence), nil
}
func (m *UserMembership) Reduce(event *models.Event) (err error) {
func (m *UserMembership) Reduce(event *es_models.Event) (err error) {
switch event.AggregateType {
case iam_es_model.IAMAggregate:
err = m.processIAM(event)
@@ -94,7 +93,7 @@ func (m *UserMembership) Reduce(event *models.Event) (err error) {
return err
}
func (m *UserMembership) processIAM(event *models.Event) (err error) {
func (m *UserMembership) processIAM(event *es_models.Event) (err error) {
member := new(usr_es_model.UserMembershipView)
err = member.AppendEvent(event)
if err != nil {
@@ -125,7 +124,7 @@ func (m *UserMembership) fillIamDisplayName(member *usr_es_model.UserMembershipV
member.ResourceOwnerName = member.ResourceOwner
}
func (m *UserMembership) processOrg(event *models.Event) (err error) {
func (m *UserMembership) processOrg(event *es_models.Event) (err error) {
member := new(usr_es_model.UserMembershipView)
err = member.AppendEvent(event)
if err != nil {
@@ -165,7 +164,7 @@ func (m *UserMembership) fillOrgName(member *usr_es_model.UserMembershipView) (e
return nil
}
func (m *UserMembership) updateOrgName(event *models.Event) error {
func (m *UserMembership) updateOrgName(event *es_models.Event) error {
org, err := m.getOrgByID(context.Background(), event.AggregateID)
if err != nil {
return err
@@ -184,7 +183,7 @@ func (m *UserMembership) updateOrgName(event *models.Event) error {
return m.view.BulkPutUserMemberships(memberships, event)
}
func (m *UserMembership) processProject(event *models.Event) (err error) {
func (m *UserMembership) processProject(event *es_models.Event) (err error) {
member := new(usr_es_model.UserMembershipView)
err = member.AppendEvent(event)
if err != nil {
@@ -237,7 +236,7 @@ func (m *UserMembership) fillProjectDisplayName(member *usr_es_model.UserMembers
return nil
}
func (m *UserMembership) updateProjectDisplayName(event *models.Event) error {
func (m *UserMembership) updateProjectDisplayName(event *es_models.Event) error {
project, err := m.getProjectByID(context.Background(), event.AggregateID)
if err != nil {
return err
@@ -253,7 +252,7 @@ func (m *UserMembership) updateProjectDisplayName(event *models.Event) error {
return m.view.BulkPutUserMemberships(memberships, event)
}
func (m *UserMembership) processUser(event *models.Event) (err error) {
func (m *UserMembership) processUser(event *es_models.Event) (err error) {
switch event.Type {
case model.UserRemoved:
return m.view.DeleteUserMembershipsByUserID(event.AggregateID, event)
@@ -262,7 +261,7 @@ func (m *UserMembership) processUser(event *models.Event) (err error) {
}
}
func (m *UserMembership) OnError(event *models.Event, err error) error {
func (m *UserMembership) OnError(event *es_models.Event, err error) error {
logging.LogWithFields("SPOOL-Ms3fj", "id", event.AggregateID).WithError(err).Warn("something went wrong in user membership handler")
return spooler.HandleError(event, err, m.view.GetLatestUserMembershipFailedEvent, m.view.ProcessedUserMembershipFailedEvent, m.view.ProcessedUserMembershipSequence, m.errorCountUntilSkip)
}
@@ -295,7 +294,7 @@ func (u *UserMembership) getProjectByID(ctx context.Context, projID string) (*pr
return nil, err
}
esProject := &proj_es_model.Project{
ObjectRoot: models.ObjectRoot{
ObjectRoot: es_models.ObjectRoot{
AggregateID: projID,
},
}

View File

@@ -2,8 +2,9 @@ package eventsourcing
import (
"context"
"github.com/caos/zitadel/internal/eventstore/v1"
"github.com/caos/zitadel/internal/v2/query"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/internal/api/authz"
"github.com/caos/zitadel/internal/auth_request/repository/cache"
@@ -12,14 +13,13 @@ import (
authz_view "github.com/caos/zitadel/internal/authz/repository/eventsourcing/view"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/config/types"
es_int "github.com/caos/zitadel/internal/eventstore"
es_spol "github.com/caos/zitadel/internal/eventstore/spooler"
es_spol "github.com/caos/zitadel/internal/eventstore/v1/spooler"
"github.com/caos/zitadel/internal/id"
)
type Config struct {
Domain string
Eventstore es_int.Config
Eventstore v1.Config
AuthRequest cache.Config
View types.SQL
Spooler spooler.SpoolerConfig
@@ -33,7 +33,7 @@ type EsRepository struct {
}
func Start(conf Config, authZ authz.Config, systemDefaults sd.SystemDefaults) (*EsRepository, error) {
es, err := es_int.Start(conf.Eventstore)
es, err := v1.Start(conf.Eventstore)
if err != nil {
return nil, err
}

View File

@@ -2,7 +2,7 @@ package spooler
import (
"database/sql"
es_locker "github.com/caos/zitadel/internal/eventstore/locker"
es_locker "github.com/caos/zitadel/internal/eventstore/v1/locker"
"time"
)

View File

@@ -2,14 +2,14 @@ package spooler
import (
"database/sql"
"github.com/caos/zitadel/internal/eventstore/v1"
sd "github.com/caos/zitadel/internal/config/systemdefaults"
"github.com/caos/zitadel/internal/authz/repository/eventsourcing/handler"
"github.com/caos/zitadel/internal/authz/repository/eventsourcing/view"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/spooler"
"github.com/caos/zitadel/internal/eventstore/v1/spooler"
)
type SpoolerConfig struct {
@@ -19,7 +19,7 @@ type SpoolerConfig struct {
Handlers handler.Configs
}
func StartSpooler(c SpoolerConfig, es eventstore.Eventstore, view *view.View, sql *sql.DB, systemDefaults sd.SystemDefaults) *spooler.Spooler {
func StartSpooler(c SpoolerConfig, es v1.Eventstore, view *view.View, sql *sql.DB, systemDefaults sd.SystemDefaults) *spooler.Spooler {
spoolerConfig := spooler.Config{
Eventstore: es,
Locker: &locker{dbClient: sql},

View File

@@ -4,7 +4,7 @@ import (
"context"
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/project/repository/view"
"github.com/caos/zitadel/internal/project/repository/view/model"

View File

@@ -1,7 +1,7 @@
package view
import (
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/org/model"
org_view "github.com/caos/zitadel/internal/org/repository/view"
org_model "github.com/caos/zitadel/internal/org/repository/view/model"

View File

@@ -3,7 +3,7 @@ package view
import (
"time"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/view/repository"
)

View File

@@ -2,7 +2,7 @@ package view
import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
usr_view "github.com/caos/zitadel/internal/user/repository/view"
usr_view_model "github.com/caos/zitadel/internal/user/repository/view/model"
"github.com/caos/zitadel/internal/view/repository"

View File

@@ -2,7 +2,7 @@ package view
import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
grant_model "github.com/caos/zitadel/internal/usergrant/model"
"github.com/caos/zitadel/internal/usergrant/repository/view"
"github.com/caos/zitadel/internal/usergrant/repository/view/model"

View File

@@ -2,7 +2,7 @@ package view
import (
"github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/models"
"github.com/caos/zitadel/internal/eventstore/v1/models"
usr_model "github.com/caos/zitadel/internal/user/model"
"github.com/caos/zitadel/internal/user/repository/view"
"github.com/caos/zitadel/internal/user/repository/view/model"