Skip to content

Commit

Permalink
feat(lb): improve backend help in case healthcheck is missing (#2689)
Browse files Browse the repository at this point in the history
Co-authored-by: Rémy Léone <[email protected]>
  • Loading branch information
yfodil and remyleone authored Nov 29, 2023
1 parent a529cb6 commit ea6fdae
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/namespaces/lb/v1/custom_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lb

import (
"context"
"errors"
"fmt"
"reflect"
"strings"
Expand All @@ -12,6 +13,7 @@ import (
"github.com/scaleway/scaleway-sdk-go/api/baremetal/v1"
"github.com/scaleway/scaleway-sdk-go/api/instance/v1"
"github.com/scaleway/scaleway-sdk-go/api/lb/v1"
"github.com/scaleway/scaleway-sdk-go/scw"
)

var (
Expand Down Expand Up @@ -781,6 +783,21 @@ func interceptBackend() core.CommandInterceptor {

res, err := runner(ctx, argsI)
if err != nil {
var invalidArgErr *scw.InvalidArgumentsError
if errors.As(err, &invalidArgErr) {
for _, detail := range invalidArgErr.Details {
switch detail.ArgumentName {
case "Port":
return nil, &core.CliError{
Err: fmt.Errorf("missing or invalid 'health-check.port' argument"),
}
case "CheckMaxRetries":
return nil, &core.CliError{
Err: fmt.Errorf("missing or invalid 'health-check.check-max-retries' argument"),
}
}
}
}
return nil, err
}

Expand Down

0 comments on commit ea6fdae

Please sign in to comment.