@@ -127,17 +127,27 @@ func NewClusterAwareAPIReader(config *rest.Config, opts client.Options) (client.
127
127
// ...
128
128
// }
129
129
func NewClusterAwareClient (config * rest.Config , opts client.Options ) (client.Client , error ) {
130
+ opts , err := applyClientOptions (config , opts )
131
+ if err != nil {
132
+ return nil , err
133
+ }
134
+
135
+ return client .New (config , opts )
136
+ }
137
+
138
+ func applyClientOptions (config * rest.Config , opts client.Options ) (client.Options , error ) {
130
139
if opts .HTTPClient == nil {
131
140
httpClient , err := NewClusterAwareHTTPClient (config )
132
141
if err != nil {
133
- return nil , err
142
+ return opts , err
134
143
}
135
144
opts .HTTPClient = httpClient
136
145
}
137
146
if opts .Mapper == nil && opts .MapperWithContext == nil {
138
147
opts .MapperWithContext = NewClusterAwareMapperProvider (config , opts .HTTPClient )
139
148
}
140
- return client .New (config , opts )
149
+
150
+ return opts , nil
141
151
}
142
152
143
153
// NewClusterAwareHTTPClient returns an http.Client with a cluster aware round tripper.
@@ -151,6 +161,15 @@ func NewClusterAwareHTTPClient(config *rest.Config) (*http.Client, error) {
151
161
return httpClient , nil
152
162
}
153
163
164
+ func NewClusterAwareClientWithWatch (config * rest.Config , options client.Options ) (client.WithWatch , error ) {
165
+ opts , err := applyClientOptions (config , options )
166
+ if err != nil {
167
+ return nil , err
168
+ }
169
+
170
+ return client .NewWithWatch (config , opts )
171
+ }
172
+
154
173
// NewClusterAwareMapperProvider returns a function producing RESTMapper for the
155
174
// cluster specified in the context.
156
175
func NewClusterAwareMapperProvider (c * rest.Config , httpClient * http.Client ) func (ctx context.Context ) (meta.RESTMapper , error ) {
0 commit comments