Invert the logic to preserve the happy path
@@ -57,13 +57,15 @@ func New(ctx context.Context) (*Client, error) {
return nil, err
}
- if ba, ok := b.(containers.ContainerService); ok {
+ ba, ok := b.(containers.ContainerService)
+ if !ok {
+ return nil, errors.New("backend not found")
+ }
return &Client{
backendType: contextType,
cc: ba,
}, nil
- }
- return nil, errors.New("backend not found")
+
}
type Client struct {
