Skip to content

Commit 239928d

Browse files
authored
Merge branch 'main' into renovate/all-golang.orgx-packages
2 parents 81b83d3 + 2a81bd0 commit 239928d

File tree

6 files changed

+61
-37
lines changed

6 files changed

+61
-37
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: configgrpc
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Update optional fields to use `configoptional.Optional` field for optional values.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [13252, 13364]
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+
Specifically, the following fields have been updated to `configoptional`:
20+
- `KeepaliveServerConfig.ServerParameters` (`KeepaliveServerParameters` type)
21+
- `KeepaliveServerConfig.EnforcementPolicy` (`KeepaliveEnforcementPolicy` type)
22+
23+
# Optional: The change log or logs in which this entry should be included.
24+
# e.g. '[user]' or '[user, api]'
25+
# Include 'user' if the change is relevant to end users.
26+
# Include 'api' if there is a change to a library API.
27+
# Default: '[user]'
28+
change_logs: [api]

config/configgrpc/configgrpc.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ type ClientConfig struct {
112112
Middlewares []configmiddleware.Config `mapstructure:"middlewares,omitempty"`
113113
}
114114

115-
func ptr[T any](v T) *T {
116-
return &v
117-
}
118-
119115
// NewDefaultClientConfig returns a new instance of ClientConfig with default values.
120116
func NewDefaultClientConfig() ClientConfig {
121117
return ClientConfig{
@@ -127,17 +123,17 @@ func NewDefaultClientConfig() ClientConfig {
127123

128124
// KeepaliveServerConfig is the configuration for keepalive.
129125
type KeepaliveServerConfig struct {
130-
ServerParameters *KeepaliveServerParameters `mapstructure:"server_parameters,omitempty"`
131-
EnforcementPolicy *KeepaliveEnforcementPolicy `mapstructure:"enforcement_policy,omitempty"`
126+
ServerParameters configoptional.Optional[KeepaliveServerParameters] `mapstructure:"server_parameters,omitempty"`
127+
EnforcementPolicy configoptional.Optional[KeepaliveEnforcementPolicy] `mapstructure:"enforcement_policy,omitempty"`
132128
// prevent unkeyed literal initialization
133129
_ struct{}
134130
}
135131

136132
// NewDefaultKeepaliveServerConfig returns a new instance of KeepaliveServerConfig with default values.
137133
func NewDefaultKeepaliveServerConfig() KeepaliveServerConfig {
138134
return KeepaliveServerConfig{
139-
ServerParameters: ptr(NewDefaultKeepaliveServerParameters()),
140-
EnforcementPolicy: ptr(NewDefaultKeepaliveEnforcementPolicy()),
135+
ServerParameters: configoptional.Some(NewDefaultKeepaliveServerParameters()),
136+
EnforcementPolicy: configoptional.Some(NewDefaultKeepaliveEnforcementPolicy()),
141137
}
142138
}
143139

@@ -487,8 +483,8 @@ func (gss *ServerConfig) getGrpcServerOptions(
487483
// https://github.com/grpc/grpc-go/blob/120728e1f775e40a2a764341939b78d666b08260/internal/transport/http2_server.go#L184-L200
488484
if gss.Keepalive.HasValue() {
489485
keepaliveConfig := gss.Keepalive.Get()
490-
if keepaliveConfig.ServerParameters != nil {
491-
svrParams := keepaliveConfig.ServerParameters
486+
if keepaliveConfig.ServerParameters.HasValue() {
487+
svrParams := keepaliveConfig.ServerParameters.Get()
492488
opts = append(opts, grpc.KeepaliveParams(keepalive.ServerParameters{
493489
MaxConnectionIdle: svrParams.MaxConnectionIdle,
494490
MaxConnectionAge: svrParams.MaxConnectionAge,
@@ -501,8 +497,8 @@ func (gss *ServerConfig) getGrpcServerOptions(
501497
// to apply them over zero/nil values before passing these as grpc.ServerOptions.
502498
// The following shows the server code for applying default grpc.ServerOptions.
503499
// https://github.com/grpc/grpc-go/blob/120728e1f775e40a2a764341939b78d666b08260/internal/transport/http2_server.go#L202-L205
504-
if keepaliveConfig.EnforcementPolicy != nil {
505-
enfPol := keepaliveConfig.EnforcementPolicy
500+
if keepaliveConfig.EnforcementPolicy.HasValue() {
501+
enfPol := keepaliveConfig.EnforcementPolicy.Get()
506502
opts = append(opts, grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
507503
MinTime: enfPol.MinTime,
508504
PermitWithoutStream: enfPol.PermitWithoutStream,

config/configgrpc/configgrpc_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ func TestNewDefaultKeepaliveEnforcementPolicy(t *testing.T) {
9090

9191
func TestNewDefaultKeepaliveServerConfig(t *testing.T) {
9292
expected := KeepaliveServerConfig{
93-
ServerParameters: ptr(NewDefaultKeepaliveServerParameters()),
94-
EnforcementPolicy: ptr(NewDefaultKeepaliveEnforcementPolicy()),
93+
ServerParameters: configoptional.Some(NewDefaultKeepaliveServerParameters()),
94+
EnforcementPolicy: configoptional.Some(NewDefaultKeepaliveEnforcementPolicy()),
9595
}
9696
result := NewDefaultKeepaliveServerConfig()
9797
assert.Equal(t, expected, result)
@@ -391,17 +391,17 @@ func TestAllGrpcServerSettingsExceptAuth(t *testing.T) {
391391
ReadBufferSize: 1024,
392392
WriteBufferSize: 1024,
393393
Keepalive: configoptional.Some(KeepaliveServerConfig{
394-
ServerParameters: &KeepaliveServerParameters{
394+
ServerParameters: configoptional.Some(KeepaliveServerParameters{
395395
MaxConnectionIdle: time.Second,
396396
MaxConnectionAge: time.Second,
397397
MaxConnectionAgeGrace: time.Second,
398398
Time: time.Second,
399399
Timeout: time.Second,
400-
},
401-
EnforcementPolicy: &KeepaliveEnforcementPolicy{
400+
}),
401+
EnforcementPolicy: configoptional.Some(KeepaliveEnforcementPolicy{
402402
MinTime: time.Second,
403403
PermitWithoutStream: true,
404-
},
404+
}),
405405
}),
406406
}
407407
opts, err := gss.getGrpcServerOptions(context.Background(), componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings(), []ToServerOption{})

internal/tools/go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ toolchain go1.24.0
77
require (
88
github.com/a8m/envsubst v1.4.3
99
github.com/client9/misspell v0.3.4
10-
github.com/golangci/golangci-lint/v2 v2.2.1
10+
github.com/golangci/golangci-lint/v2 v2.2.2
1111
github.com/google/addlicense v1.1.1
1212
github.com/jcchavezs/porto v0.7.0
1313
github.com/pavius/impi v0.0.3
@@ -32,7 +32,7 @@ require (
3232
dario.cat/mergo v1.0.1 // indirect
3333
github.com/4meepo/tagalign v1.4.2 // indirect
3434
github.com/Abirdcfly/dupword v0.1.6 // indirect
35-
github.com/AlwxSin/noinlineerr v1.0.3 // indirect
35+
github.com/AlwxSin/noinlineerr v1.0.4 // indirect
3636
github.com/Antonboom/errname v1.1.0 // indirect
3737
github.com/Antonboom/nilnil v1.1.0 // indirect
3838
github.com/Antonboom/testifylint v1.6.1 // indirect
@@ -43,7 +43,7 @@ require (
4343
github.com/Microsoft/go-winio v0.6.2 // indirect
4444
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
4545
github.com/ProtonMail/go-crypto v1.2.0 // indirect
46-
github.com/alecthomas/chroma/v2 v2.18.0 // indirect
46+
github.com/alecthomas/chroma/v2 v2.19.0 // indirect
4747
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
4848
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
4949
github.com/alexkohler/prealloc v1.0.0 // indirect
@@ -236,10 +236,10 @@ require (
236236
go.uber.org/zap v1.27.0 // indirect
237237
golang.org/x/crypto v0.39.0 // indirect
238238
golang.org/x/exp/typeparams v0.0.0-20250210185358-939b2ce775ac // indirect
239-
golang.org/x/mod v0.25.0 // indirect
239+
golang.org/x/mod v0.26.0 // indirect
240240
golang.org/x/net v0.41.0 // indirect
241241
golang.org/x/sync v0.15.0 // indirect
242-
golang.org/x/sys v0.33.0 // indirect
242+
golang.org/x/sys v0.34.0 // indirect
243243
golang.org/x/telemetry v0.0.0-20240522233618-39ace7a40ae7 // indirect
244244
golang.org/x/term v0.32.0 // indirect
245245
golang.org/x/text v0.26.0 // indirect

internal/tools/go.sum

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

receiver/otlpreceiver/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,17 @@ func TestUnmarshalConfig(t *testing.T) {
122122
ReadBufferSize: 1024,
123123
WriteBufferSize: 1024,
124124
Keepalive: configoptional.Some(configgrpc.KeepaliveServerConfig{
125-
ServerParameters: &configgrpc.KeepaliveServerParameters{
125+
ServerParameters: configoptional.Some(configgrpc.KeepaliveServerParameters{
126126
MaxConnectionIdle: 11 * time.Second,
127127
MaxConnectionAge: 12 * time.Second,
128128
MaxConnectionAgeGrace: 13 * time.Second,
129129
Time: 30 * time.Second,
130130
Timeout: 5 * time.Second,
131-
},
132-
EnforcementPolicy: &configgrpc.KeepaliveEnforcementPolicy{
131+
}),
132+
EnforcementPolicy: configoptional.Some(configgrpc.KeepaliveEnforcementPolicy{
133133
MinTime: 10 * time.Second,
134134
PermitWithoutStream: true,
135-
},
135+
}),
136136
}),
137137
}),
138138
HTTP: configoptional.Some(HTTPConfig{

0 commit comments

Comments
 (0)