diff --git a/plugins/sync/etcd/etcd.go b/plugins/sync/etcd/etcd.go index 00be0169..05a4210b 100644 --- a/plugins/sync/etcd/etcd.go +++ b/plugins/sync/etcd/etcd.go @@ -165,6 +165,7 @@ func NewSync(opts ...sync.Option) sync.Sync { // TODO: parse addresses c, err := clientv3.New(clientv3.Config{ Endpoints: endpoints, + TLS: options.TLSConfig, }) if err != nil { log.Fatal(err) diff --git a/sync/options.go b/sync/options.go index 6c546356..81d6e256 100644 --- a/sync/options.go +++ b/sync/options.go @@ -1,6 +1,7 @@ package sync import ( + "crypto/tls" "time" ) @@ -31,3 +32,10 @@ func LockWait(t time.Duration) LockOption { o.Wait = t } } + +// WithTLS sets the TLS config +func WithTLS(t *tls.Config) Option { + return func(o *Options) { + o.TLSConfig = t + } +} diff --git a/sync/sync.go b/sync/sync.go index 0c5203b7..38b3a7d9 100644 --- a/sync/sync.go +++ b/sync/sync.go @@ -2,6 +2,7 @@ package sync import ( + "crypto/tls" "errors" "time" ) @@ -35,8 +36,9 @@ type Leader interface { } type Options struct { - Nodes []string - Prefix string + Nodes []string + Prefix string + TLSConfig *tls.Config } type Option func(o *Options)