-
Notifications
You must be signed in to change notification settings - Fork 1
/
option.go
49 lines (42 loc) · 1.61 KB
/
option.go
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
47
48
49
package listen
import (
"github.com/borderzero/border0-go/client"
"github.com/borderzero/border0-go/lib/types/pointer"
)
// Option is a function that configures a Listener.
type Option func(*Listener)
// WithAPIClient sets the API client to use for the Listener.
func WithAPIClient(api client.Requester) Option {
return func(l *Listener) {
l.apiClient = api
}
}
// WithAuthToken sets the auth token to use with the API client.
func WithAuthToken(token string) Option {
return func(l *Listener) {
l.authToken = token
}
}
// WithSocketName sets the socket name to use for the HTTP socket that the Listener will create.
func WithSocketName(name string) Option {
return func(l *Listener) {
l.socketName = name
}
}
// WithPolicies sets the policy names to use for the Listener's underlaying HTTP socket. Policies with the
// given names will be attached to the socket. If the policy names list is empty, then no policies will be
// attached. If there are any changes made to the policy names list between listener startups, they will get
// properly handled. The listener will check the socket's already attached policies, and compare them with
// the given policy names. Removed policies will be detached from the socket, and new policies will be checked
// and made sure they exist, and then they will be attached to the listener's socket.
func WithPolicies(names []string) Option {
return func(l *Listener) {
l.policyNames = pointer.To(names)
}
}
// WithTunnelServer sets the tunnel server address for the Listener.
func WithTunnelServer(server string) Option {
return func(l *Listener) {
l.tunnelServer = server
}
}