Update client-go methods to support context and and new create and delete options
This commit is contained in:
parent
f4b17d345f
commit
a46126a034
32 changed files with 167 additions and 132 deletions
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
|
@ -81,7 +82,7 @@ func main() {
|
|||
klog.Fatal(err)
|
||||
}
|
||||
|
||||
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(defSvcName, metav1.GetOptions{})
|
||||
_, err = kubeClient.CoreV1().Services(defSvcNs).Get(context.TODO(), defSvcName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if errors.IsUnauthorized(err) || errors.IsForbidden(err) {
|
||||
klog.Fatal("✖ The cluster seems to be running with a restrictive Authorization mode and the Ingress controller does not have the required permissions to operate normally.")
|
||||
|
|
@ -92,7 +93,7 @@ func main() {
|
|||
}
|
||||
|
||||
if conf.Namespace != "" {
|
||||
_, err = kubeClient.CoreV1().Namespaces().Get(conf.Namespace, metav1.GetOptions{})
|
||||
_, err = kubeClient.CoreV1().Namespaces().Get(context.TODO(), conf.Namespace, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
klog.Fatalf("No namespace with name %v found: %v", conf.Namespace, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -66,7 +67,7 @@ func TestHandleSigterm(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
_, err := clientSet.CoreV1().Pods(namespace).Create(&pod)
|
||||
_, err := clientSet.CoreV1().Pods(namespace).Create(context.TODO(), &pod, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("error creating pod %v: %v", pod, err)
|
||||
}
|
||||
|
|
@ -118,7 +119,7 @@ func createConfigMap(clientSet kubernetes.Interface, ns string, t *testing.T) st
|
|||
},
|
||||
}
|
||||
|
||||
cm, err := clientSet.CoreV1().ConfigMaps(ns).Create(configMap)
|
||||
cm, err := clientSet.CoreV1().ConfigMaps(ns).Create(context.TODO(), configMap, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
t.Errorf("error creating the configuration map: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package request
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
|
|
@ -100,7 +101,7 @@ func GetDeployments(flags *genericclioptions.ConfigFlags, namespace string) ([]a
|
|||
return make([]appsv1.Deployment, 0), err
|
||||
}
|
||||
|
||||
deployments, err := api.Deployments(namespace).List(metav1.ListOptions{})
|
||||
deployments, err := api.Deployments(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return make([]appsv1.Deployment, 0), err
|
||||
}
|
||||
|
|
@ -120,7 +121,7 @@ func GetIngressDefinitions(flags *genericclioptions.ConfigFlags, namespace strin
|
|||
return make([]networking.Ingress, 0), err
|
||||
}
|
||||
|
||||
pods, err := api.Ingresses(namespace).List(metav1.ListOptions{})
|
||||
pods, err := api.Ingresses(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return make([]networking.Ingress, 0), err
|
||||
}
|
||||
|
|
@ -189,7 +190,7 @@ func getEndpoints(flags *genericclioptions.ConfigFlags, namespace string) ([]api
|
|||
return nil, err
|
||||
}
|
||||
|
||||
endpointsList, err := api.Endpoints(namespace).List(metav1.ListOptions{})
|
||||
endpointsList, err := api.Endpoints(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -256,7 +257,7 @@ func getPods(flags *genericclioptions.ConfigFlags) ([]apiv1.Pod, error) {
|
|||
return make([]apiv1.Pod, 0), err
|
||||
}
|
||||
|
||||
pods, err := api.Pods(namespace).List(metav1.ListOptions{})
|
||||
pods, err := api.Pods(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return make([]apiv1.Pod, 0), err
|
||||
}
|
||||
|
|
@ -277,7 +278,7 @@ func getLabeledPods(flags *genericclioptions.ConfigFlags, label string) ([]apiv1
|
|||
return make([]apiv1.Pod, 0), err
|
||||
}
|
||||
|
||||
pods, err := api.Pods(namespace).List(metav1.ListOptions{
|
||||
pods, err := api.Pods(namespace).List(context.TODO(), metav1.ListOptions{
|
||||
LabelSelector: label,
|
||||
})
|
||||
|
||||
|
|
@ -317,7 +318,7 @@ func getServices(flags *genericclioptions.ConfigFlags) ([]apiv1.Service, error)
|
|||
return make([]apiv1.Service, 0), err
|
||||
}
|
||||
|
||||
services, err := api.Services(namespace).List(metav1.ListOptions{})
|
||||
services, err := api.Services(namespace).List(context.TODO(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return make([]apiv1.Service, 0), err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue