mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:07:30 +00:00
feat: add action v2 execution on requests and responses (#7637)
* feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: add execution of targets to grpc calls * feat: split request and response logic to handle the different context information * feat: split request and response logic to handle the different context information * fix: integration test * fix: import alias * fix: refactor execution package * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * fix: refactor execution interceptor integration and unit tests * docs: basic documentation for executions and targets * fix: change order for interceptors * fix: merge back origin/main * fix: change target definition command and query side (#7735) * fix: change target definition command and query side * fix: correct refactoring name changes * fix: correct refactoring name changes * fix: changing execution defintion with target list and type * fix: changing execution definition with target list and type * fix: add back search queries for target and include * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * fix: projections change for execution with targets suffix table * docs: add example to actions v2 * docs: add example to actions v2 * fix: correct integration tests on query for executions * fix: add separate event for execution v2 as content changed * fix: add separate event for execution v2 as content changed * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com> * fix: added review comment changes * fix: added review comment changes * Update internal/api/grpc/server/middleware/execution_interceptor.go Co-authored-by: Silvan <silvan.reusser@gmail.com> * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes * fix: added review comment changes --------- Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Elio Bischof <elio@zitadel.com>
This commit is contained in:
@@ -23,7 +23,10 @@ func NewAggregate(aggrID, instanceID string) *eventstore.Aggregate {
|
||||
}
|
||||
|
||||
func ID(executionType domain.ExecutionType, value string) string {
|
||||
return strings.Join([]string{executionType.String(), value}, ".")
|
||||
if strings.HasPrefix(value, "/") {
|
||||
return strings.Join([]string{executionType.String(), value}, "")
|
||||
}
|
||||
return strings.Join([]string{executionType.String(), value}, "/")
|
||||
}
|
||||
|
||||
func IDAll(executionType domain.ExecutionType) string {
|
||||
|
@@ -4,5 +4,6 @@ import "github.com/zitadel/zitadel/internal/eventstore"
|
||||
|
||||
func init() {
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, SetEventType, eventstore.GenericEventMapper[SetEvent])
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, SetEventV2Type, eventstore.GenericEventMapper[SetEventV2])
|
||||
eventstore.RegisterFilterEventMapper(AggregateType, RemovedEventType, eventstore.GenericEventMapper[RemovedEvent])
|
||||
}
|
||||
|
@@ -3,12 +3,14 @@ package execution
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
const (
|
||||
eventTypePrefix eventstore.EventType = "execution."
|
||||
SetEventType = eventTypePrefix + "set"
|
||||
SetEventV2Type = eventTypePrefix + "v2.set"
|
||||
RemovedEventType = eventTypePrefix + "removed"
|
||||
)
|
||||
|
||||
@@ -31,18 +33,39 @@ func (e *SetEvent) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewSetEvent(
|
||||
type SetEventV2 struct {
|
||||
*eventstore.BaseEvent `json:"-"`
|
||||
|
||||
Targets []*Target `json:"targets"`
|
||||
}
|
||||
|
||||
func (e *SetEventV2) SetBaseEvent(b *eventstore.BaseEvent) {
|
||||
e.BaseEvent = b
|
||||
}
|
||||
|
||||
func (e *SetEventV2) Payload() any {
|
||||
return e
|
||||
}
|
||||
|
||||
func (e *SetEventV2) UniqueConstraints() []*eventstore.UniqueConstraint {
|
||||
return nil
|
||||
}
|
||||
|
||||
type Target struct {
|
||||
Type domain.ExecutionTargetType `json:"type"`
|
||||
Target string `json:"target"`
|
||||
}
|
||||
|
||||
func NewSetEventV2(
|
||||
ctx context.Context,
|
||||
aggregate *eventstore.Aggregate,
|
||||
targets []string,
|
||||
includes []string,
|
||||
) *SetEvent {
|
||||
return &SetEvent{
|
||||
targets []*Target,
|
||||
) *SetEventV2 {
|
||||
return &SetEventV2{
|
||||
BaseEvent: eventstore.NewBaseEventForPush(
|
||||
ctx, aggregate, SetEventType,
|
||||
ctx, aggregate, SetEventV2Type,
|
||||
),
|
||||
Targets: targets,
|
||||
Includes: includes,
|
||||
Targets: targets,
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -20,9 +20,8 @@ type AddedEvent struct {
|
||||
|
||||
Name string `json:"name"`
|
||||
TargetType domain.TargetType `json:"targetType"`
|
||||
URL string `json:"url"`
|
||||
Endpoint string `json:"endpoint"`
|
||||
Timeout time.Duration `json:"timeout"`
|
||||
Async bool `json:"async"`
|
||||
InterruptOnError bool `json:"interruptOnError"`
|
||||
}
|
||||
|
||||
@@ -43,16 +42,15 @@ func NewAddedEvent(
|
||||
aggregate *eventstore.Aggregate,
|
||||
name string,
|
||||
targetType domain.TargetType,
|
||||
url string,
|
||||
endpoint string,
|
||||
timeout time.Duration,
|
||||
async bool,
|
||||
interruptOnError bool,
|
||||
) *AddedEvent {
|
||||
return &AddedEvent{
|
||||
*eventstore.NewBaseEventForPush(
|
||||
ctx, aggregate, AddedEventType,
|
||||
),
|
||||
name, targetType, url, timeout, async, interruptOnError}
|
||||
name, targetType, endpoint, timeout, interruptOnError}
|
||||
}
|
||||
|
||||
type ChangedEvent struct {
|
||||
@@ -60,9 +58,8 @@ type ChangedEvent struct {
|
||||
|
||||
Name *string `json:"name,omitempty"`
|
||||
TargetType *domain.TargetType `json:"targetType,omitempty"`
|
||||
URL *string `json:"url,omitempty"`
|
||||
Endpoint *string `json:"endpoint,omitempty"`
|
||||
Timeout *time.Duration `json:"timeout,omitempty"`
|
||||
Async *bool `json:"async,omitempty"`
|
||||
InterruptOnError *bool `json:"interruptOnError,omitempty"`
|
||||
|
||||
oldName string
|
||||
@@ -119,9 +116,9 @@ func ChangeTargetType(targetType domain.TargetType) func(event *ChangedEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeURL(url string) func(event *ChangedEvent) {
|
||||
func ChangeEndpoint(endpoint string) func(event *ChangedEvent) {
|
||||
return func(e *ChangedEvent) {
|
||||
e.URL = &url
|
||||
e.Endpoint = &endpoint
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,12 +128,6 @@ func ChangeTimeout(timeout time.Duration) func(event *ChangedEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeAsync(async bool) func(event *ChangedEvent) {
|
||||
return func(e *ChangedEvent) {
|
||||
e.Async = &async
|
||||
}
|
||||
}
|
||||
|
||||
func ChangeInterruptOnError(interruptOnError bool) func(event *ChangedEvent) {
|
||||
return func(e *ChangedEvent) {
|
||||
e.InterruptOnError = &interruptOnError
|
||||
|
Reference in New Issue
Block a user