Documentation
¶
Overview ¶
Package validation provides a shared validator instance.
Index ¶
- func AtLeastOneField(v any) (string, bool)
- func Instance() *validator.Validate
- func IsPendingTarget() (string, bool)
- func RegisterTargetValidator(lister AgentLister)
- func ResolveTarget(target string) string
- func Struct(v any) (string, bool)
- func Var(field any, tag string) (string, bool)
- type AgentLister
- type AgentTarget
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtLeastOneField ¶
AtLeastOneField checks that at least one exported pointer, slice, or map field in the struct is non-nil, or that at least one non-pointer field is non-zero. Returns an error message and false if all fields are nil/zero (i.e., the update body is empty).
func IsPendingTarget ¶
IsPendingTarget returns true if the last validation failure was due to a pending agent, and clears the flag.
func RegisterTargetValidator ¶
func RegisterTargetValidator( lister AgentLister, )
RegisterTargetValidator registers the valid_target custom validator and sets the AgentLister it uses. Call this at API server startup after the job client is created, or in test SetupSuite to inject a mock.
func ResolveTarget ¶
ResolveTarget resolves a target string to a machine ID for NATS subject routing. If the target matches a hostname, the corresponding machine ID is returned. If it matches a machine ID directly, it is returned as-is. Broadcast and label targets are returned unchanged.
Types ¶
type AgentLister ¶
type AgentLister func(ctx context.Context) ([]AgentTarget, error)
AgentLister returns active agents with their hostnames and labels.