Compare commits
No commits in common. "master" and "v0.3.0" have entirely different histories.
2 changed files with 2 additions and 26 deletions
|
|
@ -2,9 +2,6 @@ package checker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"net/mail"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||||
|
|
@ -24,27 +21,6 @@ func (p *happyDeliverProvider) Definition() *sdk.CheckerDefinition {
|
||||||
return Definition()
|
return Definition()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateOptions runs on the host before Collect so bad options are rejected
|
|
||||||
// up-front rather than surfacing as a runtime SMTP failure.
|
|
||||||
func (p *happyDeliverProvider) ValidateOptions(opts sdk.CheckerOptions) error {
|
|
||||||
raw, ok := opts["from_address"]
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
s, ok := raw.(string)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("from_address must be a string")
|
|
||||||
}
|
|
||||||
s = strings.TrimSpace(s)
|
|
||||||
if s == "" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if _, err := mail.ParseAddress(s); err != nil {
|
|
||||||
return fmt.Errorf("invalid from_address: %w", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *happyDeliverProvider) ExtractMetrics(ctx sdk.ReportContext, collectedAt time.Time) ([]sdk.CheckMetric, error) {
|
func (p *happyDeliverProvider) ExtractMetrics(ctx sdk.ReportContext, collectedAt time.Time) ([]sdk.CheckMetric, error) {
|
||||||
var data HappyDeliverData
|
var data HappyDeliverData
|
||||||
if err := json.Unmarshal(ctx.Data(), &data); err != nil {
|
if err := json.Unmarshal(ctx.Data(), &data); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ func TestDefinitionShape(t *testing.T) {
|
||||||
if def.ID != "happydeliver" {
|
if def.ID != "happydeliver" {
|
||||||
t.Errorf("ID = %q", def.ID)
|
t.Errorf("ID = %q", def.ID)
|
||||||
}
|
}
|
||||||
if !def.Availability.ApplyToService {
|
if !def.Availability.ApplyToDomain {
|
||||||
t.Error("should apply to service")
|
t.Error("should apply to domain")
|
||||||
}
|
}
|
||||||
if !def.HasMetrics {
|
if !def.HasMetrics {
|
||||||
t.Error("HasMetrics should be true")
|
t.Error("HasMetrics should be true")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue