hook

package
v0.6.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FixedError

func FixedError(err error) model.Hook

FixedError is a hook returning a fixed error.

func If

func If(hk model.Hook, cond Condition) model.Hook

If executes the given hook under condition.

hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))

func On

func On(hk model.Hook, op model.Op) model.Hook

On executes the given hook only for the given operation.

hook.On(Log, model.Delete|model.Create)

func Reject

func Reject(op model.Op) model.Hook

Reject returns a hook that rejects all operations that match op.

func (T) Hooks() []model.Hook {
	return []model.Hook{
		Reject(model.Delete|model.Update),
	}
}

func Unless

func Unless(hk model.Hook, op model.Op) model.Hook

Unless skips the given hook only for the given operation.

hook.Unless(Log, model.Update|model.UpdateOne)

Types

type CatalogFunc

type CatalogFunc func(context.Context, *model.CatalogMutation) (model.Value, error)

The CatalogFunc type is an adapter to allow the use of ordinary function as Catalog mutator.

func (CatalogFunc) Mutate

func (f CatalogFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type Chain

type Chain struct {
	// contains filtered or unexported fields
}

Chain acts as a list of hooks and is effectively immutable. Once created, it will always hold the same set of hooks in the same order.

func NewChain

func NewChain(hooks ...model.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...model.Hook) Chain

Append extends a chain, adding the specified hook as the last ones in the mutation flow.

func (Chain) Extend

func (c Chain) Extend(chain Chain) Chain

Extend extends a chain, adding the specified chain as the last ones in the mutation flow.

func (Chain) Hook

func (c Chain) Hook() model.Hook

Hook chains the list of hooks and returns the final hook.

type Condition

type Condition func(context.Context, model.Mutation) bool

Condition is a hook condition function.

func And

func And(first, second Condition, rest ...Condition) Condition

And groups conditions with the AND operator.

func HasAddedFields

func HasAddedFields(field string, fields ...string) Condition

HasAddedFields is a condition validating `.AddedField` on fields.

func HasClearedFields

func HasClearedFields(field string, fields ...string) Condition

HasClearedFields is a condition validating `.FieldCleared` on fields.

func HasFields

func HasFields(field string, fields ...string) Condition

HasFields is a condition validating `.Field` on fields.

func HasOp

func HasOp(op model.Op) Condition

HasOp is a condition testing mutation operation.

func Not

func Not(cond Condition) Condition

Not negates a given condition.

func Or

func Or(first, second Condition, rest ...Condition) Condition

Or groups conditions with the OR operator.

type ConnectorFunc

type ConnectorFunc func(context.Context, *model.ConnectorMutation) (model.Value, error)

The ConnectorFunc type is an adapter to allow the use of ordinary function as Connector mutator.

func (ConnectorFunc) Mutate

Mutate calls f(ctx, m).

type CostReportFunc

type CostReportFunc func(context.Context, *model.CostReportMutation) (model.Value, error)

The CostReportFunc type is an adapter to allow the use of ordinary function as CostReport mutator.

func (CostReportFunc) Mutate

Mutate calls f(ctx, m).

type DistributeLockFunc

type DistributeLockFunc func(context.Context, *model.DistributeLockMutation) (model.Value, error)

The DistributeLockFunc type is an adapter to allow the use of ordinary function as DistributeLock mutator.

func (DistributeLockFunc) Mutate

Mutate calls f(ctx, m).

type EnvironmentConnectorRelationshipFunc

type EnvironmentConnectorRelationshipFunc func(context.Context, *model.EnvironmentConnectorRelationshipMutation) (model.Value, error)

The EnvironmentConnectorRelationshipFunc type is an adapter to allow the use of ordinary function as EnvironmentConnectorRelationship mutator.

func (EnvironmentConnectorRelationshipFunc) Mutate

Mutate calls f(ctx, m).

type EnvironmentFunc

type EnvironmentFunc func(context.Context, *model.EnvironmentMutation) (model.Value, error)

The EnvironmentFunc type is an adapter to allow the use of ordinary function as Environment mutator.

func (EnvironmentFunc) Mutate

Mutate calls f(ctx, m).

type PerspectiveFunc

type PerspectiveFunc func(context.Context, *model.PerspectiveMutation) (model.Value, error)

The PerspectiveFunc type is an adapter to allow the use of ordinary function as Perspective mutator.

func (PerspectiveFunc) Mutate

Mutate calls f(ctx, m).

type ProjectFunc

type ProjectFunc func(context.Context, *model.ProjectMutation) (model.Value, error)

The ProjectFunc type is an adapter to allow the use of ordinary function as Project mutator.

func (ProjectFunc) Mutate

func (f ProjectFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type ResourceComponentFunc added in v0.4.0

type ResourceComponentFunc func(context.Context, *model.ResourceComponentMutation) (model.Value, error)

The ResourceComponentFunc type is an adapter to allow the use of ordinary function as ResourceComponent mutator.

func (ResourceComponentFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type ResourceComponentRelationshipFunc added in v0.4.0

type ResourceComponentRelationshipFunc func(context.Context, *model.ResourceComponentRelationshipMutation) (model.Value, error)

The ResourceComponentRelationshipFunc type is an adapter to allow the use of ordinary function as ResourceComponentRelationship mutator.

func (ResourceComponentRelationshipFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type ResourceDefinitionFunc added in v0.4.0

type ResourceDefinitionFunc func(context.Context, *model.ResourceDefinitionMutation) (model.Value, error)

The ResourceDefinitionFunc type is an adapter to allow the use of ordinary function as ResourceDefinition mutator.

func (ResourceDefinitionFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type ResourceDefinitionMatchingRuleFunc added in v0.4.0

type ResourceDefinitionMatchingRuleFunc func(context.Context, *model.ResourceDefinitionMatchingRuleMutation) (model.Value, error)

The ResourceDefinitionMatchingRuleFunc type is an adapter to allow the use of ordinary function as ResourceDefinitionMatchingRule mutator.

func (ResourceDefinitionMatchingRuleFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type ResourceFunc added in v0.4.0

type ResourceFunc func(context.Context, *model.ResourceMutation) (model.Value, error)

The ResourceFunc type is an adapter to allow the use of ordinary function as Resource mutator.

func (ResourceFunc) Mutate added in v0.4.0

func (f ResourceFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type ResourceRelationshipFunc added in v0.4.0

type ResourceRelationshipFunc func(context.Context, *model.ResourceRelationshipMutation) (model.Value, error)

The ResourceRelationshipFunc type is an adapter to allow the use of ordinary function as ResourceRelationship mutator.

func (ResourceRelationshipFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type ResourceRunFunc added in v0.6.0

type ResourceRunFunc func(context.Context, *model.ResourceRunMutation) (model.Value, error)

The ResourceRunFunc type is an adapter to allow the use of ordinary function as ResourceRun mutator.

func (ResourceRunFunc) Mutate added in v0.6.0

Mutate calls f(ctx, m).

type ResourceStateFunc added in v0.6.0

type ResourceStateFunc func(context.Context, *model.ResourceStateMutation) (model.Value, error)

The ResourceStateFunc type is an adapter to allow the use of ordinary function as ResourceState mutator.

func (ResourceStateFunc) Mutate added in v0.6.0

Mutate calls f(ctx, m).

type RoleFunc

type RoleFunc func(context.Context, *model.RoleMutation) (model.Value, error)

The RoleFunc type is an adapter to allow the use of ordinary function as Role mutator.

func (RoleFunc) Mutate

func (f RoleFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type SettingFunc

type SettingFunc func(context.Context, *model.SettingMutation) (model.Value, error)

The SettingFunc type is an adapter to allow the use of ordinary function as Setting mutator.

func (SettingFunc) Mutate

func (f SettingFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type SubjectFunc

type SubjectFunc func(context.Context, *model.SubjectMutation) (model.Value, error)

The SubjectFunc type is an adapter to allow the use of ordinary function as Subject mutator.

func (SubjectFunc) Mutate

func (f SubjectFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type SubjectRoleRelationshipFunc

type SubjectRoleRelationshipFunc func(context.Context, *model.SubjectRoleRelationshipMutation) (model.Value, error)

The SubjectRoleRelationshipFunc type is an adapter to allow the use of ordinary function as SubjectRoleRelationship mutator.

func (SubjectRoleRelationshipFunc) Mutate

Mutate calls f(ctx, m).

type TemplateFunc

type TemplateFunc func(context.Context, *model.TemplateMutation) (model.Value, error)

The TemplateFunc type is an adapter to allow the use of ordinary function as Template mutator.

func (TemplateFunc) Mutate

func (f TemplateFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type TemplateVersionFunc

type TemplateVersionFunc func(context.Context, *model.TemplateVersionMutation) (model.Value, error)

The TemplateVersionFunc type is an adapter to allow the use of ordinary function as TemplateVersion mutator.

func (TemplateVersionFunc) Mutate

Mutate calls f(ctx, m).

type TokenFunc

type TokenFunc func(context.Context, *model.TokenMutation) (model.Value, error)

The TokenFunc type is an adapter to allow the use of ordinary function as Token mutator.

func (TokenFunc) Mutate

func (f TokenFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type VariableFunc

type VariableFunc func(context.Context, *model.VariableMutation) (model.Value, error)

The VariableFunc type is an adapter to allow the use of ordinary function as Variable mutator.

func (VariableFunc) Mutate

func (f VariableFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type WorkflowExecutionFunc added in v0.4.0

type WorkflowExecutionFunc func(context.Context, *model.WorkflowExecutionMutation) (model.Value, error)

The WorkflowExecutionFunc type is an adapter to allow the use of ordinary function as WorkflowExecution mutator.

func (WorkflowExecutionFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type WorkflowFunc added in v0.4.0

type WorkflowFunc func(context.Context, *model.WorkflowMutation) (model.Value, error)

The WorkflowFunc type is an adapter to allow the use of ordinary function as Workflow mutator.

func (WorkflowFunc) Mutate added in v0.4.0

func (f WorkflowFunc) Mutate(ctx context.Context, m model.Mutation) (model.Value, error)

Mutate calls f(ctx, m).

type WorkflowStageExecutionFunc added in v0.4.0

type WorkflowStageExecutionFunc func(context.Context, *model.WorkflowStageExecutionMutation) (model.Value, error)

The WorkflowStageExecutionFunc type is an adapter to allow the use of ordinary function as WorkflowStageExecution mutator.

func (WorkflowStageExecutionFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type WorkflowStageFunc added in v0.4.0

type WorkflowStageFunc func(context.Context, *model.WorkflowStageMutation) (model.Value, error)

The WorkflowStageFunc type is an adapter to allow the use of ordinary function as WorkflowStage mutator.

func (WorkflowStageFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type WorkflowStepExecutionFunc added in v0.4.0

type WorkflowStepExecutionFunc func(context.Context, *model.WorkflowStepExecutionMutation) (model.Value, error)

The WorkflowStepExecutionFunc type is an adapter to allow the use of ordinary function as WorkflowStepExecution mutator.

func (WorkflowStepExecutionFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

type WorkflowStepFunc added in v0.4.0

type WorkflowStepFunc func(context.Context, *model.WorkflowStepMutation) (model.Value, error)

The WorkflowStepFunc type is an adapter to allow the use of ordinary function as WorkflowStep mutator.

func (WorkflowStepFunc) Mutate added in v0.4.0

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL