spiff

package
v2.0.0-...-98cc131 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 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:

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) 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)

type Options

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

func (*Options) ApplyTransferOption

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) 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
}

Jump to

Keyboard shortcuts

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