Update client-go methods to support context and and new create and delete options

This commit is contained in:
Manuel Alejandro de Brito Fontes 2020-03-24 10:44:13 -03:00
parent f4b17d345f
commit a46126a034
32 changed files with 167 additions and 132 deletions

View file

@ -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)
}

View file

@ -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)
}