34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
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.",
|
|
)}
|
|
}
|