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