mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +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 (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/internal/api/authz"
|
"github.com/zitadel/zitadel/internal/api/authz"
|
||||||
"github.com/zitadel/zitadel/internal/api/service"
|
"github.com/zitadel/zitadel/internal/api/service"
|
||||||
@ -15,25 +14,10 @@ type SetupStep struct {
|
|||||||
eventstore.BaseEvent `json:"-"`
|
eventstore.BaseEvent `json:"-"`
|
||||||
migration Migration
|
migration Migration
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Error error `json:"error,omitempty"`
|
Error string `json:"error,omitempty"`
|
||||||
LastRun interface{} `json:"lastRun,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 {
|
func setupStartedCmd(ctx context.Context, migration Migration) eventstore.Command {
|
||||||
ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"})
|
ctx = authz.SetCtxData(service.WithService(ctx, "system"), authz.CtxData{UserID: "system", OrgID: "SYSTEM", ResourceOwner: "SYSTEM"})
|
||||||
return &SetupStep{
|
return &SetupStep{
|
||||||
@ -54,16 +38,16 @@ func setupDoneCmd(ctx context.Context, migration Migration, err error) eventstor
|
|||||||
typ = repeatableDoneType
|
typ = repeatableDoneType
|
||||||
lastRun = repeatable
|
lastRun = repeatable
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
typ = failedType
|
|
||||||
}
|
|
||||||
|
|
||||||
s := &SetupStep{
|
s := &SetupStep{
|
||||||
migration: migration,
|
migration: migration,
|
||||||
Name: migration.String(),
|
Name: migration.String(),
|
||||||
Error: err,
|
|
||||||
LastRun: lastRun,
|
LastRun: lastRun,
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
typ = failedType
|
||||||
|
s.Error = err.Error()
|
||||||
|
}
|
||||||
|
|
||||||
s.BaseEvent = *eventstore.NewBaseEventForPush(
|
s.BaseEvent = *eventstore.NewBaseEventForPush(
|
||||||
ctx,
|
ctx,
|
||||||
|
Loading…
Reference in New Issue
Block a user