mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-15 10:25:11 +00:00
feat: setup (#1166)
* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <[email protected]> * check project state Co-authored-by: Fabi <[email protected]>
This commit is contained in:
@@ -3,15 +3,41 @@ package command
|
||||
import (
|
||||
"context"
|
||||
|
||||
caos_errs "github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/v2/domain"
|
||||
"github.com/caos/zitadel/internal/v2/repository/iam"
|
||||
)
|
||||
|
||||
//TODO: private
|
||||
func (r *CommandSide) GetIAM(ctx context.Context, aggregateID string) (*domain.IAM, error) {
|
||||
iamWriteModel := NewIAMWriteModel(aggregateID)
|
||||
func (r *CommandSide) GetIAM(ctx context.Context) (*domain.IAM, error) {
|
||||
iamWriteModel := NewIAMWriteModel()
|
||||
err := r.eventstore.FilterToQueryReducer(ctx, iamWriteModel)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return writeModelToIAM(iamWriteModel), nil
|
||||
}
|
||||
|
||||
func (r *CommandSide) setGlobalOrg(ctx context.Context, iamAgg *iam.Aggregate, iamWriteModel *IAMWriteModel, orgID string) error {
|
||||
err := r.eventstore.FilterToQueryReducer(ctx, iamWriteModel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if iamWriteModel.GlobalOrgID != "" {
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "IAM-HGG24", "Errors.IAM.GlobalOrgAlreadySet")
|
||||
}
|
||||
iamAgg.PushEvents(iam.NewGlobalOrgSetEventEvent(ctx, orgID))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *CommandSide) setIAMProject(ctx context.Context, iamAgg *iam.Aggregate, iamWriteModel *IAMWriteModel, projectID string) error {
|
||||
err := r.eventstore.FilterToQueryReducer(ctx, iamWriteModel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if iamWriteModel.ProjectID != "" {
|
||||
return caos_errs.ThrowPreconditionFailed(nil, "IAM-EGbw2", "Errors.IAM.IAMProjectAlreadySet")
|
||||
}
|
||||
iamAgg.PushEvents(iam.NewIAMProjectSetEvent(ctx, projectID))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user