util

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: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPlotJson = `` /* 1049-byte string literal not displayed */
View Source
const FerkPlotTemplate = `` /* 1060-byte string literal not displayed */
View Source
const Module = "github.com/warptools/warpforge"

The module name used for unique strings, such as tracing identifiers Grab it via `go list -m` or manually. It's not available at runtime and it's too trivial to generate. Might inject with LDFLAGS later.

Variables

This section is empty.

Functions

func BinPath

func BinPath(bin string) (string, error)

BinPath is a helper function for finding the path to internally used binaries (e.g, rio, runc)

Errors:

  • warpforge-error-io -- When the path to this executable can't be found

func CancelOnInterrupt

func CancelOnInterrupt(cancel context.CancelFunc)

CancelOnInterrupt blocks until a os.Interrupt is received, then calls cancel.

func ChainCmdMiddleware

func ChainCmdMiddleware(cmd cli.ActionFunc, middlewares ...func(cli.ActionFunc) cli.ActionFunc) cli.ActionFunc

ChainCmdMiddleware returns a cli ActionFunc that is wrapped by the given middleware. Middleware is executed in order. E.G. `middleware[0](middleware[1](cmd))`

func CmdMiddlewareCancelOnInterrupt

func CmdMiddlewareCancelOnInterrupt(f cli.ActionFunc) cli.ActionFunc

CmdMiddlewareCancelOnInterrupt will cause the function context to be canceled on receiving an os.Interrupt signal

func CmdMiddlewareLogging

func CmdMiddlewareLogging(f cli.ActionFunc) cli.ActionFunc

CmdMiddlewareLogging configures the logging system before executing the CLI command

func CmdMiddlewareTracingConfig

func CmdMiddlewareTracingConfig(f cli.ActionFunc) cli.ActionFunc

CmdMiddlewareTracingConfig configures the tracing system before executing the CLI command

func CmdMiddlewareTracingSpan

func CmdMiddlewareTracingSpan(f cli.ActionFunc) cli.ActionFunc

CmdMiddlewareTracingSpan starts a span with the command name that ends when the middleware exits after returning from the command or next middleware

func ExecModule

func ExecModule(ctx context.Context, config wfapi.PlotExecConfig, fileName string) (wfapi.PlotResults, error)

ExecModule executes the given module file with the default plot file in the same directory. WARNING: This function calls Chdir and may not change back on errors

Errors:

  • warpforge-error-catalog-invalid --
  • warpforge-error-catalog-parse --
  • warpforge-error-git --
  • warpforge-error-io -- when the module or plot files cannot be read or cannot change directory.
  • warpforge-error-catalog-missing-entry --
  • warpforge-error-module-invalid -- when the module data is invalid
  • warpforge-error-plot-execution-failed --
  • warpforge-error-plot-invalid -- when the plot data is invalid
  • warpforge-error-plot-step-failed --
  • warpforge-error-serialization -- when the module or plot cannot be parsed
  • warpforge-error-unknown -- when changing directories fails
  • warpforge-error-workspace -- when opening the workspace set fails
  • warpforge-error-datatoonew -- when module or plot data version is unrecognized

func GenerateDir

func GenerateDir(path string) (map[string][]byte, error)

GenerateDir takes a path to a directory and runs the corresponding generators for all generatable files in the directory Errors:

  • warpforge-error-generator-failed -- when the external generator fails

func GenerateDirRecusive

func GenerateDirRecusive(startPath string) (map[string][]byte, error)

GenerateDirRecursive takes a path to a directory and runs the corresponding generators for all generatable files in the directory, recursing into subdirectories Errors:

  • warpforge-error-generator-failed -- when the external generator fails
  • warpforge-error-io -- when the dir walk fails

func GenerateFile

func GenerateFile(path string) ([]byte, error)

GenerateFile takes a path to a file and runs the corresponding generator. Errors:

  • warpforge-error-generator-failed -- when the external generator fails

func OpenWorkspaceSet

func OpenWorkspaceSet() (workspace.WorkspaceSet, error)

OpenWorkspaceSet opens the default WorkspaceSet. This consists of:

workspace stack: a workspace stack starting at the current working directory,
 root workspace: the first marked root workspace in the stack, or the home workspace if none are marked,
 home workspace: the workspace at the user's homedir

Errors:

  • warpforge-error-workspace -- could not load workspace stack
  • warpforge-error-unknown -- failed to get working directory

func PlotFromFile

func PlotFromFile(filename string) (wfapi.Plot, error)

DEPRECATED: use dab package PlotFromFile takes a path to a plot file, returns a plot Errors:

  • warpforge-error-io -- plot file cannot be read
  • warpforge-error-plot-invalid -- plot data is invalid
  • warpforge-error-serialization -- plot file cannot be serialized into a plot

Types

This section is empty.

Jump to

Keyboard shortcuts

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