mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 02:54:20 +00:00
fix(setup): unmarshal of failed step (#7144)
This commit is contained in:
parent
aa2d642e97
commit
41215bdc0a
@ -2,7 +2,6 @@ package migration
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/service"
|
||||
@ -15,25 +14,10 @@ type SetupStep struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
migration Migration
|
||||
Name string `json:"name"`
|
||||
Error error `json:"error,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
LastRun interface{} `json:"lastRun,omitempty"`
|
||||
}
|
||||
|
||||
func (s *SetupStep) UnmarshalJSON(data []byte) error {
|
||||
fields := struct {
|
||||
Name string `json:"name,"`
|
||||
Error *zerrors.ZitadelError `json:"error"`
|
||||
LastRun map[string]interface{} `json:"lastRun,omitempty"`
|
||||
}{}
|
||||
if err := json.Unmarshal(data, &fields); err != nil {
|
||||
return err
|
||||
}
|
||||
s.Name = fields.Name
|
||||
s.Error = fields.Error
|
||||
s.LastRun = fields.LastRun
|
||||
return nil
|
||||
}
|
||||
|
||||
func setupStartedCmd(ctx context.Context, migration Migration) eventstore.Command {
|
||||
ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"})
|
||||
return &SetupStep{
|
||||
@ -54,16 +38,16 @@ func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstor
|
||||
typ = repeatableDoneType
|
||||
lastRun = repeatable
|
||||
}
|
||||
if err != nil {
|
||||
typ = failedType
|
||||
}
|
||||
|
||||
s := &SetupStep{
|
||||
migration: migration,
|
||||
Name: migration.String(),
|
||||
Error: err,
|
||||
LastRun: lastRun,
|
||||
}
|
||||
if err != nil {
|
||||
typ = failedType
|
||||
s.Error = err.Error()
|
||||
}
|
||||
|
||||
s.BaseEvent = *eventstore.NewBaseEventForPush(
|
||||
ctx,
|
||||
|
Loading…
Reference in New Issue
Block a user