refactor(pkg): refactor Plugin
to make it easier to test
Writing the plugin's output string and exiting the program will no longer take place in the plugin status itself. It will only be done in the main program.
This commit is contained in:
parent
b3aa7dfcad
commit
5432360f0e
5 changed files with 30 additions and 19 deletions
|
@ -215,9 +215,9 @@ func NewProgram() program.Program {
|
|||
return program
|
||||
}
|
||||
|
||||
// Terminate the monitoring check program.
|
||||
func (program *checkProgram) Done() {
|
||||
program.plugin.Done()
|
||||
// Return the program's output value.
|
||||
func (program *checkProgram) Output() *plugin.Plugin {
|
||||
return program.plugin
|
||||
}
|
||||
|
||||
// Check the values that were specified from the command line. Returns true
|
||||
|
|
|
@ -85,13 +85,9 @@ func NewProgram() program.Program {
|
|||
return program
|
||||
}
|
||||
|
||||
// Terminate the monitoring check program.
|
||||
func (program *checkProgram) Done() {
|
||||
if r := recover(); r != nil {
|
||||
program.plugin.SetState(plugin.StatusUnknown, "Internal error")
|
||||
program.plugin.AddLinef("Error info: %v", r)
|
||||
}
|
||||
program.plugin.Done()
|
||||
// Return the program's output value.
|
||||
func (program *checkProgram) Output() *plugin.Plugin {
|
||||
return program.plugin
|
||||
}
|
||||
|
||||
// Check the values that were specified from the command line. Returns true if the arguments made sense.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue