Files
zitadel/internal/setup/setup.go
Livio Amstutz 8dcbbc87ca fix: update config to commands (and queries) (#1342)
* fix: adaot config to commands (and queries)

* remove dependency on vv2 in v1

* add queries user to operator

* set password for queries on tests

* set password for queries on tests

* fix config
2021-02-24 11:17:39 +01:00

48 lines
1.1 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"
)
const (
OrgOwnerRole = "ORG_OWNER"
SetupUser = "SETUP"
)
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
}