checker: return slice of CheckStates and bump sdk to 1.2.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
nemunaire 2026-04-23 15:14:27 +07:00
commit ff5c784f3d
3 changed files with 8 additions and 8 deletions

View file

@ -58,15 +58,15 @@ func (r *dummyRule) ValidateOptions(opts sdk.CheckerOptions) error {
// The ObservationGetter.Get method deserialises the stored JSON into your data
// struct. Always check the error: the observation may not be available if
// collection failed.
func (r *dummyRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opts sdk.CheckerOptions) sdk.CheckState {
func (r *dummyRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opts sdk.CheckerOptions) []sdk.CheckState {
// Retrieve the observation data by key.
var data DummyData
if err := obs.Get(ctx, ObservationKeyDummy, &data); err != nil {
return sdk.CheckState{
return []sdk.CheckState{{
Status: sdk.StatusError,
Message: fmt.Sprintf("Failed to get dummy data: %v", err),
Code: "dummy_error",
}
}}
}
// Read thresholds from options.
@ -84,7 +84,7 @@ func (r *dummyRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opt
status = sdk.StatusOK
}
return sdk.CheckState{
return []sdk.CheckState{{
Status: status,
Message: fmt.Sprintf("Score: %.1f - %s", data.Score, data.Message),
Code: "dummy_score_check",
@ -92,5 +92,5 @@ func (r *dummyRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, opt
"score": data.Score,
"message": data.Message,
},
}
}}
}

2
go.mod
View file

@ -2,4 +2,4 @@ module git.happydns.org/checker-dummy
go 1.25.0
require git.happydns.org/checker-sdk-go v1.0.0
require git.happydns.org/checker-sdk-go v1.2.0

4
go.sum
View file

@ -1,2 +1,2 @@
git.happydns.org/checker-sdk-go v1.0.0 h1:5u8vnvoH2KEbHtAqPu/Wh6xBQ8PWgle9iZ1j7HTZXd8=
git.happydns.org/checker-sdk-go v1.0.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI=
git.happydns.org/checker-sdk-go v1.2.0 h1:v4MpKAz0W3PwP+bxx3pya8w893sVH5xTD1of1cc0TV8=
git.happydns.org/checker-sdk-go v1.2.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI=