Skip to content

Commit 49a29fc

Browse files
committed
[configtls] Rename config structs for consistancy
This commit renames the following structs: * TLSClientSetting to ClientConfig * TLSServerSetting to ServerConfig * TLSSetting to Config This is based on the naming convention followed in other config packages. Fixes #9474
1 parent 52c914d commit 49a29fc

File tree

15 files changed

+254
-229
lines changed

15 files changed

+254
-229
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: configtls
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Rename TLSClientSetting, TLSServerSetting, and TLSSetting based on the naming convention used in other config packages.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [9474]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: []

config/configgrpc/configgrpc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ type ClientConfig struct {
6161
// The compression key for supported compression types within collector.
6262
Compression configcompression.Type `mapstructure:"compression"`
6363

64-
// TLSSetting struct exposes TLS client configuration.
65-
TLSSetting configtls.TLSClientSetting `mapstructure:"tls"`
64+
// Config struct exposes TLS client configuration.
65+
Config configtls.ClientConfig `mapstructure:"tls"`
6666

6767
// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
6868
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
@@ -131,7 +131,7 @@ type ServerConfig struct {
131131

132132
// Configures the protocol to use TLS.
133133
// The default value is nil, which will cause the protocol to not use TLS.
134-
TLSSetting *configtls.TLSServerSetting `mapstructure:"tls"`
134+
Config *configtls.ServerConfig `mapstructure:"tls"`
135135

136136
// MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server.
137137
MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib"`
@@ -202,7 +202,7 @@ func (gcs *ClientConfig) toDialOptions(host component.Host, settings component.T
202202
opts = append(opts, grpc.WithDefaultCallOptions(grpc.UseCompressor(cp)))
203203
}
204204

205-
tlsCfg, err := gcs.TLSSetting.LoadTLSConfig()
205+
tlsCfg, err := gcs.Config.LoadTLSConfig()
206206
if err != nil {
207207
return nil, err
208208
}
@@ -304,8 +304,8 @@ func (gss *ServerConfig) toServerOption(host component.Host, settings component.
304304

305305
var opts []grpc.ServerOption
306306

307-
if gss.TLSSetting != nil {
308-
tlsCfg, err := gss.TLSSetting.LoadTLSConfig()
307+
if gss.Config != nil {
308+
tlsCfg, err := gss.Config.LoadTLSConfig()
309309
if err != nil {
310310
return nil, err
311311
}

config/configgrpc/configgrpc_test.go

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func TestDefaultGrpcClientSettings(t *testing.T) {
6363
t.Cleanup(func() { require.NoError(t, tt.Shutdown(context.Background())) })
6464

6565
gcs := &ClientConfig{
66-
TLSSetting: configtls.TLSClientSetting{
66+
Config: configtls.ClientConfig{
6767
Insecure: true,
6868
},
6969
}
@@ -90,7 +90,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
9090
},
9191
Endpoint: "localhost:1234",
9292
Compression: configcompression.TypeGzip,
93-
TLSSetting: configtls.TLSClientSetting{
93+
Config: configtls.ClientConfig{
9494
Insecure: false,
9595
},
9696
Keepalive: &KeepaliveClientConfig{
@@ -119,7 +119,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
119119
},
120120
Endpoint: "localhost:1234",
121121
Compression: configcompression.TypeSnappy,
122-
TLSSetting: configtls.TLSClientSetting{
122+
Config: configtls.ClientConfig{
123123
Insecure: false,
124124
},
125125
Keepalive: &KeepaliveClientConfig{
@@ -148,7 +148,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
148148
},
149149
Endpoint: "localhost:1234",
150150
Compression: configcompression.TypeZstd,
151-
TLSSetting: configtls.TLSClientSetting{
151+
Config: configtls.ClientConfig{
152152
Insecure: false,
153153
},
154154
Keepalive: &KeepaliveClientConfig{
@@ -196,8 +196,8 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
196196
Endpoint: "localhost:1234",
197197
Transport: "tcp",
198198
},
199-
TLSSetting: &configtls.TLSServerSetting{
200-
TLSSetting: configtls.TLSSetting{},
199+
Config: &configtls.ServerConfig{
200+
Config: configtls.Config{},
201201
ClientCAFile: "",
202202
},
203203
MaxRecvMsgSizeMiB: 1,
@@ -258,8 +258,8 @@ func TestGRPCClientSettingsError(t *testing.T) {
258258
Headers: nil,
259259
Endpoint: "",
260260
Compression: "",
261-
TLSSetting: configtls.TLSClientSetting{
262-
TLSSetting: configtls.TLSSetting{
261+
Config: configtls.ClientConfig{
262+
Config: configtls.Config{
263263
CAFile: "/doesnt/exist",
264264
},
265265
Insecure: false,
@@ -274,8 +274,8 @@ func TestGRPCClientSettingsError(t *testing.T) {
274274
Headers: nil,
275275
Endpoint: "",
276276
Compression: "",
277-
TLSSetting: configtls.TLSClientSetting{
278-
TLSSetting: configtls.TLSSetting{
277+
Config: configtls.ClientConfig{
278+
Config: configtls.Config{
279279
CertFile: "/doesnt/exist",
280280
},
281281
Insecure: false,
@@ -292,7 +292,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
292292
},
293293
Endpoint: "localhost:1234",
294294
Compression: "gzip",
295-
TLSSetting: configtls.TLSClientSetting{
295+
Config: configtls.ClientConfig{
296296
Insecure: false,
297297
},
298298
Keepalive: &KeepaliveClientConfig{
@@ -326,7 +326,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
326326
err: "unsupported compression type \"zlib\"",
327327
settings: ClientConfig{
328328
Endpoint: "localhost:1234",
329-
TLSSetting: configtls.TLSClientSetting{
329+
Config: configtls.ClientConfig{
330330
Insecure: true,
331331
},
332332
Compression: "zlib",
@@ -337,7 +337,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
337337
err: "unsupported compression type \"deflate\"",
338338
settings: ClientConfig{
339339
Endpoint: "localhost:1234",
340-
TLSSetting: configtls.TLSClientSetting{
340+
Config: configtls.ClientConfig{
341341
Insecure: true,
342342
},
343343
Compression: "deflate",
@@ -348,7 +348,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
348348
err: "unsupported compression type \"bad\"",
349349
settings: ClientConfig{
350350
Endpoint: "localhost:1234",
351-
TLSSetting: configtls.TLSClientSetting{
351+
Config: configtls.ClientConfig{
352352
Insecure: true,
353353
},
354354
Compression: "bad",
@@ -374,7 +374,7 @@ func TestUseSecure(t *testing.T) {
374374
Headers: nil,
375375
Endpoint: "",
376376
Compression: "",
377-
TLSSetting: configtls.TLSClientSetting{},
377+
Config: configtls.ClientConfig{},
378378
Keepalive: nil,
379379
}
380380
dialOpts, err := gcs.toDialOptions(componenttest.NewNopHost(), tt.TelemetrySettings())
@@ -445,8 +445,8 @@ func TestGRPCServerSettingsError(t *testing.T) {
445445
Endpoint: "127.0.0.1:1234",
446446
Transport: "tcp",
447447
},
448-
TLSSetting: &configtls.TLSServerSetting{
449-
TLSSetting: configtls.TLSSetting{
448+
Config: &configtls.ServerConfig{
449+
Config: configtls.Config{
450450
CAFile: "/doesnt/exist",
451451
},
452452
},
@@ -459,8 +459,8 @@ func TestGRPCServerSettingsError(t *testing.T) {
459459
Endpoint: "127.0.0.1:1234",
460460
Transport: "tcp",
461461
},
462-
TLSSetting: &configtls.TLSServerSetting{
463-
TLSSetting: configtls.TLSSetting{
462+
Config: &configtls.ServerConfig{
463+
Config: configtls.Config{
464464
CertFile: "/doesnt/exist",
465465
},
466466
},
@@ -473,7 +473,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
473473
Endpoint: "127.0.0.1:1234",
474474
Transport: "tcp",
475475
},
476-
TLSSetting: &configtls.TLSServerSetting{
476+
Config: &configtls.ServerConfig{
477477
ClientCAFile: "/doesnt/exist",
478478
},
479479
},
@@ -493,8 +493,8 @@ func TestGRPCServerSettings_ToListener_Error(t *testing.T) {
493493
Endpoint: "127.0.0.1:1234567",
494494
Transport: "tcp",
495495
},
496-
TLSSetting: &configtls.TLSServerSetting{
497-
TLSSetting: configtls.TLSSetting{
496+
Config: &configtls.ServerConfig{
497+
Config: configtls.Config{
498498
CertFile: "/doesnt/exist",
499499
},
500500
},
@@ -511,42 +511,42 @@ func TestHttpReception(t *testing.T) {
511511

512512
tests := []struct {
513513
name string
514-
tlsServerCreds *configtls.TLSServerSetting
515-
tlsClientCreds *configtls.TLSClientSetting
514+
tlsServerCreds *configtls.ServerConfig
515+
tlsClientCreds *configtls.ClientConfig
516516
hasError bool
517517
}{
518518
{
519519
name: "noTLS",
520520
tlsServerCreds: nil,
521-
tlsClientCreds: &configtls.TLSClientSetting{
521+
tlsClientCreds: &configtls.ClientConfig{
522522
Insecure: true,
523523
},
524524
},
525525
{
526526
name: "TLS",
527-
tlsServerCreds: &configtls.TLSServerSetting{
528-
TLSSetting: configtls.TLSSetting{
527+
tlsServerCreds: &configtls.ServerConfig{
528+
Config: configtls.Config{
529529
CAFile: filepath.Join("testdata", "ca.crt"),
530530
CertFile: filepath.Join("testdata", "server.crt"),
531531
KeyFile: filepath.Join("testdata", "server.key"),
532532
},
533533
},
534-
tlsClientCreds: &configtls.TLSClientSetting{
535-
TLSSetting: configtls.TLSSetting{
534+
tlsClientCreds: &configtls.ClientConfig{
535+
Config: configtls.Config{
536536
CAFile: filepath.Join("testdata", "ca.crt"),
537537
},
538538
ServerName: "localhost",
539539
},
540540
},
541541
{
542542
name: "NoServerCertificates",
543-
tlsServerCreds: &configtls.TLSServerSetting{
544-
TLSSetting: configtls.TLSSetting{
543+
tlsServerCreds: &configtls.ServerConfig{
544+
Config: configtls.Config{
545545
CAFile: filepath.Join("testdata", "ca.crt"),
546546
},
547547
},
548-
tlsClientCreds: &configtls.TLSClientSetting{
549-
TLSSetting: configtls.TLSSetting{
548+
tlsClientCreds: &configtls.ClientConfig{
549+
Config: configtls.Config{
550550
CAFile: filepath.Join("testdata", "ca.crt"),
551551
},
552552
ServerName: "localhost",
@@ -555,16 +555,16 @@ func TestHttpReception(t *testing.T) {
555555
},
556556
{
557557
name: "mTLS",
558-
tlsServerCreds: &configtls.TLSServerSetting{
559-
TLSSetting: configtls.TLSSetting{
558+
tlsServerCreds: &configtls.ServerConfig{
559+
Config: configtls.Config{
560560
CAFile: filepath.Join("testdata", "ca.crt"),
561561
CertFile: filepath.Join("testdata", "server.crt"),
562562
KeyFile: filepath.Join("testdata", "server.key"),
563563
},
564564
ClientCAFile: filepath.Join("testdata", "ca.crt"),
565565
},
566-
tlsClientCreds: &configtls.TLSClientSetting{
567-
TLSSetting: configtls.TLSSetting{
566+
tlsClientCreds: &configtls.ClientConfig{
567+
Config: configtls.Config{
568568
CAFile: filepath.Join("testdata", "ca.crt"),
569569
CertFile: filepath.Join("testdata", "client.crt"),
570570
KeyFile: filepath.Join("testdata", "client.key"),
@@ -574,16 +574,16 @@ func TestHttpReception(t *testing.T) {
574574
},
575575
{
576576
name: "NoClientCertificate",
577-
tlsServerCreds: &configtls.TLSServerSetting{
578-
TLSSetting: configtls.TLSSetting{
577+
tlsServerCreds: &configtls.ServerConfig{
578+
Config: configtls.Config{
579579
CAFile: filepath.Join("testdata", "ca.crt"),
580580
CertFile: filepath.Join("testdata", "server.crt"),
581581
KeyFile: filepath.Join("testdata", "server.key"),
582582
},
583583
ClientCAFile: filepath.Join("testdata", "ca.crt"),
584584
},
585-
tlsClientCreds: &configtls.TLSClientSetting{
586-
TLSSetting: configtls.TLSSetting{
585+
tlsClientCreds: &configtls.ClientConfig{
586+
Config: configtls.Config{
587587
CAFile: filepath.Join("testdata", "ca.crt"),
588588
},
589589
ServerName: "localhost",
@@ -592,16 +592,16 @@ func TestHttpReception(t *testing.T) {
592592
},
593593
{
594594
name: "WrongClientCA",
595-
tlsServerCreds: &configtls.TLSServerSetting{
596-
TLSSetting: configtls.TLSSetting{
595+
tlsServerCreds: &configtls.ServerConfig{
596+
Config: configtls.Config{
597597
CAFile: filepath.Join("testdata", "ca.crt"),
598598
CertFile: filepath.Join("testdata", "server.crt"),
599599
KeyFile: filepath.Join("testdata", "server.key"),
600600
},
601601
ClientCAFile: filepath.Join("testdata", "server.crt"),
602602
},
603-
tlsClientCreds: &configtls.TLSClientSetting{
604-
TLSSetting: configtls.TLSSetting{
603+
tlsClientCreds: &configtls.ClientConfig{
604+
Config: configtls.Config{
605605
CAFile: filepath.Join("testdata", "ca.crt"),
606606
CertFile: filepath.Join("testdata", "client.crt"),
607607
KeyFile: filepath.Join("testdata", "client.key"),
@@ -620,7 +620,7 @@ func TestHttpReception(t *testing.T) {
620620
Endpoint: "localhost:0",
621621
Transport: "tcp",
622622
},
623-
TLSSetting: test.tlsServerCreds,
623+
Config: test.tlsServerCreds,
624624
}
625625
ln, err := gss.ToListenerContext(context.Background())
626626
assert.NoError(t, err)
@@ -633,8 +633,8 @@ func TestHttpReception(t *testing.T) {
633633
}()
634634

635635
gcs := &ClientConfig{
636-
Endpoint: ln.Addr().String(),
637-
TLSSetting: *test.tlsClientCreds,
636+
Endpoint: ln.Addr().String(),
637+
Config: *test.tlsClientCreds,
638638
}
639639
grpcClientConn, errClient := gcs.ToClientConn(context.Background(), componenttest.NewNopHost(), tt.TelemetrySettings())
640640
assert.NoError(t, errClient)
@@ -681,7 +681,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
681681

682682
gcs := &ClientConfig{
683683
Endpoint: "unix://" + ln.Addr().String(),
684-
TLSSetting: configtls.TLSClientSetting{
684+
Config: configtls.ClientConfig{
685685
Insecure: true,
686686
},
687687
}
@@ -883,7 +883,7 @@ func TestClientInfoInterceptors(t *testing.T) {
883883
{
884884
gcs := &ClientConfig{
885885
Endpoint: l.Addr().String(),
886-
TLSSetting: configtls.TLSClientSetting{
886+
Config: configtls.ClientConfig{
887887
Insecure: true,
888888
},
889889
}

0 commit comments

Comments
 (0)