Split monolithic rule into per-test rules, collect gathers facts only
This commit is contained in:
parent
5b71e85f49
commit
4177fcdc7b
14 changed files with 758 additions and 259 deletions
34
checker/rules_discovery.go
Normal file
34
checker/rules_discovery.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package checker
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
sdk "git.happydns.org/checker-sdk-go/checker"
|
||||
)
|
||||
|
||||
// endpointsDiscoveredRule surfaces the "no producer has published endpoints
|
||||
// for this target yet" steady state. Kept as its own rule so it does not
|
||||
// contaminate per-endpoint findings when discovery is in flight.
|
||||
type endpointsDiscoveredRule struct{}
|
||||
|
||||
func (r *endpointsDiscoveredRule) Name() string { return "tls.endpoints_discovered" }
|
||||
func (r *endpointsDiscoveredRule) Description() string {
|
||||
return "Verifies that at least one TLS endpoint has been discovered for this target."
|
||||
}
|
||||
|
||||
func (r *endpointsDiscoveredRule) Evaluate(ctx context.Context, obs sdk.ObservationGetter, _ sdk.CheckerOptions) []sdk.CheckState {
|
||||
data, errSt := loadData(ctx, obs)
|
||||
if errSt != nil {
|
||||
return []sdk.CheckState{*errSt}
|
||||
}
|
||||
if len(data.Probes) == 0 {
|
||||
return []sdk.CheckState{unknownState(
|
||||
"tls.endpoints_discovered.none",
|
||||
"No TLS endpoints have been discovered for this target yet.",
|
||||
)}
|
||||
}
|
||||
return []sdk.CheckState{passState(
|
||||
"tls.endpoints_discovered.ok",
|
||||
"TLS endpoints were discovered for this target.",
|
||||
)}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue