Documentation ¶
Index ¶
- Constants
- 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 CheckVersion(cmd *cobra.Command, args []string) error
- func DownloadResultsHandler(ctx context.Context, cmd *cobra.Command, jobID string, ...) error
- func EnsureValidVersion(ctx context.Context, clientVersion, serverVersion *models.BuildVersionInfo) error
- func ExecuteJob(ctx context.Context, j *model.Job, ...) (*model.Job, error)
- func FakeFatalErrorHandler(cmd *cobra.Command, msg error, code int)
- func GetAPIClient(ctx context.Context) *client.APIClient
- func GetAPIClientV2(ctx context.Context) *clientv2.Client
- func GetCleanupManager(ctx context.Context) *system.CleanupManager
- func GetDefaultJobFolder(jobID string) string
- func Logs(cmd *cobra.Command, jobID string, follow, history bool) error
- func PrintUpdateCheck(cmd *cobra.Command, args []string)
- func ReadFromStdinIfAvailable(cmd *cobra.Command) ([]byte, error)
- func StartUpdateCheck(cmd *cobra.Command, args []string)
- type Msg
- type Versions
Constants ¶
const AutoDownloadFolderPerm = 0755
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), Adapt(StartUpdateCheck), )
ClientPreRunHooks is the set of pre-run hooks that all client commands should have applied.
var Fatal = fatalError
var LoggingMode = logger.LogModeDefault
var SystemManagerKey = contextKey{/* contains filtered or unexported fields */}
Functions ¶
func Adapt ¶ added in v1.1.2
func Adapt(hook runHook) runHookE
Adapt turns a run hook that does not return an error into one that does.
func AfterParentHook ¶ added in v1.1.2
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 ¶ added in v1.1.2
func AfterParentPostRunHook(hook runHookE) runHookE
func AfterParentPreRunHook ¶ added in v1.1.2
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 ¶ added in v1.1.2
func Chain(hooks ...runHookE) runHookE
Run all of the passed hooks in order, stopping on and returning the first error.
func DownloadResultsHandler ¶
func EnsureValidVersion ¶
func EnsureValidVersion(ctx context.Context, clientVersion, serverVersion *models.BuildVersionInfo) error
func ExecuteJob ¶
func FakeFatalErrorHandler ¶
FakeFatalErrorHandler captures the error for testing, responsibility of the test to handle the exit (if any) NOTE: If your test is not idempotent, you can cause side effects (the underlying function will continue to run) Returned as text JSON to wherever RootCmd is printing.
func GetCleanupManager ¶
func GetCleanupManager(ctx context.Context) *system.CleanupManager
func GetDefaultJobFolder ¶
func PrintUpdateCheck ¶ added in v1.1.2
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 ¶ added in v1.1.2
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 ¶
type Versions ¶ added in v1.1.2
type Versions struct { ClientVersion *models.BuildVersionInfo `json:"clientVersion,omitempty"` ServerVersion *models.BuildVersionInfo `json:"serverVersion,omitempty"` LatestVersion *models.BuildVersionInfo `json:"latestVersion,omitempty"` UpdateMessage string `json:"updateMessage,omitempty"` }