Skip to content

Commit b3918e3

Browse files
committed
Use Err prefix for always return error implementation
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 78663f9 commit b3918e3

File tree

4 files changed

+37
-9
lines changed

4 files changed

+37
-9
lines changed

.chloggen/use-err.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: deprecation
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
7+
component: extensionauthtest
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Deprecate NewErrorClient in favor of NewErrClient.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: []
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/confighttp/confighttp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func TestHTTPClientSettingWithAuthConfig(t *testing.T) {
455455
shouldErr: true,
456456
host: &mockHost{
457457
ext: map[component.ID]component.Component{
458-
mockID: extensionauthtest.NewErrorClient(errors.New("error")),
458+
mockID: extensionauthtest.NewErrClient(errors.New("error")),
459459
},
460460
},
461461
},

extension/extensionauth/extensionauthtest/error_client.go renamed to extension/extensionauth/extensionauthtest/err_client.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@ import (
1414
)
1515

1616
var (
17-
_ extension.Extension = (*errorClient)(nil)
18-
_ extensionauth.HTTPClient = (*errorClient)(nil)
19-
_ extensionauth.GRPCClient = (*errorClient)(nil)
17+
_ extension.Extension = (*errClient)(nil)
18+
_ extensionauth.HTTPClient = (*errClient)(nil)
19+
_ extensionauth.GRPCClient = (*errClient)(nil)
2020
)
2121

22-
type errorClient struct {
22+
type errClient struct {
2323
component.StartFunc
2424
component.ShutdownFunc
2525
extensionauth.ClientPerRPCCredentialsFunc
2626
extensionauth.ClientRoundTripperFunc
2727
}
2828

29-
// NewErrorClient returns a new [extension.Extension] that implements the [extensionauth.HTTPClient] and [extensionauth.GRPCClient] and always returns an error on both methods.
30-
func NewErrorClient(err error) extension.Extension {
31-
return &errorClient{
29+
// Deprecated: [v0.125.0] Use NewErrClient.
30+
var NewErrorClient = NewErrClient
31+
32+
// NewErrClient returns a new [extension.Extension] that implements the [extensionauth.HTTPClient] and [extensionauth.GRPCClient] and always returns an error on both methods.
33+
func NewErrClient(err error) extension.Extension {
34+
return &errClient{
3235
ClientRoundTripperFunc: func(http.RoundTripper) (http.RoundTripper, error) {
3336
return nil, err
3437
},

extension/extensionauth/extensionauthtest/error_client_test.go renamed to extension/extensionauth/extensionauthtest/err_client_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func TestErrorClient(t *testing.T) {
16-
client := NewErrorClient(errors.New("error"))
16+
client := NewErrClient(errors.New("error"))
1717

1818
httpClient, ok := client.(extensionauth.HTTPClient)
1919
require.True(t, ok)

0 commit comments

Comments
 (0)