Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 300ebd8

Browse files
authored
cmd/bosun: pass stderr on error to user for save command
1 parent c699b45 commit 300ebd8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cmd/bosun/conf/conf.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ type BulkEditRequest []EditRequest
377377

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

396-
// MakeSaveCommandHook takes a fuction based on the command name and will run it on save passing files, user,
396+
// MakeSaveCommandHook takes a function based on the command name and will run it on save passing files, user,
397397
// message, args... as arguments to the command. For the SaveHook function that is returned, If the command fails
398398
// to execute or returns a non normal output then an error is returned.
399399
func MakeSaveCommandHook(cmdName string) (f SaveHook, err error) {
@@ -417,9 +417,9 @@ func MakeSaveCommandHook(cmdName string) (f SaveHook, err error) {
417417
err = c.Wait()
418418
if err != nil {
419419
slog.Warning(cErr.String())
420-
return err
420+
return fmt.Errorf("%v: %v", err, cErr.String())
421421
}
422-
slog.Infof("save hook ouput: %v\n", cOut.String())
422+
slog.Infof("save hook output: %v\n", cOut.String())
423423
return nil
424424
}
425425
return

docs/system_configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Example:
134134
### CommandHookPath
135135
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.
136136

137-
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).
137+
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.
138138

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

0 commit comments

Comments
 (0)