2021-01-06 09:47:55 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-01-12 11:59:51 +00:00
|
|
|
"github.com/caos/logging"
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore"
|
2021-01-12 11:59:51 +00:00
|
|
|
|
2021-02-23 14:13:04 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2021-01-06 09:47:55 +00:00
|
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Step6 struct {
|
|
|
|
DefaultLabelPolicy iam_model.LabelPolicy
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Step6) Step() domain.Step {
|
|
|
|
return domain.Step6
|
|
|
|
}
|
|
|
|
|
2021-02-24 10:17:39 +00:00
|
|
|
func (s *Step6) execute(ctx context.Context, commandSide *Commands) error {
|
2021-01-06 09:47:55 +00:00
|
|
|
return commandSide.SetupStep6(ctx, s)
|
|
|
|
}
|
|
|
|
|
2021-02-24 10:17:39 +00:00
|
|
|
func (c *Commands) SetupStep6(ctx context.Context, step *Step6) error {
|
2021-02-18 13:48:27 +00:00
|
|
|
fn := func(iam *IAMWriteModel) ([]eventstore.EventPusher, error) {
|
2021-01-06 09:47:55 +00:00
|
|
|
iamAgg := IAMAggregateFromWriteModel(&iam.WriteModel)
|
2021-02-24 10:17:39 +00:00
|
|
|
event, err := c.addDefaultLabelPolicy(ctx, iamAgg, NewIAMLabelPolicyWriteModel(), &domain.LabelPolicy{
|
2021-01-06 09:47:55 +00:00
|
|
|
PrimaryColor: step.DefaultLabelPolicy.PrimaryColor,
|
|
|
|
SecondaryColor: step.DefaultLabelPolicy.SecondaryColor,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-01-12 11:59:51 +00:00
|
|
|
logging.Log("SETUP-ADgd2").Info("default label policy set up")
|
2021-02-18 13:48:27 +00:00
|
|
|
return []eventstore.EventPusher{event}, nil
|
2021-01-06 09:47:55 +00:00
|
|
|
}
|
2021-02-24 10:17:39 +00:00
|
|
|
return c.setup(ctx, step, fn)
|
2021-01-06 09:47:55 +00:00
|
|
|
}
|