Documentation ¶
Index ¶
- Variables
- func Adapt(hook runHook) runHookE
- func AfterParentHook(hook runHookE, getHook func(*cobra.Command) runHookE) runHookE
- func AfterParentPostRunHook(hook runHookE) runHookE
- func AfterParentPreRunHook(hook runHookE) runHookE
- func ApplyPorcelainLogLevel(cmd *cobra.Command, _ []string)
- func Chain(hooks ...runHookE) runHookE
- func PrintUpdateCheck(cmd *cobra.Command, args []string)
- func StartUpdateCheck(cmd *cobra.Command, cfg types.Bacalhau, store version.UpdateStore)
Constants ¶
This section is empty.
Variables ¶
var ClientPostRunHooks runHookE = Chain( Adapt(PrintUpdateCheck), )
ClientPostRunHooks is the set of post-run hooks that all client commands should have applied.
var ClientPreRunHooks runHookE = Chain( Adapt(ApplyPorcelainLogLevel), )
ClientPreRunHooks is the set of pre-run hooks that all client commands should have applied.
var RemoteCmdPostRunHooks runHookE = ClientPostRunHooks
RemoteCmdPostRunHooks is the set of post-run hooks that all commands that communicate with remote servers should have applied.
var RemoteCmdPreRunHooks runHookE = Chain( ClientPreRunHooks, )
RemoteCmdPreRunHooks is the set of pre-run hooks that all commands that communicate with remote servers should have applied.
Functions ¶
func Adapt ¶
func Adapt(hook runHook) runHookE
Adapt turns a run hook that does not return an error into one that does.
func AfterParentHook ¶
Because cobra doesn't do PersistentPreRun{,E} chaining yet (https://github.com/spf13/cobra/issues/252), this function walks upwards and finds any parent hook that should be run if the hooks were properly persistent. The complexity here is that if we are running on a child command we will first find the parent hook, and need to skip that otherwise we'll end up in an infinite loop.
func AfterParentPostRunHook ¶
func AfterParentPostRunHook(hook runHookE) runHookE
func AfterParentPreRunHook ¶
func AfterParentPreRunHook(hook runHookE) runHookE
func ApplyPorcelainLogLevel ¶
ApplyPorcelainLogLevel sets the log level of loggers running on user-facing "porcelain" commands to be zerolog.FatalLevel to reduce noise shown to users, unless the user has specifically set a valid log level with an env var.
func Chain ¶
func Chain(hooks ...runHookE) runHookE
Run all of the passed hooks in order, stopping on and returning the first error.
func PrintUpdateCheck ¶
PrintUpdateCheck is a Cobra post run hook to print the results of an update check. The message will be a non-nil pointer only if the update check succeeds and should only have visible output if the message is non-empty.
func StartUpdateCheck ¶
StartUpdateCheck is a Cobra pre run hook to run an update check in the background. There should be no output if the check fails or the context is cancelled before the check can complete.
Types ¶
This section is empty.