mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
667cc30291
* feat: remove assets * feat: minio implementation * fix: remove assets from tests * feat: minio implementation * feat: Env vars * fix: sprintf * fix: sprintf * Update internal/eventstore/repository/repository.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: error handling Co-authored-by: Livio Amstutz <livio.a@gmail.com>
56 lines
1.1 KiB
Go
56 lines
1.1 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 (
|
|
GlobalOrgSetEventType eventstore.EventType = "iam.global.org.set"
|
|
)
|
|
|
|
type GlobalOrgSetEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
OrgID string `json:"globalOrgId"`
|
|
}
|
|
|
|
func (e *GlobalOrgSetEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func (e *GlobalOrgSetEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint {
|
|
return nil
|
|
}
|
|
|
|
func NewGlobalOrgSetEventEvent(
|
|
ctx context.Context,
|
|
aggregate *eventstore.Aggregate,
|
|
orgID string,
|
|
) *GlobalOrgSetEvent {
|
|
return &GlobalOrgSetEvent{
|
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
|
ctx,
|
|
aggregate,
|
|
GlobalOrgSetEventType,
|
|
),
|
|
OrgID: orgID,
|
|
}
|
|
}
|
|
|
|
func GlobalOrgSetMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &GlobalOrgSetEvent{
|
|
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
|
|
}
|