MCPcopy
hub / github.com/etcd-io/etcd / ExampleConfig_withTLS

Function ExampleConfig_withTLS

client/v3/example_test.go:51–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

49func mockConfig_withTLS() {}
50
51func ExampleConfig_withTLS() {
52 forUnitTestsRunInMockedContext(mockConfig_withTLS, func() {
53 tlsInfo := transport.TLSInfo{
54 CertFile: "/tmp/test-certs/test-name-1.pem",
55 KeyFile: "/tmp/test-certs/test-name-1-key.pem",
56 TrustedCAFile: "/tmp/test-certs/trusted-ca.pem",
57 }
58 tlsConfig, err := tlsInfo.ClientConfig()
59 if err != nil {
60 log.Fatal(err)
61 }
62 cli, err := clientv3.New(clientv3.Config{
63 Endpoints: exampleEndpoints(),
64 DialTimeout: dialTimeout,
65 TLS: tlsConfig,
66 })
67 if err != nil {
68 log.Fatal(err)
69 }
70 defer cli.Close() // make sure to close the client
71
72 _, err = cli.Put(context.TODO(), "foo", "bar")
73 if err != nil {
74 log.Fatal(err)
75 }
76 })
77 // Without the line below the test is not being executed
78 // Output:
79}

Callers

nothing calls this directly

Calls 6

ClientConfigMethod · 0.95
exampleEndpointsFunction · 0.70
FatalMethod · 0.65
CloseMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…