Skip to content
Permalink
Browse files
cmd/bosun: pass stderr on error to user for save command
  • Loading branch information
kylebrandt committed Apr 18, 2017
1 parent c699b45 commit 300ebd8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
@@ -377,7 +377,7 @@ type BulkEditRequest []EditRequest

// EditRequest is a proposed edit to the config file for sections. The Name is the name of section,
// Type can be "alert", "template", "notification", "lookup", or "macro". The Text should be the full
// text of the definition, including the delaration and brackets (i.e. "alert foo { .. }"). If Delete
// text of the definition, including the declaration and brackets (i.e. "alert foo { .. }"). If Delete
// is true then the section will be deleted. In order to rename something, specify the old name in the
// Name field but have the Text definition contain the new name.
type EditRequest struct {
@@ -393,7 +393,7 @@ type EditRequest struct {
// when the SaveHook returns an error.
type SaveHook func(files, user, message string, args ...string) error

// MakeSaveCommandHook takes a fuction based on the command name and will run it on save passing files, user,
// MakeSaveCommandHook takes a function based on the command name and will run it on save passing files, user,
// message, args... as arguments to the command. For the SaveHook function that is returned, If the command fails
// to execute or returns a non normal output then an error is returned.
func MakeSaveCommandHook(cmdName string) (f SaveHook, err error) {
@@ -417,9 +417,9 @@ func MakeSaveCommandHook(cmdName string) (f SaveHook, err error) {
err = c.Wait()
if err != nil {
slog.Warning(cErr.String())
return err
return fmt.Errorf("%v: %v", err, cErr.String())
}
slog.Infof("save hook ouput: %v\n", cOut.String())
slog.Infof("save hook output: %v\n", cOut.String())
return nil
}
return
@@ -134,7 +134,7 @@ Example:
### CommandHookPath
When enabling saving, and a user issues a save, you have the option to run a executable or script by specifying this parameter. This allows you to do things like backup the file on writes or commit the file to a git repo.

This command is passed a filename, username, message, and vargs (vargs is currently not used). If the command exits a non-zero exit code, then the changes will be reverted (the file before the changes is copied back and bosun doesn't restart).
This command is passed a filename, username, message, and vargs (vargs is currently not used). If the command exits a non-zero exit code, then the changes will be reverted (the file before the changes is copied back and bosun doesn't restart). When the configuration is saved via the user interface, any messages to standard error will be shown to the user when there is a non-zero exit code.

Example:
`CommandHookPath = "/Users/kbrandt/src/hook/hook"`

0 comments on commit 300ebd8

Please sign in to comment.