@@ -21,6 +21,7 @@ import (
21
21
"fmt"
22
22
23
23
autoscaling "k8s.io/api/autoscaling/v1"
24
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24
25
"k8s.io/apimachinery/pkg/runtime"
25
26
"k8s.io/apimachinery/pkg/runtime/schema"
26
27
serializer "k8s.io/apimachinery/pkg/runtime/serializer"
@@ -31,6 +32,14 @@ import (
31
32
32
33
var scaleConverter = NewScaleConverter ()
33
34
var codecs = serializer .NewCodecFactory (scaleConverter .Scheme ())
35
+ var parameterScheme = runtime .NewScheme ()
36
+ var dynamicParameterCodec = runtime .NewParameterCodec (parameterScheme )
37
+
38
+ var versionV1 = schema.GroupVersion {Version : "v1" }
39
+
40
+ func init () {
41
+ metav1 .AddToGroupVersion (parameterScheme , versionV1 )
42
+ }
34
43
35
44
// scaleClient is an implementation of ScalesGetter
36
45
// which makes use of a RESTMapper and a generic REST
@@ -138,7 +147,7 @@ func (c *scaleClient) Scales(namespace string) ScaleInterface {
138
147
}
139
148
}
140
149
141
- func (c * namespacedScaleClient ) Get (resource schema.GroupResource , name string ) (* autoscaling.Scale , error ) {
150
+ func (c * namespacedScaleClient ) Get (ctx context. Context , resource schema.GroupResource , name string , opts metav1. GetOptions ) (* autoscaling.Scale , error ) {
142
151
// Currently, a /scale endpoint can return different scale types.
143
152
// Until we have support for the alternative API representations proposal,
144
153
// we need to deal with accepting different API versions.
@@ -155,15 +164,16 @@ func (c *namespacedScaleClient) Get(resource schema.GroupResource, name string)
155
164
Resource (gvr .Resource ).
156
165
Name (name ).
157
166
SubResource ("scale" ).
158
- Do (context .TODO ())
167
+ SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
168
+ Do (ctx )
159
169
if err := result .Error (); err != nil {
160
170
return nil , err
161
171
}
162
172
163
173
return convertToScale (& result )
164
174
}
165
175
166
- func (c * namespacedScaleClient ) Update (resource schema.GroupResource , scale * autoscaling.Scale ) (* autoscaling.Scale , error ) {
176
+ func (c * namespacedScaleClient ) Update (ctx context. Context , resource schema.GroupResource , scale * autoscaling.Scale , opts metav1. UpdateOptions ) (* autoscaling.Scale , error ) {
167
177
path , gvr , err := c .client .pathAndVersionFor (resource )
168
178
if err != nil {
169
179
return nil , fmt .Errorf ("unable to get client for %s: %v" , resource .String (), err )
@@ -196,8 +206,9 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
196
206
Resource (gvr .Resource ).
197
207
Name (scale .Name ).
198
208
SubResource ("scale" ).
209
+ SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
199
210
Body (scaleUpdateBytes ).
200
- Do (context . TODO () )
211
+ Do (ctx )
201
212
if err := result .Error (); err != nil {
202
213
// propagate "raw" error from the API
203
214
// this allows callers to interpret underlying Reason field
@@ -208,16 +219,17 @@ func (c *namespacedScaleClient) Update(resource schema.GroupResource, scale *aut
208
219
return convertToScale (& result )
209
220
}
210
221
211
- func (c * namespacedScaleClient ) Patch (gvr schema.GroupVersionResource , name string , pt types.PatchType , data []byte ) (* autoscaling.Scale , error ) {
222
+ func (c * namespacedScaleClient ) Patch (ctx context. Context , gvr schema.GroupVersionResource , name string , pt types.PatchType , data []byte , opts metav1. PatchOptions ) (* autoscaling.Scale , error ) {
212
223
groupVersion := gvr .GroupVersion ()
213
224
result := c .client .clientBase .Patch (pt ).
214
225
AbsPath (c .client .apiPathFor (groupVersion )).
215
226
NamespaceIfScoped (c .namespace , c .namespace != "" ).
216
227
Resource (gvr .Resource ).
217
228
Name (name ).
218
229
SubResource ("scale" ).
230
+ SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
219
231
Body (data ).
220
- Do (context . TODO () )
232
+ Do (ctx )
221
233
if err := result .Error (); err != nil {
222
234
return nil , err
223
235
}
0 commit comments