|
@@ -19,6 +19,7 @@ import (
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/clientv3"
|
|
"github.com/coreos/etcd/clientv3"
|
|
|
|
|
+ "github.com/coreos/etcd/pkg/transport"
|
|
|
"golang.org/x/net/context"
|
|
"golang.org/x/net/context"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -43,3 +44,29 @@ func Example() {
|
|
|
log.Fatal(err)
|
|
log.Fatal(err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func ExampleConfig_withTLS() {
|
|
|
|
|
+ tlsInfo := transport.TLSInfo{
|
|
|
|
|
+ CertFile: "/tmp/test-certs/test-name-1.pem",
|
|
|
|
|
+ KeyFile: "/tmp/test-certs/test-name-1-key.pem",
|
|
|
|
|
+ TrustedCAFile: "/tmp/test-certs/trusted-ca.pem",
|
|
|
|
|
+ }
|
|
|
|
|
+ tlsConfig, err := tlsInfo.ClientConfig()
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ log.Fatal(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ cli, err := clientv3.New(clientv3.Config{
|
|
|
|
|
+ Endpoints: endpoints,
|
|
|
|
|
+ DialTimeout: dialTimeout,
|
|
|
|
|
+ TLS: tlsConfig,
|
|
|
|
|
+ })
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ log.Fatal(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ defer cli.Close() // make sure to close the client
|
|
|
|
|
+
|
|
|
|
|
+ _, err = cli.Put(context.TODO(), "foo", "bar")
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ log.Fatal(err)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|