mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-18 13:57:32 +00:00
f51f0ede5c
* fix: add assets to eventstore and event * fix: project member, grant member, app changed tests * fix: asset migrations * feat: add asset tests * feat: add asset tests * Update internal/eventstore/repository/repository.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * feat: add asset tests Co-authored-by: Livio Amstutz <livio.a@gmail.com>
60 lines
1.2 KiB
Go
60 lines
1.2 KiB
Go
package iam
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/repository"
|
|
)
|
|
|
|
const (
|
|
ProjectSetEventType eventstore.EventType = "iam.project.iam.set"
|
|
)
|
|
|
|
type ProjectSetEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
ProjectID string `json:"iamProjectId"`
|
|
}
|
|
|
|
func (e *ProjectSetEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *ProjectSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func (e *ProjectSetEvent) Assets() []*eventstore.Asset {
|
|
return nil
|
|
}
|
|
|
|
func NewIAMProjectSetEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
projectID string,
|
|
) *ProjectSetEvent {
|
|
return &ProjectSetEvent{
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
ProjectSetEventType,
|
|
),
|
|
ProjectID: projectID,
|
|
}
|
|
}
|
|
|
|
func ProjectSetMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &ProjectSetEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "IAM-cdFZH", "unable to unmarshal global org set")
|
|
}
|
|
|
|
return e, nil
|
|
}
|