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 settings
import (
"context"
"net/http"
"strings"
@ -41,12 +42,12 @@ var _ = framework.IngressNginxDescribe("[Security] Pod Security Policies", func(
ginkgo.BeforeEach(func() {
psp := createPodSecurityPolicy()
_, err := f.KubeClientSet.PolicyV1beta1().PodSecurityPolicies().Create(psp)
_, err := f.KubeClientSet.PolicyV1beta1().PodSecurityPolicies().Create(context.TODO(), psp, metav1.CreateOptions{})
if !k8sErrors.IsAlreadyExists(err) {
assert.Nil(ginkgo.GinkgoT(), err, "creating Pod Security Policy")
}
role, err := f.KubeClientSet.RbacV1().Roles(f.Namespace).Get("nginx-ingress", metav1.GetOptions{})
role, err := f.KubeClientSet.RbacV1().Roles(f.Namespace).Get(context.TODO(), "nginx-ingress", metav1.GetOptions{})
assert.Nil(ginkgo.GinkgoT(), err, "getting ingress controller cluster role")
assert.NotNil(ginkgo.GinkgoT(), role)
@ -57,7 +58,7 @@ var _ = framework.IngressNginxDescribe("[Security] Pod Security Policies", func(
Verbs: []string{"use"},
})
_, err = f.KubeClientSet.RbacV1().Roles(f.Namespace).Update(role)
_, err = f.KubeClientSet.RbacV1().Roles(f.Namespace).Update(context.TODO(), role, metav1.UpdateOptions{})
assert.Nil(ginkgo.GinkgoT(), err, "updating ingress controller cluster role to use a pod security policy")
// update the deployment just to trigger a rolling update and the use of the security policy
@ -66,7 +67,7 @@ var _ = framework.IngressNginxDescribe("[Security] Pod Security Policies", func(
args := deployment.Spec.Template.Spec.Containers[0].Args
args = append(args, "--v=2")
deployment.Spec.Template.Spec.Containers[0].Args = args
_, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(deployment)
_, err := f.KubeClientSet.AppsV1().Deployments(f.Namespace).Update(context.TODO(), deployment, metav1.UpdateOptions{})
return err
})