@@ -120,14 +120,11 @@ func (c *client) Namespace(ns string) ResourceInterface {
120
120
}
121
121
122
122
// Delete removes the provided resource from the server.
123
- func (c * client ) Delete (name string , opts * metav1.DeleteOptions , subresources ... string ) error {
123
+ func (c * client ) Delete (ctx context. Context , name string , opts metav1.DeleteOptions , subresources ... string ) error {
124
124
if len (name ) == 0 {
125
125
return fmt .Errorf ("name is required" )
126
126
}
127
- if opts == nil {
128
- opts = & metav1.DeleteOptions {}
129
- }
130
- deleteOptionsByte , err := runtime .Encode (deleteOptionsCodec .LegacyCodec (schema.GroupVersion {Version : "v1" }), opts )
127
+ deleteOptionsByte , err := runtime .Encode (deleteOptionsCodec .LegacyCodec (schema.GroupVersion {Version : "v1" }), & opts )
131
128
if err != nil {
132
129
return err
133
130
}
@@ -136,16 +133,13 @@ func (c *client) Delete(name string, opts *metav1.DeleteOptions, subresources ..
136
133
Delete ().
137
134
AbsPath (append (c .makeURLSegments (name ), subresources ... )... ).
138
135
Body (deleteOptionsByte ).
139
- Do (context . TODO () )
136
+ Do (ctx )
140
137
return result .Error ()
141
138
}
142
139
143
140
// DeleteCollection triggers deletion of all resources in the specified scope (namespace or cluster).
144
- func (c * client ) DeleteCollection (opts * metav1.DeleteOptions , listOptions metav1.ListOptions ) error {
145
- if opts == nil {
146
- opts = & metav1.DeleteOptions {}
147
- }
148
- deleteOptionsByte , err := runtime .Encode (deleteOptionsCodec .LegacyCodec (schema.GroupVersion {Version : "v1" }), opts )
141
+ func (c * client ) DeleteCollection (ctx context.Context , opts metav1.DeleteOptions , listOptions metav1.ListOptions ) error {
142
+ deleteOptionsByte , err := runtime .Encode (deleteOptionsCodec .LegacyCodec (schema.GroupVersion {Version : "v1" }), & opts )
149
143
if err != nil {
150
144
return err
151
145
}
@@ -155,19 +149,19 @@ func (c *client) DeleteCollection(opts *metav1.DeleteOptions, listOptions metav1
155
149
AbsPath (c .makeURLSegments ("" )... ).
156
150
Body (deleteOptionsByte ).
157
151
SpecificallyVersionedParams (& listOptions , dynamicParameterCodec , versionV1 ).
158
- Do (context . TODO () )
152
+ Do (ctx )
159
153
return result .Error ()
160
154
}
161
155
162
156
// Get returns the resource with name from the specified scope (namespace or cluster).
163
- func (c * client ) Get (name string , opts metav1.GetOptions , subresources ... string ) (* metav1.PartialObjectMetadata , error ) {
157
+ func (c * client ) Get (ctx context. Context , name string , opts metav1.GetOptions , subresources ... string ) (* metav1.PartialObjectMetadata , error ) {
164
158
if len (name ) == 0 {
165
159
return nil , fmt .Errorf ("name is required" )
166
160
}
167
161
result := c .client .client .Get ().AbsPath (append (c .makeURLSegments (name ), subresources ... )... ).
168
162
SetHeader ("Accept" , "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json" ).
169
163
SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
170
- Do (context . TODO () )
164
+ Do (ctx )
171
165
if err := result .Error (); err != nil {
172
166
return nil , err
173
167
}
@@ -199,11 +193,11 @@ func (c *client) Get(name string, opts metav1.GetOptions, subresources ...string
199
193
}
200
194
201
195
// List returns all resources within the specified scope (namespace or cluster).
202
- func (c * client ) List (opts metav1.ListOptions ) (* metav1.PartialObjectMetadataList , error ) {
196
+ func (c * client ) List (ctx context. Context , opts metav1.ListOptions ) (* metav1.PartialObjectMetadataList , error ) {
203
197
result := c .client .client .Get ().AbsPath (c .makeURLSegments ("" )... ).
204
198
SetHeader ("Accept" , "application/vnd.kubernetes.protobuf;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadataList;g=meta.k8s.io;v=v1,application/json" ).
205
199
SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
206
- Do (context . TODO () )
200
+ Do (ctx )
207
201
if err := result .Error (); err != nil {
208
202
return nil , err
209
203
}
@@ -232,7 +226,7 @@ func (c *client) List(opts metav1.ListOptions) (*metav1.PartialObjectMetadataLis
232
226
}
233
227
234
228
// Watch finds all changes to the resources in the specified scope (namespace or cluster).
235
- func (c * client ) Watch (opts metav1.ListOptions ) (watch.Interface , error ) {
229
+ func (c * client ) Watch (ctx context. Context , opts metav1.ListOptions ) (watch.Interface , error ) {
236
230
var timeout time.Duration
237
231
if opts .TimeoutSeconds != nil {
238
232
timeout = time .Duration (* opts .TimeoutSeconds ) * time .Second
@@ -243,11 +237,11 @@ func (c *client) Watch(opts metav1.ListOptions) (watch.Interface, error) {
243
237
SetHeader ("Accept" , "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json" ).
244
238
SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
245
239
Timeout (timeout ).
246
- Watch (context . TODO () )
240
+ Watch (ctx )
247
241
}
248
242
249
243
// Patch modifies the named resource in the specified scope (namespace or cluster).
250
- func (c * client ) Patch (name string , pt types.PatchType , data []byte , opts metav1.PatchOptions , subresources ... string ) (* metav1.PartialObjectMetadata , error ) {
244
+ func (c * client ) Patch (ctx context. Context , name string , pt types.PatchType , data []byte , opts metav1.PatchOptions , subresources ... string ) (* metav1.PartialObjectMetadata , error ) {
251
245
if len (name ) == 0 {
252
246
return nil , fmt .Errorf ("name is required" )
253
247
}
@@ -257,7 +251,7 @@ func (c *client) Patch(name string, pt types.PatchType, data []byte, opts metav1
257
251
Body (data ).
258
252
SetHeader ("Accept" , "application/vnd.kubernetes.protobuf;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json;as=PartialObjectMetadata;g=meta.k8s.io;v=v1,application/json" ).
259
253
SpecificallyVersionedParams (& opts , dynamicParameterCodec , versionV1 ).
260
- Do (context . TODO () )
254
+ Do (ctx )
261
255
if err := result .Error (); err != nil {
262
256
return nil , err
263
257
}
0 commit comments