Skip to content

Commit d0a0b36

Browse files
committed
[extensionauth,configauth] Remove deprecated symbols
1 parent e529b31 commit d0a0b36

File tree

16 files changed

+77
-446
lines changed

16 files changed

+77
-446
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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: extensionauth, configauth
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove deprecated types and functions from `extensionauth` and `configauth` packages.
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [12672]
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+
This includes:
20+
- `extensionauth.NewClient`,
21+
- `extensionauth.ClientOption` and all its implementations,
22+
- `extensionauth.NewServer`,
23+
- `extensionauth.ServerOption` and all its implementations and
24+
- `configauth.Authenticator.GetClientAuthenticator`.
25+
26+
# Optional: The change log or logs in which this entry should be included.
27+
# e.g. '[user]' or '[user, api]'
28+
# Include 'user' if the change is relevant to end users.
29+
# Include 'api' if there is a change to a library API.
30+
# Default: '[user]'
31+
change_logs: [api]

config/configauth/configauth.go

-14
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
var (
1919
errAuthenticatorNotFound = errors.New("authenticator not found")
20-
errNotClient = errors.New("requested authenticator is not a client authenticator")
2120
errNotHTTPClient = errors.New("requested authenticator is not a HTTP client authenticator")
2221
errNotGRPCClient = errors.New("requested authenticator is not a gRPC client authenticator")
2322
errNotServer = errors.New("requested authenticator is not a server authenticator")
@@ -42,19 +41,6 @@ func (a Authentication) GetServerAuthenticator(_ context.Context, extensions map
4241
return nil, fmt.Errorf("failed to resolve authenticator %q: %w", a.AuthenticatorID, errAuthenticatorNotFound)
4342
}
4443

45-
// GetClientAuthenticator attempts to select the appropriate extensionauth.Client from the list of extensions,
46-
// based on the component id of the extension. If an authenticator is not found, an error is returned.
47-
// Deprecated: [v0.122.0] Use GetHTTPClientAuthenticator or GetGRPCClientAuthenticator instead.
48-
func (a Authentication) GetClientAuthenticator(_ context.Context, extensions map[component.ID]component.Component) (extensionauth.Client, error) {
49-
if ext, found := extensions[a.AuthenticatorID]; found {
50-
if client, ok := ext.(extensionauth.Client); ok {
51-
return client, nil
52-
}
53-
return nil, errNotClient
54-
}
55-
return nil, fmt.Errorf("failed to resolve authenticator %q: %w", a.AuthenticatorID, errAuthenticatorNotFound)
56-
}
57-
5844
// GetHTTPClientAuthenticator attempts to select the appropriate extensionauth.Client from the list of extensions,
5945
// based on the component id of the extension. If an authenticator is not found, an error is returned.
6046
// This should be only used by HTTP clients.

config/configauth/configauth_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestGetServerFails(t *testing.T) {
6868
assert.Nil(t, authenticator)
6969
}
7070

71-
func TestGetClient(t *testing.T) {
71+
func TestGetHTTPClient(t *testing.T) {
7272
testCases := []struct {
7373
name string
7474
authenticator extension.Extension
@@ -109,7 +109,7 @@ func TestGetClient(t *testing.T) {
109109
}
110110
}
111111

112-
func TestGetClientFails(t *testing.T) {
112+
func TestGetGRPCClientFails(t *testing.T) {
113113
cfg := &Authentication{
114114
AuthenticatorID: component.MustNewID("does_not_exist"),
115115
}

config/configauth/go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ replace go.opentelemetry.io/collector/pdata => ../../pdata
3434

3535
replace go.opentelemetry.io/collector/component => ../../component
3636

37-
replace go.opentelemetry.io/collector/component/componenttest => ../../component/componenttest
38-
3937
replace go.opentelemetry.io/collector/extension => ../../extension
4038

4139
replace go.opentelemetry.io/collector/extension/extensionauth => ../../extension/extensionauth

config/configauth/go.sum

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/confighttp/confighttp_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type mockAuthServer struct {
4646
extensionauth.ServerAuthenticateFunc
4747
}
4848

49-
func newMockAuthServer(auth func(ctx context.Context, sources map[string][]string) (context.Context, error)) extensionauth.Server {
49+
func newMockAuthServer(auth func(ctx context.Context, sources map[string][]string) (context.Context, error)) extension.Extension {
5050
return &mockAuthServer{ServerAuthenticateFunc: auth}
5151
}
5252

config/confighttp/xconfighttp/go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ require (
3131
go.opentelemetry.io/collector/config/configcompression v1.28.1 // indirect
3232
go.opentelemetry.io/collector/config/configopaque v1.28.1 // indirect
3333
go.opentelemetry.io/collector/config/configtls v1.28.1 // indirect
34-
go.opentelemetry.io/collector/extension v1.28.1 // indirect
3534
go.opentelemetry.io/collector/extension/extensionauth v0.122.1 // indirect
3635
go.opentelemetry.io/collector/pdata v1.28.1 // indirect
3736
go.opentelemetry.io/otel v1.35.0 // indirect

extension/extensionauth/client.go

-99
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,8 @@ import (
77
"net/http"
88

99
"google.golang.org/grpc/credentials"
10-
11-
"go.opentelemetry.io/collector/component"
12-
"go.opentelemetry.io/collector/extension"
1310
)
1411

15-
// Client is an optional Extension interface that can be used as an HTTP and gRPC authenticator for the configauth.Authentication option.
16-
// Authenticators are then included as part of OpenTelemetry Collector builds and can be referenced by their
17-
// names from the Authentication configuration.
18-
// Deprecated: [v0.122.0] Assert the use of HTTPClient and GRPCClient interfaces instead.
19-
type Client interface {
20-
extension.Extension
21-
HTTPClient
22-
GRPCClient
23-
}
24-
2512
// HTTPClient is an optional Extension interface that can be used as an HTTP authenticator for the configauth.Authentication option.
2613
// Authenticators are then included as part of OpenTelemetry Collector builds and can be referenced by their
2714
// names from the Authentication configuration.
@@ -38,18 +25,6 @@ type GRPCClient interface {
3825
PerRPCCredentials() (credentials.PerRPCCredentials, error)
3926
}
4027

41-
// ClientOption represents the possible options for NewClient.
42-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
43-
type ClientOption interface {
44-
apply(*defaultClient)
45-
}
46-
47-
type clientOptionFunc func(*defaultClient)
48-
49-
func (of clientOptionFunc) apply(e *defaultClient) {
50-
of(e)
51-
}
52-
5328
var _ HTTPClient = (*ClientRoundTripperFunc)(nil)
5429

5530
// ClientRoundTripperFunc specifies the function that returns a RoundTripper that can be used to authenticate HTTP requests.
@@ -73,77 +48,3 @@ func (f ClientPerRPCCredentialsFunc) PerRPCCredentials() (credentials.PerRPCCred
7348
}
7449
return f()
7550
}
76-
77-
var _ Client = (*defaultClient)(nil)
78-
79-
type defaultClient struct {
80-
component.StartFunc
81-
component.ShutdownFunc
82-
clientRoundTripperFunc ClientRoundTripperFunc
83-
clientPerRPCCredentialsFunc ClientPerRPCCredentialsFunc
84-
}
85-
86-
// PerRPCCredentials implements Client.
87-
func (d *defaultClient) PerRPCCredentials() (credentials.PerRPCCredentials, error) {
88-
if d.clientPerRPCCredentialsFunc == nil {
89-
return nil, nil
90-
}
91-
return d.clientPerRPCCredentialsFunc()
92-
}
93-
94-
// RoundTripper implements Client.
95-
func (d *defaultClient) RoundTripper(base http.RoundTripper) (http.RoundTripper, error) {
96-
if d.clientRoundTripperFunc == nil {
97-
return base, nil
98-
}
99-
return d.clientRoundTripperFunc(base)
100-
}
101-
102-
// WithClientStart overrides the default `Start` function for a component.Component.
103-
// The default always returns nil.
104-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
105-
func WithClientStart(startFunc component.StartFunc) ClientOption {
106-
return clientOptionFunc(func(o *defaultClient) {
107-
o.StartFunc = startFunc
108-
})
109-
}
110-
111-
// WithClientShutdown overrides the default `Shutdown` function for a component.Component.
112-
// The default always returns nil.
113-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
114-
func WithClientShutdown(shutdownFunc component.ShutdownFunc) ClientOption {
115-
return clientOptionFunc(func(o *defaultClient) {
116-
o.ShutdownFunc = shutdownFunc
117-
})
118-
}
119-
120-
// WithClientRoundTripper provides a `RoundTripper` function for this client authenticator.
121-
// The default round tripper is no-op.
122-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
123-
func WithClientRoundTripper(roundTripperFunc ClientRoundTripperFunc) ClientOption {
124-
return clientOptionFunc(func(o *defaultClient) {
125-
o.clientRoundTripperFunc = roundTripperFunc
126-
})
127-
}
128-
129-
// WithClientPerRPCCredentials provides a `PerRPCCredentials` function for this client authenticator.
130-
// There's no default.
131-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
132-
func WithClientPerRPCCredentials(perRPCCredentialsFunc ClientPerRPCCredentialsFunc) ClientOption {
133-
return clientOptionFunc(func(o *defaultClient) {
134-
o.clientPerRPCCredentialsFunc = perRPCCredentialsFunc
135-
})
136-
}
137-
138-
// NewClient returns a Client configured with the provided options.
139-
// Deprecated: [v0.122.0] This type is deprecated and will be removed in the next release.
140-
// Manually implement the [HTTPClient] and/or [GRPCClient] interfaces instead.
141-
func NewClient(options ...ClientOption) (Client, error) {
142-
bc := &defaultClient{}
143-
144-
for _, op := range options {
145-
op.apply(bc)
146-
}
147-
148-
return bc, nil
149-
}

extension/extensionauth/client_test.go

+14-86
Original file line numberDiff line numberDiff line change
@@ -11,87 +11,19 @@ import (
1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
1313
"google.golang.org/grpc/credentials"
14-
15-
"go.opentelemetry.io/collector/component"
16-
"go.opentelemetry.io/collector/component/componenttest"
1714
)
1815

19-
func TestClientDefaultValues(t *testing.T) {
20-
// prepare
21-
e, err := NewClient()
22-
require.NoError(t, err)
23-
24-
// test
25-
t.Run("start", func(t *testing.T) {
26-
err := e.Start(context.Background(), componenttest.NewNopHost())
27-
assert.NoError(t, err)
28-
})
29-
30-
t.Run("roundtripper", func(t *testing.T) {
31-
ctx, err := e.RoundTripper(http.DefaultTransport)
32-
assert.NotNil(t, ctx)
33-
assert.NoError(t, err)
34-
})
35-
36-
t.Run("per-rpc-credentials", func(t *testing.T) {
37-
p, err := e.PerRPCCredentials()
38-
assert.Nil(t, p)
39-
assert.NoError(t, err)
40-
})
41-
42-
t.Run("shutdown", func(t *testing.T) {
43-
err := e.Shutdown(context.Background())
44-
assert.NoError(t, err)
45-
})
46-
}
47-
48-
func TestWithClientStart(t *testing.T) {
49-
called := false
50-
e, err := NewClient(WithClientStart(func(context.Context, component.Host) error {
51-
called = true
52-
return nil
53-
}))
54-
require.NoError(t, err)
55-
56-
// test
57-
err = e.Start(context.Background(), componenttest.NewNopHost())
58-
59-
// verify
60-
assert.True(t, called)
61-
assert.NoError(t, err)
62-
}
63-
64-
func TestWithClientShutdown(t *testing.T) {
65-
called := false
66-
e, err := NewClient(WithClientShutdown(func(context.Context) error {
67-
called = true
68-
return nil
69-
}))
70-
require.NoError(t, err)
71-
72-
// test
73-
err = e.Shutdown(context.Background())
74-
75-
// verify
76-
assert.True(t, called)
77-
assert.NoError(t, err)
78-
}
79-
80-
func TestWithClientRoundTripper(t *testing.T) {
81-
called := false
82-
e, err := NewClient(WithClientRoundTripper(func(base http.RoundTripper) (http.RoundTripper, error) {
16+
func TestRoundTripperFunc(t *testing.T) {
17+
var called bool
18+
var httpClient HTTPClient = ClientRoundTripperFunc(func(base http.RoundTripper) (http.RoundTripper, error) {
8319
called = true
8420
return base, nil
85-
}))
86-
require.NoError(t, err)
87-
88-
// test
89-
rt, err := e.RoundTripper(http.DefaultTransport)
21+
})
9022

91-
// verify
23+
rt, err := httpClient.RoundTripper(http.DefaultTransport)
24+
require.NoError(t, err)
9225
assert.True(t, called)
93-
assert.NotNil(t, rt)
94-
assert.NoError(t, err)
26+
assert.Equal(t, http.DefaultTransport, rt)
9527
}
9628

9729
type customPerRPCCredentials struct{}
@@ -106,19 +38,15 @@ func (c *customPerRPCCredentials) RequireTransportSecurity() bool {
10638
return true
10739
}
10840

109-
func TestWithPerRPCCredentials(t *testing.T) {
110-
called := false
111-
e, err := NewClient(WithClientPerRPCCredentials(func() (credentials.PerRPCCredentials, error) {
41+
func TestWithPerRPCCredentialsFunc(t *testing.T) {
42+
var called bool
43+
var grpcClient GRPCClient = ClientPerRPCCredentialsFunc(func() (credentials.PerRPCCredentials, error) {
11244
called = true
11345
return &customPerRPCCredentials{}, nil
114-
}))
115-
require.NoError(t, err)
116-
117-
// test
118-
p, err := e.PerRPCCredentials()
46+
})
11947

120-
// verify
48+
creds, err := grpcClient.PerRPCCredentials()
49+
require.NoError(t, err)
12150
assert.True(t, called)
122-
assert.NotNil(t, p)
123-
assert.NoError(t, err)
51+
assert.NotNil(t, creds)
12452
}

extension/extensionauth/extensionauthtest/go.mod

-2
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,3 @@ replace go.opentelemetry.io/collector/component => ../../../component
3636
replace go.opentelemetry.io/collector/pdata => ../../../pdata
3737

3838
replace go.opentelemetry.io/collector/extension => ../..
39-
40-
replace go.opentelemetry.io/collector/component/componenttest => ../../../component/componenttest

0 commit comments

Comments
 (0)