2024-03-02 23:55:28 +01:00
|
|
|
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.
|
2024-03-03 23:24:42 +01:00
|
|
|
func WithLivenessProbes(probes ...Probe) Option {
|
2024-03-02 23:55:28 +01:00
|
|
|
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.
|
2024-03-03 23:24:42 +01:00
|
|
|
func WithReadinessProbes(probes ...Probe) Option {
|
2024-03-02 23:55:28 +01:00
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|