mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-25 18:55:27 -06:00
* fix: rename iam command side to instance * fix: rename iam command side to instance * fix: rename iam command side to instance * fix: rename iam command side to instance * fix: rename orgiampolicy to domain policy * fix: merge conflicts * fix: protos * fix: md files * implement deprecated org iam policy again Co-authored-by: Livio Amstutz <livio.a@gmail.com>
43 lines
1.0 KiB
Go
43 lines
1.0 KiB
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.GetInstance(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.Instance{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
|
|
}
|