-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathplugin_testconn.go
More file actions
46 lines (35 loc) · 921 Bytes
/
plugin_testconn.go
File metadata and controls
46 lines (35 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package plugin
import (
"context"
"github.com/rs/zerolog"
)
type TestConnError struct {
Code string
Message error
}
func NewTestConnError(code string, err error) *TestConnError {
return &TestConnError{
Code: code,
Message: err,
}
}
func (e *TestConnError) Error() string {
return e.Message.Error()
}
func (e *TestConnError) Unwrap() error {
return e.Message
}
func (e *TestConnError) Is(err error) bool {
if err2, ok := err.(*TestConnError); ok {
return e.Code == err2.Code
}
return false
}
type ConnectionTester func(ctx context.Context, logger zerolog.Logger, spec []byte) error
func (p *Plugin) TestConnection(ctx context.Context, logger zerolog.Logger, spec []byte) error {
return p.testConnFn(ctx, logger, spec)
}
func UnimplementedTestConnectionFn(context.Context, zerolog.Logger, []byte) error {
return ErrNotImplemented
}
var _ ConnectionTester = UnimplementedTestConnectionFn