wfapi

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ECodeArgument may be used when invalid arguments are provided to the warpforge command line
	ECodeArgument = "warpforge-error-invalid-argument"
	// ECodeAlreadyExists may be used when _something_ already exists.
	// Prefer to use a more specific error code or specify _what_ is missing.
	ECodeAlreadyExists          = "warpforge-error-already-exists"
	ECodeCatalogInvalid         = "warpforge-error-catalog-invalid"
	ECodeCatalogMissingEntry    = "warpforge-error-catalog-missing-entry"
	ECodeCatalogName            = "warpforge-error-catalog-name"
	ECodeCatalogParse           = "warpforge-error-catalog-parse"
	ECodeDataTooNew             = "warpforge-error-datatoonew"
	ECodeExecutorFailed         = "warpforge-error-executor-failed"
	ECodeFormulaExecutionFailed = "warpforge-error-formula-execution-failed"
	ECodeFormulaInvalid         = "warpforge-error-formula-invalid"
	ECodeGeneratorFailed        = "warpforge-error-generator-failed"
	ECodeGit                    = "warpforge-error-git"
	// ECodeInternal is used for errors that are internal and cannot be handled by users.
	// Try to pick something more specific.
	ECodeInternal = "warpforge-error-internal"
	// ECodeInvalid is used when something is invalid.
	// Prefer to choose a more specific error code.
	ECodeInvalid             = "warpforge-error-invalid"
	ECodeIo                  = "warpforge-error-io"
	ECodeMissing             = "warpforge-error-missing"
	ECodeModuleInvalid       = "warpforge-error-module-invalid"
	ECodePlotExecution       = "warpforge-error-plot-execution-failed"
	ECodePlotInvalid         = "warpforge-error-plot-invalid"
	ECodePlotStepFailed      = "warpforge-error-plot-step-failed"
	ECodeSearchingFilesystem = "warpforge-error-searching-filesystem"
	ECodeSerialization       = "warpforge-error-serialization"
	ECodeSyscall             = "warpforge-error-syscall"
	// ECodeUnknown is used for unknown errors. Avoid whenever possible.
	ECodeUnknown       = "warpforge-error-unknown"
	ECodeWareIdInvalid = "warpforge-error-wareid-invalid"
	ECodeWarePack      = "warpforge-error-ware-pack"
	ECodeWareUnpack    = "warpforge-error-ware-unpack"
	ECodeWorkspace     = "warpforge-error-workspace"
)

TODO: Add comments for reasons to use or not use particular codes

Variables

View Source
var TypeSystem = func() *schema.TypeSystem {
	schReader, err := schFs.Open("wfapi.ipldsch")
	if err != nil {
		panic(fmt.Sprintf("failed to open embedded wfapi.ipldsch: %s", err))
	}
	ts, err := ipld.LoadSchema("warpforge", schReader)
	if err != nil {
		panic(fmt.Sprintf("failed to parse api schema: %s", err))
	}
	return ts
}()

Functions

func ErrorCatalogInvalid

func ErrorCatalogInvalid(path string, reason string) error

ErrorCatalogInvalid is returned when a catalog contains invalid data

Errors:

  • warpforge-error-catalog-invalid --

func ErrorCatalogItemAlreadyExists

func ErrorCatalogItemAlreadyExists(path string, itemName ItemLabel) error

ErrorCatalogItemAlreadyExists is returned when trying to add an item that already exists

Errors:

  • warpforge-error-already-exists --

func ErrorCatalogName

func ErrorCatalogName(name string, reason string) error

ErrorCatalogName is returned when a catalog name is invalid

Errors:

  • warpforge-error-catalog-name --

func ErrorCatalogParse

func ErrorCatalogParse(path string, cause error) error

ErrorCatalogParse is returned when parsing of a catalog file fails

Errors:

  • warpforge-error-catalog-parse --

func ErrorDataTooNew

func ErrorDataTooNew(context string, cause error) error

ErrorDataTooNew is returned when some data was (partially) deserialized, but only enough that we could recognize it as being a newer version of message than this application supports.

Errors:

  • warpforge-error-datatoonew -- if some data is too new to parse completely.

func ErrorExecutorFailed

func ErrorExecutorFailed(executorEngineName string, cause error) error

ErrorExecutorFailed is returned when a container executor (e.g., runc) returns an error.

Errors:

  • warpforge-error-executor-failed --

func ErrorFileAlreadyExists

func ErrorFileAlreadyExists(path string) error

ErrorFileAlreadyExists is used when a file already exists

Errors:

  • warpforge-error-already-exists --

func ErrorFileMissing

func ErrorFileMissing(path string) error

ErrorFileMissing is used when an expected file does not exist

Errors:

  • warpforge-error-missing --

func ErrorFormulaExecutionFailed

func ErrorFormulaExecutionFailed(cause error) error

ErrorFormulaExecutionFailed is returned to wrap generic errors that cause formula execution to fail.

Errors:

  • warpforge-error-formula-execution-failed --

func ErrorFormulaInvalid

func ErrorFormulaInvalid(reason string) error

ErrorFormulaInvalid is returned when a formula contains invalid data

Errors:

  • warpforge-error-formula-invalid --

func ErrorGeneratorFailed

func ErrorGeneratorFailed(generatorName string, inputFile string, details string) error

ErrorGeneratorFailed is returned when an external generator fails

Errors:

  • warpforge-error-generator-failed --

func ErrorGit

func ErrorGit(context string, cause error) error

ErrorGit is returned when a go-git error occurs

Errors:

  • warpforge-error-git --

func ErrorIo

func ErrorIo(context string, path string, cause error) error

ErrorIo wraps generic I/O errors from the Go stdlib

Errors:

  • warpforge-error-io --

func ErrorMissingCatalogEntry

func ErrorMissingCatalogEntry(ref CatalogRef, replayAvailable bool) error

ErrorMissingCatalogEntry is returned when a catalog entry cannot be found

Errors:

  • warpforge-error-catalog-missing-entry --

func ErrorModuleInvalid

func ErrorModuleInvalid(reason string) error

ErrorModuleInvalid is returned when a module contains invalid data

Errors:

  • warpforge-error-module-invalid --

func ErrorPlotExecutionFailed

func ErrorPlotExecutionFailed(cause error) error

ErrorPlotExecutionFailed is used to wrap errors around plot execution Errors:

  • warpforge-error-plot-execution-failed --

func ErrorPlotInvalid

func ErrorPlotInvalid(reason string) error

ErrorPlotInvalid is returned when a plot contains invalid data

Errors:

  • warpforge-error-plot-invalid --

func ErrorPlotStepFailed

func ErrorPlotStepFailed(stepName StepName, cause error) error

ErrorPlotStepFailed is returned execution of a Step within a Plot fails

Errors:

  • warpforge-error-plot-step-failed --

func ErrorSearchingFilesystem

func ErrorSearchingFilesystem(searchingFor string, cause error) error

ErrorSearchingFilesystem is returned when an error occurs during search

Errors:

  • warpforge-error-searching-filesystem --

func ErrorSerialization

func ErrorSerialization(context string, cause error) error

ErrorSerialization is returned when a serialization or deserialization error occurs

Errors:

  • warpforge-error-serialization --

func ErrorSyscall

func ErrorSyscall(fmtPattern string, args ...interface{}) error

ErrorSyscall is used to wrap errors from the syscall package

Errors:

  • warpforge-error-syscall --

func ErrorWareIdInvalid

func ErrorWareIdInvalid(wareId WareID) error

ErrorWareIdInvalid is returned when a malformed WareID is parsed

Errors:

  • warpforge-error-wareid-invalid --

func ErrorWarePack

func ErrorWarePack(path string, cause error) error

ErrorWarePack is returned when the packing of a ware fails

Errors:

  • warpforge-error-ware-pack --

func ErrorWareUnpack

func ErrorWareUnpack(wareId WareID, cause error) error

ErrorWareUnpack is returned when the unpacking of a ware fails

Errors:

  • warpforge-error-ware-unpack --

func ErrorWorkspace

func ErrorWorkspace(wsPath string, cause error) error

ErrorWorkspace is returned when an error occurs when handling a workspace

Errors:

  • warpforge-error-workspace --

func IsCode

func IsCode(err error, code string) bool

IsCode reports whether any error in err's chain matches the given code string.

The chain consists of err itself followed by the sequence of errors obtained by repeatedly calling serum.Cause which is similar to calling Unwrap.

An error is considered to match the code string if the result of serum.Code(err) is equal to the code string.

func TerminalError

func TerminalError(err serum.ErrorInterface, exitCode int)

TerminalError emits an error on stdout as json, and halts immediately. In most cases, you should not use this method, and there will be a better place to send errors that will be more guaranteed to fit any protocols and scripts better; however, this is sometimes used in init methods (where we know no other protocol yet).

Types

type Action

type Action struct {
	Echo   *Action_Echo
	Exec   *Action_Exec
	Script *Action_Script
}

Action is a union (aka sum type). Exactly one of its fields will be set.

type Action_Echo

type Action_Echo struct {
}

type Action_Exec

type Action_Exec struct {
	Command []string
	Network *bool
}

type Action_Script

type Action_Script struct {
	Interpreter string
	Contents    []string
	Network     *bool
}

type ApiOutput

type ApiOutput struct {
	Output      *string
	Log         *LogOutput
	RunRecord   *RunRecord
	PlotResults *PlotResults
}

type Catalog

type Catalog struct {
	Keys   []ModuleName
	Values map[ModuleName]CatalogModule
}

type CatalogLineage

type CatalogLineage struct {
	Name     string
	Metadata struct {
		Keys   []string
		Values map[string]string
	}
	Releases []CatalogRelease
}

type CatalogMirrors

type CatalogMirrors struct {
	ByWare   *CatalogMirrorsByWare
	ByModule *CatalogMirrorsByModule
}

type CatalogMirrorsByModule

type CatalogMirrorsByModule struct {
	Keys   []ModuleName
	Values map[ModuleName]CatalogMirrorsByPacktype
}

type CatalogMirrorsByPacktype

type CatalogMirrorsByPacktype struct {
	Keys   []Packtype
	Values map[Packtype][]WarehouseAddr
}

type CatalogMirrorsByWare

type CatalogMirrorsByWare struct {
	Keys   []WareID
	Values map[WareID][]WarehouseAddr
}

type CatalogMirrorsCapsule

type CatalogMirrorsCapsule struct {
	CatalogMirrors *CatalogMirrors
}

type CatalogModule

type CatalogModule struct {
	Name     ModuleName
	Releases struct {
		Keys   []ReleaseName
		Values map[ReleaseName]CatalogReleaseCID
	}
	Metadata struct {
		Keys   []string
		Values map[string]string
	}
}

type CatalogModuleCapsule

type CatalogModuleCapsule struct {
	CatalogModule *CatalogModule
}

type CatalogRef

type CatalogRef struct {
	ModuleName  ModuleName
	ReleaseName ReleaseName
	ItemName    ItemLabel
}

func (*CatalogRef) String

func (c *CatalogRef) String() string

type CatalogRelease

type CatalogRelease struct {
	ReleaseName ReleaseName
	Items       struct {
		Keys   []ItemLabel
		Values map[ItemLabel]WareID
	}
	Metadata struct {
		Keys   []string
		Values map[string]string
	}
}

func (*CatalogRelease) Cid

func (rel *CatalogRelease) Cid() CatalogReleaseCID

type CatalogReleaseCID

type CatalogReleaseCID string

type FilterMap

type FilterMap struct {
	Keys   []string
	Values map[string]string
}

Placeholder type. May need better definition.

type Formula

type Formula struct {
	Inputs struct {
		Keys   []SandboxPort
		Values map[SandboxPort]FormulaInput
	}
	Action  Action
	Outputs struct {
		Keys   []OutputName
		Values map[OutputName]GatherDirective
	}
}

type FormulaAndContext

type FormulaAndContext struct {
	Formula FormulaCapsule
	Context *FormulaContextCapsule
}

type FormulaCapsule

type FormulaCapsule struct {
	Formula *Formula
}

type FormulaContext

type FormulaContext struct {
	Warehouses struct {
		Keys   []WareID
		Values map[WareID]WarehouseAddr
	}
}

type FormulaContextCapsule

type FormulaContextCapsule struct {
	FormulaContext *FormulaContext
}

type FormulaExecConfig

type FormulaExecConfig struct {
	Interactive        bool
	DisableMemoization bool
}

type FormulaInput

type FormulaInput struct {
	FormulaInputSimple  *FormulaInputSimple
	FormulaInputComplex *FormulaInputComplex
}

func (*FormulaInput) Basis

func (fi *FormulaInput) Basis() *FormulaInputSimple

type FormulaInputComplex

type FormulaInputComplex struct {
	Basis   FormulaInputSimple
	Filters FilterMap
}

type FormulaInputSimple

type FormulaInputSimple struct {
	WareID  *WareID
	Mount   *Mount
	Literal *Literal
}

type GatherDirective

type GatherDirective struct {
	From     SandboxPort
	Packtype *Packtype  // 'optional': should be absent iff SandboxPort is a SandboxVar.
	Filters  *FilterMap // 'optional': must be absent if SandboxPort is a SandboxVar.
}

type GitIngest

type GitIngest struct {
	HostPath string
	Ref      string
}

type Ingest

type Ingest struct {
	GitIngest *GitIngest
}

type ItemLabel

type ItemLabel string

type Literal

type Literal string

type LocalLabel

type LocalLabel string

LocalLabel is for referencing data within a Plot. Input data gets assigned a LocalLabel; Pipes pull info from a LocalLabel (possibly together with a StepName to scope it); when a Step is evaluated (e.g. turned into a Formula, executed, and produces results), the results will become identifiable by a LocalLabel (scoped by the StepName).

(LocalLabel and OutputName are essentially the same thing: an OutputName gets casted to being considered a LocalLabel when a Formula's results are hoisted into the Plot.)

Must not contain ':' charaters or unprintables or whitespace.

type LogOutput

type LogOutput struct {
	Msg string
}

type Module

type Module struct {
	// name might go here?  other config?  unsure honestly, mostly leaving space for future expansion.
	Name ModuleName
}

type ModuleCapsule

type ModuleCapsule struct {
	Module *Module
}

type ModuleName

type ModuleName string

type Mount

type Mount struct {
	Mode     MountMode
	HostPath string
}

type MountMode

type MountMode string
const (
	MountMode_Readonly  MountMode = "readonly"
	MountMode_Readwrite MountMode = "readwrite"
	MountMode_Overlay   MountMode = "overlay"
)

type OutputName

type OutputName string

type Packtype

type Packtype string

type Pipe

type Pipe struct {
	StepName StepName
	Label    LocalLabel
}

type Plot

type Plot struct {
	Inputs struct {
		Keys   []LocalLabel
		Values map[LocalLabel]PlotInput
	}
	Steps struct {
		Keys   []StepName
		Values map[StepName]Step
	}
	Outputs struct {
		Keys   []LocalLabel
		Values map[LocalLabel]PlotOutput
	}
}

func (*Plot) Cid

func (plot *Plot) Cid() PlotCID

type PlotCID

type PlotCID string

type PlotCapsule

type PlotCapsule struct {
	Plot *Plot
}

type PlotExecConfig

type PlotExecConfig struct {
	Recursive         bool
	FormulaExecConfig FormulaExecConfig
}

type PlotInput

type PlotInput struct {
	PlotInputSimple  *PlotInputSimple
	PlotInputComplex *PlotInputComplex
}

func (*PlotInput) Basis

func (pi *PlotInput) Basis() *PlotInputSimple

type PlotInputComplex

type PlotInputComplex struct {
	Basis   PlotInputSimple
	Filters FilterMap
}

type PlotInputSimple

type PlotInputSimple struct {
	WareID     *WareID
	Mount      *Mount
	Literal    *Literal
	Pipe       *Pipe
	CatalogRef *CatalogRef
	Ingest     *Ingest
}

type PlotOutput

type PlotOutput struct {
	Pipe *Pipe
}

type PlotResults

type PlotResults struct {
	Keys   []LocalLabel
	Values map[LocalLabel]WareID
}

type Protoformula

type Protoformula struct {
	Inputs struct {
		Keys   []SandboxPort
		Values map[SandboxPort]PlotInput
	}
	Action  Action
	Outputs struct {
		Keys   []LocalLabel
		Values map[LocalLabel]GatherDirective
	}
}

type ReleaseName

type ReleaseName string

type ReplayCapsule

type ReplayCapsule struct {
	Plot *Plot
}

type RunRecord

type RunRecord struct {
	Guid      string
	Time      int64
	FormulaID string
	Exitcode  int
	Results   struct {
		Keys   []OutputName
		Values map[OutputName]FormulaInputSimple
	}
}

type SandboxPath

type SandboxPath string

type SandboxPort

type SandboxPort struct {
	// FIXME: although golang has permitted us to use this as a map key... we shouldn't; it's trouble.
	// The pointers here mean that constructing an equal value is nearly possible, which is unintended and unpleasant to use.
	// Fixing this may require some work upstream in go-ipld-prime's bindnode package:
	// in order to stop using pointers here, it will need to support integer indicators instead.
	SandboxPath *SandboxPath
	SandboxVar  *SandboxVar
}

type SandboxVar

type SandboxVar string

type Step

type Step struct {
	Plot         *Plot
	Protoformula *Protoformula
}

type StepName

type StepName string

StepName is for assigning string names to Steps in a Plot. StepNames will be part of wiring things together using Pipes.

Must not contain ':' charaters or unprintables or whitespace.

type WareID

type WareID struct {
	Packtype Packtype // f.eks. "tar", "git"
	Hash     string   // what it says on the tin.
}

func (WareID) String

func (w WareID) String() string

type WarehouseAddr

type WarehouseAddr string

WarehouseAddr is typically parsed as roughly a URL, but we don't deal with that at the API type level.

Jump to

Keyboard shortcuts

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