Skip to content

Commit 605011a

Browse files
authored
[confighttp,configgrpc] Rename TLSSetting to TLS (#13115)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Renames `TLSSetting` fields to `TLS`. The name is a historical artifact since the `configtls` had `Setting` in the name before. This is more consistent with the rest. I think if we do this change we should do it alongside other changes to confighttp, to avoid breaking our users multiple times.
1 parent 72878a1 commit 605011a

File tree

17 files changed

+120
-95
lines changed

17 files changed

+120
-95
lines changed

.chloggen/mx-psi_tlssetting.yaml

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: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: confighttp,configgrpc
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: "Rename `ClientConfig.TLSSetting` and `ServerConfig.TLSSetting` to `ClientConfig.TLS` and `ServerConfig.TLS`."
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [13115]
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: [api]

config/configgrpc/client_middleware_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestClientMiddlewareOrdering(t *testing.T) {
114114
// Create client config with middleware extensions
115115
clientConfig := ClientConfig{
116116
Endpoint: addr,
117-
TLSSetting: configtls.ClientConfig{
117+
TLS: configtls.ClientConfig{
118118
Insecure: true,
119119
},
120120
Middlewares: []configmiddleware.Config{
@@ -158,7 +158,7 @@ func TestClientMiddlewareToClientErrors(t *testing.T) {
158158
},
159159
config: ClientConfig{
160160
Endpoint: "localhost:1234",
161-
TLSSetting: configtls.ClientConfig{
161+
TLS: configtls.ClientConfig{
162162
Insecure: true,
163163
},
164164
Middlewares: []configmiddleware.Config{
@@ -178,7 +178,7 @@ func TestClientMiddlewareToClientErrors(t *testing.T) {
178178
},
179179
config: ClientConfig{
180180
Endpoint: "localhost:1234",
181-
TLSSetting: configtls.ClientConfig{
181+
TLS: configtls.ClientConfig{
182182
Insecure: true,
183183
},
184184
Middlewares: []configmiddleware.Config{

config/configgrpc/configgrpc.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ type ClientConfig struct {
7474
// The compression key for supported compression types within collector.
7575
Compression configcompression.Type `mapstructure:"compression,omitempty"`
7676

77-
// TLSSetting struct exposes TLS client configuration.
78-
TLSSetting configtls.ClientConfig `mapstructure:"tls,omitempty"`
77+
// TLS struct exposes TLS client configuration.
78+
TLS configtls.ClientConfig `mapstructure:"tls,omitempty"`
7979

8080
// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
8181
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
@@ -114,7 +114,7 @@ type ClientConfig struct {
114114
// NewDefaultClientConfig returns a new instance of ClientConfig with default values.
115115
func NewDefaultClientConfig() *ClientConfig {
116116
return &ClientConfig{
117-
TLSSetting: configtls.NewDefaultClientConfig(),
117+
TLS: configtls.NewDefaultClientConfig(),
118118
Keepalive: NewDefaultKeepaliveClientConfig(),
119119
BalancerName: BalancerName(),
120120
}
@@ -176,7 +176,7 @@ type ServerConfig struct {
176176

177177
// Configures the protocol to use TLS.
178178
// The default value is nil, which will cause the protocol to not use TLS.
179-
TLSSetting *configtls.ServerConfig `mapstructure:"tls,omitempty"`
179+
TLS *configtls.ServerConfig `mapstructure:"tls,omitempty"`
180180

181181
// MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server.
182182
MaxRecvMsgSizeMiB int `mapstructure:"max_recv_msg_size_mib,omitempty"`
@@ -306,7 +306,7 @@ func (gcs *ClientConfig) getGrpcDialOptions(
306306
opts = append(opts, grpc.WithDefaultCallOptions(grpc.UseCompressor(cp)))
307307
}
308308

309-
tlsCfg, err := gcs.TLSSetting.LoadTLSConfig(ctx)
309+
tlsCfg, err := gcs.TLS.LoadTLSConfig(ctx)
310310
if err != nil {
311311
return nil, err
312312
}
@@ -451,8 +451,8 @@ func (gss *ServerConfig) getGrpcServerOptions(
451451
) ([]grpc.ServerOption, error) {
452452
var opts []grpc.ServerOption
453453

454-
if gss.TLSSetting != nil {
455-
tlsCfg, err := gss.TLSSetting.LoadTLSConfig(context.Background())
454+
if gss.TLS != nil {
455+
tlsCfg, err := gss.TLS.LoadTLSConfig(context.Background())
456456
if err != nil {
457457
return nil, err
458458
}

config/configgrpc/configgrpc_test.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestNewDefaultKeepaliveClientConfig(t *testing.T) {
6161

6262
func TestNewDefaultClientConfig(t *testing.T) {
6363
expected := &ClientConfig{
64-
TLSSetting: configtls.NewDefaultClientConfig(),
64+
TLS: configtls.NewDefaultClientConfig(),
6565
Keepalive: NewDefaultKeepaliveClientConfig(),
6666
BalancerName: BalancerName(),
6767
}
@@ -113,22 +113,22 @@ var (
113113

114114
func TestDefaultGrpcClientSettings(t *testing.T) {
115115
gcs := &ClientConfig{
116-
TLSSetting: configtls.ClientConfig{
116+
TLS: configtls.ClientConfig{
117117
Insecure: true,
118118
},
119119
}
120120
opts, err := gcs.getGrpcDialOptions(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings(), []ToClientConnOption{})
121121
require.NoError(t, err)
122122
/* Expecting 2 DialOptions:
123-
* - WithTransportCredentials (TLSSetting)
123+
* - WithTransportCredentials (TLS)
124124
* - WithStatsHandler (always, for self-telemetry)
125125
*/
126126
assert.Len(t, opts, 2)
127127
}
128128

129129
func TestGrpcClientExtraOption(t *testing.T) {
130130
gcs := &ClientConfig{
131-
TLSSetting: configtls.ClientConfig{
131+
TLS: configtls.ClientConfig{
132132
Insecure: true,
133133
},
134134
}
@@ -141,7 +141,7 @@ func TestGrpcClientExtraOption(t *testing.T) {
141141
)
142142
require.NoError(t, err)
143143
/* Expecting 3 DialOptions:
144-
* - WithTransportCredentials (TLSSetting)
144+
* - WithTransportCredentials (TLS)
145145
* - WithStatsHandler (always, for self-telemetry)
146146
* - extraOpt
147147
*/
@@ -163,7 +163,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
163163
},
164164
Endpoint: "localhost:1234",
165165
Compression: configcompression.TypeGzip,
166-
TLSSetting: configtls.ClientConfig{
166+
TLS: configtls.ClientConfig{
167167
Insecure: false,
168168
},
169169
Keepalive: &KeepaliveClientConfig{
@@ -192,7 +192,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
192192
},
193193
Endpoint: "localhost:1234",
194194
Compression: configcompression.TypeSnappy,
195-
TLSSetting: configtls.ClientConfig{
195+
TLS: configtls.ClientConfig{
196196
Insecure: false,
197197
},
198198
Keepalive: &KeepaliveClientConfig{
@@ -221,7 +221,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
221221
},
222222
Endpoint: "localhost:1234",
223223
Compression: configcompression.TypeZstd,
224-
TLSSetting: configtls.ClientConfig{
224+
TLS: configtls.ClientConfig{
225225
Insecure: false,
226226
},
227227
Keepalive: &KeepaliveClientConfig{
@@ -249,7 +249,7 @@ func TestAllGrpcClientSettings(t *testing.T) {
249249
require.NoError(t, err)
250250
/* Expecting 11 DialOptions:
251251
* - WithDefaultCallOptions (Compression)
252-
* - WithTransportCredentials (TLSSetting)
252+
* - WithTransportCredentials (TLS)
253253
* - WithDefaultServiceConfig (BalancerName)
254254
* - WithAuthority (Authority)
255255
* - WithStatsHandler (always, for self-telemetry)
@@ -277,7 +277,7 @@ func TestHeaders(t *testing.T) {
277277
// Create client and send request to server with headers
278278
resp, errResp := sendTestRequest(t, ClientConfig{
279279
Endpoint: addr,
280-
TLSSetting: configtls.ClientConfig{
280+
TLS: configtls.ClientConfig{
281281
Insecure: true,
282282
},
283283
Headers: map[string]configopaque.String{
@@ -380,7 +380,7 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
380380
Endpoint: "localhost:1234",
381381
Transport: confignet.TransportTypeTCP,
382382
},
383-
TLSSetting: &configtls.ServerConfig{
383+
TLS: &configtls.ServerConfig{
384384
Config: configtls.Config{},
385385
ClientCAFile: "",
386386
},
@@ -434,7 +434,7 @@ func TestGrpcClientConfigInvalidBalancer(t *testing.T) {
434434
},
435435
Endpoint: "localhost:1234",
436436
Compression: "gzip",
437-
TLSSetting: configtls.ClientConfig{
437+
TLS: configtls.ClientConfig{
438438
Insecure: false,
439439
},
440440
Keepalive: &KeepaliveClientConfig{
@@ -462,7 +462,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
462462
Headers: nil,
463463
Endpoint: "",
464464
Compression: "",
465-
TLSSetting: configtls.ClientConfig{
465+
TLS: configtls.ClientConfig{
466466
Config: configtls.Config{
467467
CAFile: "/doesnt/exist",
468468
},
@@ -478,7 +478,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
478478
Headers: nil,
479479
Endpoint: "",
480480
Compression: "",
481-
TLSSetting: configtls.ClientConfig{
481+
TLS: configtls.ClientConfig{
482482
Config: configtls.Config{
483483
CertFile: "/doesnt/exist",
484484
},
@@ -508,7 +508,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
508508
err: "unsupported compression type \"zlib\"",
509509
settings: ClientConfig{
510510
Endpoint: "localhost:1234",
511-
TLSSetting: configtls.ClientConfig{
511+
TLS: configtls.ClientConfig{
512512
Insecure: true,
513513
},
514514
Compression: "zlib",
@@ -519,7 +519,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
519519
err: "unsupported compression type \"deflate\"",
520520
settings: ClientConfig{
521521
Endpoint: "localhost:1234",
522-
TLSSetting: configtls.ClientConfig{
522+
TLS: configtls.ClientConfig{
523523
Insecure: true,
524524
},
525525
Compression: "deflate",
@@ -530,7 +530,7 @@ func TestGRPCClientSettingsError(t *testing.T) {
530530
err: "unsupported compression type \"bad\"",
531531
settings: ClientConfig{
532532
Endpoint: "localhost:1234",
533-
TLSSetting: configtls.ClientConfig{
533+
TLS: configtls.ClientConfig{
534534
Insecure: true,
535535
},
536536
Compression: "bad",
@@ -553,7 +553,7 @@ func TestUseSecure(t *testing.T) {
553553
Headers: nil,
554554
Endpoint: "",
555555
Compression: "",
556-
TLSSetting: configtls.ClientConfig{},
556+
TLS: configtls.ClientConfig{},
557557
Keepalive: nil,
558558
}
559559
dialOpts, err := gcs.getGrpcDialOptions(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings(), []ToClientConnOption{})
@@ -573,7 +573,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
573573
Endpoint: "127.0.0.1:1234",
574574
Transport: confignet.TransportTypeTCP,
575575
},
576-
TLSSetting: &configtls.ServerConfig{
576+
TLS: &configtls.ServerConfig{
577577
Config: configtls.Config{
578578
CAFile: "/doesnt/exist",
579579
},
@@ -587,7 +587,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
587587
Endpoint: "127.0.0.1:1234",
588588
Transport: confignet.TransportTypeTCP,
589589
},
590-
TLSSetting: &configtls.ServerConfig{
590+
TLS: &configtls.ServerConfig{
591591
Config: configtls.Config{
592592
CertFile: "/doesnt/exist",
593593
},
@@ -601,7 +601,7 @@ func TestGRPCServerSettingsError(t *testing.T) {
601601
Endpoint: "127.0.0.1:1234",
602602
Transport: confignet.TransportTypeTCP,
603603
},
604-
TLSSetting: &configtls.ServerConfig{
604+
TLS: &configtls.ServerConfig{
605605
ClientCAFile: "/doesnt/exist",
606606
},
607607
},
@@ -738,13 +738,13 @@ func TestHttpReception(t *testing.T) {
738738
Endpoint: "localhost:0",
739739
Transport: confignet.TransportTypeTCP,
740740
},
741-
TLSSetting: test.tlsServerCreds,
741+
TLS: test.tlsServerCreds,
742742
})
743743
defer s.Stop()
744744

745745
resp, errResp := sendTestRequest(t, ClientConfig{
746-
Endpoint: addr,
747-
TLSSetting: *test.tlsClientCreds,
746+
Endpoint: addr,
747+
TLS: *test.tlsClientCreds,
748748
})
749749
if test.hasError {
750750
require.Error(t, errResp)
@@ -772,7 +772,7 @@ func TestReceiveOnUnixDomainSocket(t *testing.T) {
772772

773773
resp, errResp := sendTestRequest(t, ClientConfig{
774774
Endpoint: "unix://" + addr,
775-
TLSSetting: configtls.ClientConfig{
775+
TLS: configtls.ClientConfig{
776776
Insecure: true,
777777
},
778778
})
@@ -955,7 +955,7 @@ func TestClientInfoInterceptors(t *testing.T) {
955955
{
956956
resp, errResp := sendTestRequest(t, ClientConfig{
957957
Endpoint: addr,
958-
TLSSetting: configtls.ClientConfig{
958+
TLS: configtls.ClientConfig{
959959
Insecure: true,
960960
},
961961
})

config/configgrpc/server_middleware_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestGrpcServerUnaryInterceptor(t *testing.T) {
9191
// Send a request to trigger the interceptors
9292
resp, errResp := sendTestRequest(t, ClientConfig{
9393
Endpoint: addr,
94-
TLSSetting: configtls.ClientConfig{
94+
TLS: configtls.ClientConfig{
9595
Insecure: true,
9696
},
9797
})

config/confighttp/confighttp.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ type ClientConfig struct {
5353
// ProxyURL setting for the collector
5454
ProxyURL string `mapstructure:"proxy_url,omitempty"`
5555

56-
// TLSSetting struct exposes TLS client configuration.
57-
TLSSetting configtls.ClientConfig `mapstructure:"tls,omitempty"`
56+
// TLS struct exposes TLS client configuration.
57+
TLS configtls.ClientConfig `mapstructure:"tls,omitempty"`
5858

5959
// ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize.
6060
// Default is 0.
@@ -164,7 +164,7 @@ type ToClientOption interface {
164164

165165
// ToClient creates an HTTP client.
166166
func (hcs *ClientConfig) ToClient(ctx context.Context, host component.Host, settings component.TelemetrySettings, _ ...ToClientOption) (*http.Client, error) {
167-
tlsCfg, err := hcs.TLSSetting.LoadTLSConfig(ctx)
167+
tlsCfg, err := hcs.TLS.LoadTLSConfig(ctx)
168168
if err != nil {
169169
return nil, err
170170
}
@@ -314,8 +314,8 @@ type ServerConfig struct {
314314
// Endpoint configures the listening address for the server.
315315
Endpoint string `mapstructure:"endpoint,omitempty"`
316316

317-
// TLSSetting struct exposes TLS client configuration.
318-
TLSSetting *configtls.ServerConfig `mapstructure:"tls"`
317+
// TLS struct exposes TLS client configuration.
318+
TLS *configtls.ServerConfig `mapstructure:"tls"`
319319

320320
// CORS configures the server for HTTP cross-origin resource sharing (CORS).
321321
CORS *CORSConfig `mapstructure:"cors"`
@@ -403,9 +403,9 @@ func (hss *ServerConfig) ToListener(ctx context.Context) (net.Listener, error) {
403403
return nil, err
404404
}
405405

406-
if hss.TLSSetting != nil {
406+
if hss.TLS != nil {
407407
var tlsCfg *tls.Config
408-
tlsCfg, err = hss.TLSSetting.LoadTLSConfig(ctx)
408+
tlsCfg, err = hss.TLS.LoadTLSConfig(ctx)
409409
if err != nil {
410410
return nil, err
411411
}

0 commit comments

Comments
 (0)