kubeprobes/kubeprobes_options.go

48 lines
1.2 KiB
Go
Raw Normal View History

package kubeprobes
// Option represents a [Kubeprobes] constructor option.
type Option interface {
apply(kp *kubeprobes)
}
type option func(*kubeprobes)
func (o option) apply(kp *kubeprobes) {
o(kp)
}
// WithLivenessProbes adds given probe functions to the set of liveness probes.
func WithLivenessProbes(probes ...Probe) Option {
return option(func(kp *kubeprobes) {
kp.livenessProbes = append(kp.livenessProbes, probes...)
})
}
// WithLivenessPath sets custom path for liveness probe (default is "/live").
func WithLivenessPath(path string) Option {
return option(func(kp *kubeprobes) {
kp.pathLive = path
})
}
// WithReadinessProbes adds given probe functions to the set of readiness probes.
func WithReadinessProbes(probes ...Probe) Option {
return option(func(kp *kubeprobes) {
kp.readinessProbes = append(kp.readinessProbes, probes...)
})
}
// WithReadinessPath sets custom path for readiness probe (default is "/ready").
func WithReadinessPath(path string) Option {
return option(func(kp *kubeprobes) {
kp.pathReady = path
})
}
// WithVerboseOutput enables verbose output for every request.
func WithVerboseOutput() Option {
return option(func(kp *kubeprobes) {
kp.verbose = true
})
}