hook

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 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) generated.Hook

FixedError is a hook returning a fixed error.

func If

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

If executes the given hook under condition.

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

func On

On executes the given hook only for the given operation.

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

func Reject

func Reject(op generated.Op) generated.Hook

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

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

func Unless

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

Unless skips the given hook only for the given operation.

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

Types

type ApplicationDependencyFunc

type ApplicationDependencyFunc func(context.Context, *generated.ApplicationDependencyMutation) (generated.Value, error)

The ApplicationDependencyFunc type is an adapter to allow the use of ordinary function as ApplicationDependency mutator.

func (ApplicationDependencyFunc) Mutate

Mutate calls f(ctx, m).

type ApplicationFunc

The ApplicationFunc type is an adapter to allow the use of ordinary function as Application mutator.

func (ApplicationFunc) Mutate

Mutate calls f(ctx, m).

type ApplicationNamespaceFunc

type ApplicationNamespaceFunc func(context.Context, *generated.ApplicationNamespaceMutation) (generated.Value, error)

The ApplicationNamespaceFunc type is an adapter to allow the use of ordinary function as ApplicationNamespace mutator.

func (ApplicationNamespaceFunc) Mutate

Mutate calls f(ctx, m).

type ArtifactFunc

The ArtifactFunc type is an adapter to allow the use of ordinary function as Artifact mutator.

func (ArtifactFunc) Mutate

Mutate calls f(ctx, m).

type ArtifactReferenceFunc

type ArtifactReferenceFunc func(context.Context, *generated.ArtifactReferenceMutation) (generated.Value, error)

The ArtifactReferenceFunc type is an adapter to allow the use of ordinary function as ArtifactReference mutator.

func (ArtifactReferenceFunc) Mutate

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 ...generated.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

func (c Chain) Append(hooks ...generated.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() generated.Hook

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

type CommonMixinFunc

The CommonMixinFunc type is an adapter to allow the use of ordinary function as CommonMixin mutator.

func (CommonMixinFunc) Mutate

Mutate calls f(ctx, m).

type Condition

type Condition func(context.Context, generated.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 generated.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 DeploymentPackageFunc

type DeploymentPackageFunc func(context.Context, *generated.DeploymentPackageMutation) (generated.Value, error)

The DeploymentPackageFunc type is an adapter to allow the use of ordinary function as DeploymentPackage mutator.

func (DeploymentPackageFunc) Mutate

Mutate calls f(ctx, m).

type DeploymentProfileFunc

type DeploymentProfileFunc func(context.Context, *generated.DeploymentProfileMutation) (generated.Value, error)

The DeploymentProfileFunc type is an adapter to allow the use of ordinary function as DeploymentProfile mutator.

func (DeploymentProfileFunc) Mutate

Mutate calls f(ctx, m).

type DeploymentRequirementFunc

type DeploymentRequirementFunc func(context.Context, *generated.DeploymentRequirementMutation) (generated.Value, error)

The DeploymentRequirementFunc type is an adapter to allow the use of ordinary function as DeploymentRequirement mutator.

func (DeploymentRequirementFunc) Mutate

Mutate calls f(ctx, m).

type EndpointFunc

The EndpointFunc type is an adapter to allow the use of ordinary function as Endpoint mutator.

func (EndpointFunc) Mutate

Mutate calls f(ctx, m).

type ExtensionFunc

The ExtensionFunc type is an adapter to allow the use of ordinary function as Extension mutator.

func (ExtensionFunc) Mutate

Mutate calls f(ctx, m).

type IgnoredResourceFunc

type IgnoredResourceFunc func(context.Context, *generated.IgnoredResourceMutation) (generated.Value, error)

The IgnoredResourceFunc type is an adapter to allow the use of ordinary function as IgnoredResource mutator.

func (IgnoredResourceFunc) Mutate

Mutate calls f(ctx, m).

type NamespaceAdornmentFunc

type NamespaceAdornmentFunc func(context.Context, *generated.NamespaceAdornmentMutation) (generated.Value, error)

The NamespaceAdornmentFunc type is an adapter to allow the use of ordinary function as NamespaceAdornment mutator.

func (NamespaceAdornmentFunc) Mutate

Mutate calls f(ctx, m).

type NamespaceFunc

The NamespaceFunc type is an adapter to allow the use of ordinary function as Namespace mutator.

func (NamespaceFunc) Mutate

Mutate calls f(ctx, m).

type ParameterTemplateFunc

type ParameterTemplateFunc func(context.Context, *generated.ParameterTemplateMutation) (generated.Value, error)

The ParameterTemplateFunc type is an adapter to allow the use of ordinary function as ParameterTemplate mutator.

func (ParameterTemplateFunc) Mutate

Mutate calls f(ctx, m).

type ProfileFunc

The ProfileFunc type is an adapter to allow the use of ordinary function as Profile mutator.

func (ProfileFunc) Mutate

Mutate calls f(ctx, m).

type RegistryFunc

The RegistryFunc type is an adapter to allow the use of ordinary function as Registry mutator.

func (RegistryFunc) Mutate

Mutate calls f(ctx, m).

Jump to

Keyboard shortcuts

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