mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
3c07a186fc
* fix: pub sub in new eventstore * fix: todos * fix: todos * fix: todos * fix: todos * fix: todos
43 lines
1017 B
Go
43 lines
1017 B
Go
package setup
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/logging"
|
|
|
|
"github.com/caos/zitadel/internal/command"
|
|
"github.com/caos/zitadel/internal/domain"
|
|
caos_errs "github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
)
|
|
|
|
func Execute(ctx context.Context, setUpConfig IAMSetUp, iamID string, commands *command.Commands) error {
|
|
logging.Log("SETUP-JAK2q").Info("starting setup")
|
|
|
|
iam, err := commands.GetIAM(ctx)
|
|
if err != nil && !caos_errs.IsNotFound(err) {
|
|
return err
|
|
}
|
|
if iam != nil && (iam.SetUpDone == domain.StepCount-1 || iam.SetUpStarted != iam.SetUpDone) {
|
|
logging.Log("SETUP-VA2k1").Info("all steps done")
|
|
return nil
|
|
}
|
|
|
|
if iam == nil {
|
|
iam = &domain.IAM{ObjectRoot: models.ObjectRoot{AggregateID: iamID}}
|
|
}
|
|
|
|
steps, err := setUpConfig.Steps(iam.SetUpDone)
|
|
if err != nil || len(steps) == 0 {
|
|
return err
|
|
}
|
|
|
|
err = commands.ExecuteSetupSteps(ctx, steps)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
logging.Log("SETUP-ds31h").Info("setup done")
|
|
return nil
|
|
}
|