Update to k8s 1.18

(cherry picked from commit 420f62f642)
This commit is contained in:
Darren Shepherd
2020-03-26 13:58:39 -07:00
committed by Arvind Iyengar
parent 682e866977
commit c5087d55cf
6 changed files with 34 additions and 32 deletions

View File

@@ -105,7 +105,7 @@ func (s *Store) byID(apiOp *types.APIRequest, schema *types.APISchema, id string
return nil, err
}
obj, err := k8sClient.Get(id, opts)
obj, err := k8sClient.Get(apiOp.Context(), id, opts)
rowToObject(obj)
return obj, err
}
@@ -225,7 +225,7 @@ func (s *Store) list(apiOp *types.APIRequest, schema *types.APISchema, client dy
return types.APIObjectList{}, nil
}
resultList, err := client.List(opts)
resultList, err := client.List(apiOp.Context(), opts)
if err != nil {
return types.APIObjectList{}, err
}
@@ -254,7 +254,7 @@ func returnErr(err error, c chan types.APIEvent) {
func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.ResourceInterface, schema *types.APISchema, w types.WatchRequest, result chan types.APIEvent) {
rev := w.Revision
if rev == "" {
list, err := k8sClient.List(metav1.ListOptions{
list, err := k8sClient.List(apiOp.Context(), metav1.ListOptions{
Limit: 1,
})
if err != nil {
@@ -267,7 +267,7 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.Resource
}
timeout := int64(60 * 30)
watcher, err := k8sClient.Watch(metav1.ListOptions{
watcher, err := k8sClient.Watch(apiOp.Context(), metav1.ListOptions{
Watch: true,
TimeoutSeconds: &timeout,
ResourceVersion: rev,
@@ -394,7 +394,7 @@ func (s *Store) Create(apiOp *types.APIRequest, schema *types.APISchema, params
return types.APIObject{}, err
}
resp, err = k8sClient.Create(&unstructured.Unstructured{Object: input}, opts)
resp, err = k8sClient.Create(apiOp.Context(), &unstructured.Unstructured{Object: input}, opts)
rowToObject(resp)
return toAPI(schema, resp), err
}
@@ -439,7 +439,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params
}
}
resp, err := k8sClient.Patch(id, pType, bytes, opts)
resp, err := k8sClient.Patch(apiOp.Context(), id, pType, bytes, opts)
if err != nil {
return types.APIObject{}, err
}
@@ -457,7 +457,7 @@ func (s *Store) Update(apiOp *types.APIRequest, schema *types.APISchema, params
return types.APIObject{}, err
}
resp, err := k8sClient.Update(&unstructured.Unstructured{Object: moveFromUnderscore(input)}, metav1.UpdateOptions{})
resp, err := k8sClient.Update(apiOp.Context(), &unstructured.Unstructured{Object: moveFromUnderscore(input)}, metav1.UpdateOptions{})
if err != nil {
return types.APIObject{}, err
}
@@ -476,7 +476,7 @@ func (s *Store) Delete(apiOp *types.APIRequest, schema *types.APISchema, id stri
return types.APIObject{}, err
}
if err := k8sClient.Delete(id, &opts); err != nil {
if err := k8sClient.Delete(apiOp.Context(), id, opts); err != nil {
return types.APIObject{}, err
}