Skip to content

Commit

Permalink
Update BackendConfig client-go methods
Browse files Browse the repository at this point in the history
  • Loading branch information
skmatti committed May 22, 2020
1 parent 818e326 commit 71bbc51
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cmd/e2e-test/affinity_beta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestAffinityBeta(t *testing.T) {
},
},
}
if _, err := Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Create(beConfig); err != nil {
if _, err := Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Create(context.TODO(), beConfig, metav1.CreateOptions{}); err != nil {
t.Fatalf("CloudV1beta1().BackendConfigs(%q).Create(%#v) = %v, want nil", s.Namespace, beConfig, err)
}
t.Logf("BackendConfig created (%s/%s) ", s.Namespace, beConfig.Name)
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestAffinityBeta(t *testing.T) {
for _, transition := range affinityTransitions {
// Test modifications.
if err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
bc, err := Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Get(beConfig.Name, metav1.GetOptions{})
bc, err := Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Get(context.TODO(), beConfig.Name, metav1.GetOptions{})
if err != nil {
return err
}
Expand All @@ -119,7 +119,7 @@ func TestAffinityBeta(t *testing.T) {
}
bc.Spec.SessionAffinity.AffinityType = transition.affinity
bc.Spec.SessionAffinity.AffinityCookieTtlSec = &transition.ttl
_, err = Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Update(bc)
_, err = Framework.BackendConfigClient.CloudV1beta1().BackendConfigs(s.Namespace).Update(context.TODO(), bc, metav1.UpdateOptions{})
return err
}); err != nil {
t.Errorf("CloudV1beta1().BackendConfigs(%q).Update(%#v) = %v, want nil", s.Namespace, transition, err)
Expand Down
21 changes: 11 additions & 10 deletions pkg/e2e/adapter/beconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package adapter

import (
"bytes"
"context"
"encoding/json"
"errors"

Expand All @@ -41,10 +42,10 @@ func (crud *BackendConfigCRUD) Get(ns, name string) (*v1.BackendConfig, error) {
}
klog.V(3).Infof("Get BackendConfig %s/%s", ns, name)
if isV1 {
return crud.C.CloudV1().BackendConfigs(ns).Get(name, metav1.GetOptions{})
return crud.C.CloudV1().BackendConfigs(ns).Get(context.TODO(), name, metav1.GetOptions{})
}
klog.V(4).Info("Using BackendConfig V1beta1 API")
bc, err := crud.C.CloudV1beta1().BackendConfigs(ns).Get(name, metav1.GetOptions{})
bc, err := crud.C.CloudV1beta1().BackendConfigs(ns).Get(context.TODO(), name, metav1.GetOptions{})
return toV1(bc), err
}

Expand All @@ -56,11 +57,11 @@ func (crud *BackendConfigCRUD) Create(bc *v1.BackendConfig) (*v1.BackendConfig,
}
klog.V(2).Infof("Create BackendConfig %s/%s", bc.Namespace, bc.Name)
if isV1 {
return crud.C.CloudV1().BackendConfigs(bc.Namespace).Create(bc)
return crud.C.CloudV1().BackendConfigs(bc.Namespace).Create(context.TODO(), bc, metav1.CreateOptions{})
}
klog.V(2).Info("Using BackendConfig V1beta1 API")
legacyBc := toV1beta1(bc)
legacyBc, err = crud.C.CloudV1beta1().BackendConfigs(bc.Namespace).Create(legacyBc)
legacyBc, err = crud.C.CloudV1beta1().BackendConfigs(bc.Namespace).Create(context.TODO(), legacyBc, metav1.CreateOptions{})
return toV1(legacyBc), err
}

Expand All @@ -72,11 +73,11 @@ func (crud *BackendConfigCRUD) Update(bc *v1.BackendConfig) (*v1.BackendConfig,
}
klog.V(2).Infof("Update %s/%s", bc.Namespace, bc.Name)
if isV1 {
return crud.C.CloudV1().BackendConfigs(bc.Namespace).Update(bc)
return crud.C.CloudV1().BackendConfigs(bc.Namespace).Update(context.TODO(), bc, metav1.UpdateOptions{})
}
klog.V(2).Infof("Using BackendConfig V1beta1 API")
legacyBC := toV1beta1(bc)
legacyBC, err = crud.C.CloudV1beta1().BackendConfigs(bc.Namespace).Update(legacyBC)
legacyBC, err = crud.C.CloudV1beta1().BackendConfigs(bc.Namespace).Update(context.TODO(), legacyBC, metav1.UpdateOptions{})
return toV1(legacyBC), err
}

Expand All @@ -88,10 +89,10 @@ func (crud *BackendConfigCRUD) Delete(ns, name string) error {
}
klog.V(2).Infof("Delete BackendConfig %s/%s", ns, name)
if isV1 {
return crud.C.CloudV1().BackendConfigs(ns).Delete(name, &metav1.DeleteOptions{})
return crud.C.CloudV1().BackendConfigs(ns).Delete(context.TODO(), name, metav1.DeleteOptions{})
}
klog.V(2).Info("Using BackendConfig V1beta1 API")
return crud.C.CloudV1beta1().BackendConfigs(ns).Delete(name, &metav1.DeleteOptions{})
return crud.C.CloudV1beta1().BackendConfigs(ns).Delete(context.TODO(), name, metav1.DeleteOptions{})
}

// List BackendConfig resources in given namespace.
Expand All @@ -102,10 +103,10 @@ func (crud *BackendConfigCRUD) List(ns string) (*v1.BackendConfigList, error) {
}
klog.V(3).Infof("List BackendConfigs in namespace(%s)", ns)
if isV1 {
return crud.C.CloudV1().BackendConfigs(ns).List(metav1.ListOptions{})
return crud.C.CloudV1().BackendConfigs(ns).List(context.TODO(), metav1.ListOptions{})
}
klog.V(4).Info("Using BackendConfig V1beta1 API")
bcl, err := crud.C.CloudV1beta1().BackendConfigs(ns).List(metav1.ListOptions{})
bcl, err := crud.C.CloudV1beta1().BackendConfigs(ns).List(context.TODO(), metav1.ListOptions{})
return toV1List(bcl), err
}

Expand Down

0 comments on commit 71bbc51

Please sign in to comment.