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:
Emmanuel BENOîT 2024-07-19 23:46:33 +02:00
parent b3aa7dfcad
commit 5432360f0e
Signed by: Emmanuel BENOîT
SSH key fingerprint: SHA256:l7PFUUF5TCDsvYeQC9OnTNz08dFY7Fvf4Hv3neIqYpg
5 changed files with 30 additions and 19 deletions
cmd
sslcert
zoneserial

View file

@ -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

View file

@ -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.