hook

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 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) ent.Hook

FixedError is a hook returning a fixed error.

func If

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

If executes the given hook under condition.

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

func On

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

On executes the given hook only for the given operation.

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

func Reject

func Reject(op ent.Op) ent.Hook

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

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

func Unless

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

Unless skips the given hook only for the given operation.

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

Types

type ArtifactFunc

type ArtifactFunc func(context.Context, *ent.ArtifactMutation) (ent.Value, error)

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

func (ArtifactFunc) Mutate

func (f ArtifactFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type BillOfMaterialsFunc

type BillOfMaterialsFunc func(context.Context, *ent.BillOfMaterialsMutation) (ent.Value, error)

The BillOfMaterialsFunc type is an adapter to allow the use of ordinary function as BillOfMaterials mutator.

func (BillOfMaterialsFunc) Mutate

Mutate calls f(ctx, m).

type BuilderFunc

type BuilderFunc func(context.Context, *ent.BuilderMutation) (ent.Value, error)

The BuilderFunc type is an adapter to allow the use of ordinary function as Builder mutator.

func (BuilderFunc) Mutate

func (f BuilderFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type CertificationFunc

type CertificationFunc func(context.Context, *ent.CertificationMutation) (ent.Value, error)

The CertificationFunc type is an adapter to allow the use of ordinary function as Certification mutator.

func (CertificationFunc) Mutate

Mutate calls f(ctx, m).

type CertifyLegalFunc

type CertifyLegalFunc func(context.Context, *ent.CertifyLegalMutation) (ent.Value, error)

The CertifyLegalFunc type is an adapter to allow the use of ordinary function as CertifyLegal mutator.

func (CertifyLegalFunc) Mutate

func (f CertifyLegalFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type CertifyScorecardFunc

type CertifyScorecardFunc func(context.Context, *ent.CertifyScorecardMutation) (ent.Value, error)

The CertifyScorecardFunc type is an adapter to allow the use of ordinary function as CertifyScorecard mutator.

func (CertifyScorecardFunc) Mutate

Mutate calls f(ctx, m).

type CertifyVexFunc

type CertifyVexFunc func(context.Context, *ent.CertifyVexMutation) (ent.Value, error)

The CertifyVexFunc type is an adapter to allow the use of ordinary function as CertifyVex mutator.

func (CertifyVexFunc) Mutate

func (f CertifyVexFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type CertifyVulnFunc

type CertifyVulnFunc func(context.Context, *ent.CertifyVulnMutation) (ent.Value, error)

The CertifyVulnFunc type is an adapter to allow the use of ordinary function as CertifyVuln mutator.

func (CertifyVulnFunc) Mutate

func (f CertifyVulnFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.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 ...ent.Hook) Chain

NewChain creates a new chain of hooks.

func (Chain) Append

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

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

type Condition

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

type DependencyFunc func(context.Context, *ent.DependencyMutation) (ent.Value, error)

The DependencyFunc type is an adapter to allow the use of ordinary function as Dependency mutator.

func (DependencyFunc) Mutate

func (f DependencyFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type HasMetadataFunc added in v0.2.1

type HasMetadataFunc func(context.Context, *ent.HasMetadataMutation) (ent.Value, error)

The HasMetadataFunc type is an adapter to allow the use of ordinary function as HasMetadata mutator.

func (HasMetadataFunc) Mutate added in v0.2.1

func (f HasMetadataFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type HasSourceAtFunc

type HasSourceAtFunc func(context.Context, *ent.HasSourceAtMutation) (ent.Value, error)

The HasSourceAtFunc type is an adapter to allow the use of ordinary function as HasSourceAt mutator.

func (HasSourceAtFunc) Mutate

func (f HasSourceAtFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type HashEqualFunc

type HashEqualFunc func(context.Context, *ent.HashEqualMutation) (ent.Value, error)

The HashEqualFunc type is an adapter to allow the use of ordinary function as HashEqual mutator.

func (HashEqualFunc) Mutate

func (f HashEqualFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type LicenseFunc

type LicenseFunc func(context.Context, *ent.LicenseMutation) (ent.Value, error)

The LicenseFunc type is an adapter to allow the use of ordinary function as License mutator.

func (LicenseFunc) Mutate

func (f LicenseFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type OccurrenceFunc

type OccurrenceFunc func(context.Context, *ent.OccurrenceMutation) (ent.Value, error)

The OccurrenceFunc type is an adapter to allow the use of ordinary function as Occurrence mutator.

func (OccurrenceFunc) Mutate

func (f OccurrenceFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type PackageNameFunc

type PackageNameFunc func(context.Context, *ent.PackageNameMutation) (ent.Value, error)

The PackageNameFunc type is an adapter to allow the use of ordinary function as PackageName mutator.

func (PackageNameFunc) Mutate

func (f PackageNameFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type PackageVersionFunc

type PackageVersionFunc func(context.Context, *ent.PackageVersionMutation) (ent.Value, error)

The PackageVersionFunc type is an adapter to allow the use of ordinary function as PackageVersion mutator.

func (PackageVersionFunc) Mutate

Mutate calls f(ctx, m).

type PkgEqualFunc

type PkgEqualFunc func(context.Context, *ent.PkgEqualMutation) (ent.Value, error)

The PkgEqualFunc type is an adapter to allow the use of ordinary function as PkgEqual mutator.

func (PkgEqualFunc) Mutate

func (f PkgEqualFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type PointOfContactFunc added in v0.2.1

type PointOfContactFunc func(context.Context, *ent.PointOfContactMutation) (ent.Value, error)

The PointOfContactFunc type is an adapter to allow the use of ordinary function as PointOfContact mutator.

func (PointOfContactFunc) Mutate added in v0.2.1

Mutate calls f(ctx, m).

type SLSAAttestationFunc

type SLSAAttestationFunc func(context.Context, *ent.SLSAAttestationMutation) (ent.Value, error)

The SLSAAttestationFunc type is an adapter to allow the use of ordinary function as SLSAAttestation mutator.

func (SLSAAttestationFunc) Mutate

Mutate calls f(ctx, m).

type SourceNameFunc

type SourceNameFunc func(context.Context, *ent.SourceNameMutation) (ent.Value, error)

The SourceNameFunc type is an adapter to allow the use of ordinary function as SourceName mutator.

func (SourceNameFunc) Mutate

func (f SourceNameFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type VulnEqualFunc

type VulnEqualFunc func(context.Context, *ent.VulnEqualMutation) (ent.Value, error)

The VulnEqualFunc type is an adapter to allow the use of ordinary function as VulnEqual mutator.

func (VulnEqualFunc) Mutate

func (f VulnEqualFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error)

Mutate calls f(ctx, m).

type VulnerabilityIDFunc

type VulnerabilityIDFunc func(context.Context, *ent.VulnerabilityIDMutation) (ent.Value, error)

The VulnerabilityIDFunc type is an adapter to allow the use of ordinary function as VulnerabilityID mutator.

func (VulnerabilityIDFunc) Mutate

Mutate calls f(ctx, m).

type VulnerabilityMetadataFunc added in v0.4.0

type VulnerabilityMetadataFunc func(context.Context, *ent.VulnerabilityMetadataMutation) (ent.Value, error)

The VulnerabilityMetadataFunc type is an adapter to allow the use of ordinary function as VulnerabilityMetadata mutator.

func (VulnerabilityMetadataFunc) 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