Code suggestions #8
30
probes.go
30
probes.go
@ -35,44 +35,28 @@ func New(options ...Option) (Kubeprobes, error) {
|
||||
}
|
||||
|
||||
func (kp *kubeprobes) validate() error {
|
||||
errs := []error{}
|
||||
|
||||
var err error
|
||||
if kp.pathLive == "" {
|
||||
errs = append(
|
||||
errs,
|
||||
fmt.Errorf("liveness probe path must not be empty"),
|
||||
)
|
||||
err = errors.Join(err, fmt.Errorf("liveness probe path must not be empty"))
|
||||
}
|
||||
|
||||
if kp.pathReady == "" {
|
||||
errs = append(
|
||||
errs,
|
||||
fmt.Errorf("readiness probe path must not be empty"),
|
||||
)
|
||||
err = errors.Join(err, fmt.Errorf("readiness probe path must not be empty"))
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(kp.pathLive, "/") {
|
||||
errs = append(
|
||||
errs,
|
||||
fmt.Errorf("liveness probe path must start with slash (current: %q)", kp.pathLive),
|
||||
)
|
||||
err = errors.Join(err, fmt.Errorf("liveness probe path must start with slash (current: %q)", kp.pathLive))
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(kp.pathReady, "/") {
|
||||
errs = append(
|
||||
errs,
|
||||
fmt.Errorf("readiness probe path must start with slash (current: %q)", kp.pathReady),
|
||||
)
|
||||
err = errors.Join(err, fmt.Errorf("readiness probe path must start with slash (current: %q)", kp.pathReady))
|
||||
}
|
||||
|
||||
if kp.pathLive == kp.pathReady {
|
||||
errs = append(
|
||||
errs,
|
||||
fmt.Errorf("liveness and readiness probes have the same values (both %q)", kp.pathLive),
|
||||
)
|
||||
err = errors.Join(err, fmt.Errorf("liveness and readiness probes have the same values (both %q)", kp.pathLive))
|
||||
}
|
||||
|
||||
return errors.Join(errs...)
|
||||
return err
|
||||
}
|
||||
|
||||
func (kp *kubeprobes) handleLiveness(w http.ResponseWriter, _ *http.Request) {
|
||||
|
Loading…
Reference in New Issue
Block a user