refactor: Replaced context.TODO() with request.Context() in API files (#2214)
This commit is contained in:
@@ -117,7 +117,7 @@ func (a *API) FunctionApiList(w http.ResponseWriter, r *http.Request) {
|
||||
ns = metav1.NamespaceAll
|
||||
}
|
||||
|
||||
funcs, err := a.fissionClient.CoreV1().Functions(ns).List(context.TODO(), metav1.ListOptions{})
|
||||
funcs, err := a.fissionClient.CoreV1().Functions(ns).List(r.Context(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -147,13 +147,13 @@ func (a *API) FunctionApiCreate(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// check if namespace exists, if not create it.
|
||||
err = a.createNsIfNotExists(f.ObjectMeta.Namespace)
|
||||
err = a.createNsIfNotExists(r.Context(), f.ObjectMeta.Namespace)
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
fnew, err := a.fissionClient.CoreV1().Functions(f.ObjectMeta.Namespace).Create(context.TODO(), &f, metav1.CreateOptions{})
|
||||
fnew, err := a.fissionClient.CoreV1().Functions(f.ObjectMeta.Namespace).Create(r.Context(), &f, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -177,7 +177,7 @@ func (a *API) FunctionApiGet(w http.ResponseWriter, r *http.Request) {
|
||||
ns = metav1.NamespaceDefault
|
||||
}
|
||||
|
||||
f, err := a.fissionClient.CoreV1().Functions(ns).Get(context.TODO(), name, metav1.GetOptions{})
|
||||
f, err := a.fissionClient.CoreV1().Functions(ns).Get(r.Context(), name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -214,7 +214,7 @@ func (a *API) FunctionApiUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
fnew, err := a.fissionClient.CoreV1().Functions(f.ObjectMeta.Namespace).Update(context.TODO(), &f, metav1.UpdateOptions{})
|
||||
fnew, err := a.fissionClient.CoreV1().Functions(f.ObjectMeta.Namespace).Update(r.Context(), &f, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -236,7 +236,7 @@ func (a *API) FunctionApiDelete(w http.ResponseWriter, r *http.Request) {
|
||||
ns = metav1.NamespaceDefault
|
||||
}
|
||||
|
||||
err := a.fissionClient.CoreV1().Functions(ns).Delete(context.TODO(), name, metav1.DeleteOptions{})
|
||||
err := a.fissionClient.CoreV1().Functions(ns).Delete(r.Context(), name, metav1.DeleteOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -299,7 +299,7 @@ func (a *API) FunctionPodLogs(w http.ResponseWriter, r *http.Request) {
|
||||
podNs = ns
|
||||
}
|
||||
|
||||
f, err := a.fissionClient.CoreV1().Functions(ns).Get(context.TODO(), fnName, metav1.GetOptions{})
|
||||
f, err := a.fissionClient.CoreV1().Functions(ns).Get(r.Context(), fnName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
a.respondWithError(w, err)
|
||||
return
|
||||
@@ -311,7 +311,7 @@ func (a *API) FunctionPodLogs(w http.ResponseWriter, r *http.Request) {
|
||||
fv1.ENVIRONMENT_NAME: f.Spec.Environment.Name,
|
||||
fv1.ENVIRONMENT_NAMESPACE: f.Spec.Environment.Namespace,
|
||||
}
|
||||
podList, err := a.kubernetesClient.CoreV1().Pods(podNs).List(context.TODO(), metav1.ListOptions{
|
||||
podList, err := a.kubernetesClient.CoreV1().Pods(podNs).List(r.Context(), metav1.ListOptions{
|
||||
LabelSelector: labels.Set(selector).AsSelector().String(),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user