spiff

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

README

Spiff-based Transfer Handler

This package provides a TransferHandler programmable using the Spiff Templating Engine. The spiff template get a flat binding mode describing the operation mode and it must provide a top-level node process containing the processing result.

The following modes are used:

Update Mode

This mode is used to decide on the update option for a component version. This controls whether an update on volatile (non-signature relevant) information should be done. It gets the following bindings:

  • mode <string>: update
  • values <map>:
    • component <map>: the meta dats of the component version carrying the resource
      • name <string>: component name
      • version <string>: component version
      • provider <provider>: provider info, a struct with the field s
        • name <string>: provider name
        • labels <map[string]any>: provider attributes
      • labels <map[string]>: labels of the component version (deep)
    • target <map>: the respository specification of the target resource

The result value (field process) must be a boolean describing whether the update should be possible.

Enforce Transport Mode

This mode is used to decide on the enforced transport option for a component version. This controls whether transport is carried out as if the component version were not present at the destination. It gets the following bindings:

  • mode <string>: enforceTransport
  • values <map>:
    • component <map>: the meta dats of the component version carrying the resource
      • name <string>: component name
      • version <string>: component version
      • provider <provider>: provider info, a struct with the field s
        • name <string>: provider name
        • labels <map[string]any>: provider attributes
      • labels <map[string]>: labels of the component version (deep)
    • target <map>: the respository specification of the target resource

The result value (field process) must be a boolean describing whether the update should be possible.

Overwrite Mode

This mode is used to decide on the overwrite option for a component version. This controls whether an update on non-volatile (signature relevant) information should be done. It gets the following bindings:

  • mode <string>: overwrite
  • values <map>:
    • component <map>: the meta dats of the component version carrying the resource
      • name <string>: component name
      • version <string>: component version
      • provider <provider>: provider info, a struct with the field s
        • name <string>: provider name
        • labels <map[string]any>: provider attributes
      • labels <map[string]>: labels of the component version (deep)
    • target <map>: the respository specification of the target resource

The result value (field process) must be a boolean describing whether the update should be possible.

Resource Mode

This mode is used to decide on the by-value option for a resource. It gets the following bindings:

  • mode <string>: resource
  • values <map>:
    • component <map>: the meta dats of the component version carrying the resource
      • name <string>: component name
      • version <string>: component version
      • provider <provider>: provider info, a struct with the field s
        • name <string>: provider name
        • labels <map[string]any>: provider attributes
      • labels <map[string]>: labels of the component version (deep)
    • element <map>: the meta data of the resource and the field type containing the element type.
    • access <map>: the access specification of the resource
    • target <map>: the respository specification of the target resource

The result value (field process) must be a boolean describing whether the resource should be transported ny-value.

Source Mode

This mode is used to decide on the by-value option for a source. It gets the following bindings:

The result value (field process) must be a boolean describing whether the resource should be transported ny-value.

Component Version Mode

This mode is used to decide on the recursion option for a referenced component version. It gets the following bindings:

  • mode <string>: componentversion
  • values <map>: (see Resource Mode)
    • component <map> (optional): the meta dats of the component version carrying the reference
      • name <string>: component name
      • version <string>: component version
      • provider <string>: provider name
      • labels <map[string]>: labels of the component version (deep)
    • element <map>: the meta data of the component reference

The result value (field process) can either be a simple boolean value or a map with the following fields:

  • process <bool>: true indicates to follow the reference
  • repospec <map> (optional): the specification of the repository to use to follow the reference
  • script <template> (optional): the script to use instead of the current one.

If no new repository spec is given, the actual repository is used. If no new script is given, the actual one is used for sub sequent processing.

the component field is optional, for top level requests during the transport of a set of component versions, there is no hosting component.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Script

func Script(data []byte) transferhandler.TransferOption

func ScriptByFile

func ScriptByFile(path string, fss ...vfs.FileSystem) transferhandler.TransferOption

Types

type Handler

type Handler struct {
	standard.Handler
	// contains filtered or unexported fields
}

func (*Handler) EnforceTransport added in v0.7.0

func (h *Handler) EnforceTransport(src ocm.ComponentVersionAccess, tgt ocm.ComponentVersionAccess) (bool, error)

func (*Handler) Eval

func (h *Handler) Eval(binding map[string]interface{}) (spiffing.Node, error)

func (*Handler) EvalBool

func (h *Handler) EvalBool(mode string, binding map[string]interface{}, key string) (bool, error)

func (*Handler) EvalRecursion

func (h *Handler) EvalRecursion(mode string, binding map[string]interface{}, key string) (bool, []byte, []byte, error)

func (*Handler) OverwriteVersion

func (h *Handler) OverwriteVersion(src ocm.ComponentVersionAccess, tgt ocm.ComponentVersionAccess) (bool, error)

func (*Handler) TransferResource

func (h *Handler) TransferResource(src ocm.ComponentVersionAccess, a ocm.AccessSpec, r ocm.ResourceAccess) (bool, error)

func (*Handler) TransferSource

func (h *Handler) TransferSource(src ocm.ComponentVersionAccess, a ocm.AccessSpec, r ocm.SourceAccess) (bool, error)

func (*Handler) UpdateVersion added in v0.4.1

func (h *Handler) UpdateVersion(src ocm.ComponentVersionAccess, tgt ocm.ComponentVersionAccess) (bool, error)

type Options

type Options struct {
	standard.Options
	// contains filtered or unexported fields
}

func (*Options) ApplyTransferOption added in v0.3.0

func (o *Options) ApplyTransferOption(target transferhandler.TransferOptions) error

func (*Options) GetScript

func (o *Options) GetScript() []byte

func (*Options) GetScriptFilesystem

func (o *Options) GetScriptFilesystem() vfs.FileSystem

func (*Options) NewOptions added in v0.4.0

func (*Options) NewTransferHandler added in v0.4.0

func (o *Options) NewTransferHandler() (transferhandler.TransferHandler, error)

func (*Options) SetScript

func (o *Options) SetScript(data []byte)

func (*Options) SetScriptFilesystem

func (o *Options) SetScriptFilesystem(fs vfs.FileSystem)

type ScriptFilesystemOption

type ScriptFilesystemOption interface {
	SetScriptFilesystem(fs vfs.FileSystem)
	GetScriptFilesystem() vfs.FileSystem
}

type ScriptOption

type ScriptOption interface {
	SetScript(data []byte)
	GetScript() []byte
}

type TransferOptionsCreator added in v0.4.0

type TransferOptionsCreator = transferhandler.SpecializedOptionsCreator[*Options, Options]

Jump to

Keyboard shortcuts

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