From 97bd8a16fda3b7d0f176aa1b04d7fba5f1f56354 Mon Sep 17 00:00:00 2001 From: Ritu Sood Date: Tue, 23 Feb 2021 20:18:26 -0800 Subject: Migrate to use Helm v3 libraries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moving to Helm v3. Updated unit tests. Reworked Healthcheck Execution to align with v3 design. Helm v3 requires newer version for K8s libraries. Moved to use version 0.19.4. Issue-ID: MULTICLOUD-1295 Signed-off-by: Ritu Sood Signed-off-by: Konrad Bańka Change-Id: I091b75d69841dde56ad2c294cca2d5a0291ffa8f (cherry picked from commit 1f60346da61383f18b7277037439711aef38a0fe) --- src/k8splugin/plugins/generic/plugin.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/k8splugin/plugins/generic') diff --git a/src/k8splugin/plugins/generic/plugin.go b/src/k8splugin/plugins/generic/plugin.go index 8cbfcdf5..5f73ad22 100644 --- a/src/k8splugin/plugins/generic/plugin.go +++ b/src/k8splugin/plugins/generic/plugin.go @@ -14,6 +14,7 @@ limitations under the License. package main import ( + "context" pkgerrors "github.com/pkg/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -77,9 +78,9 @@ func (g genericPlugin) Create(yamlFilePath string, namespace string, client plug switch mapping.Scope.Name() { case meta.RESTScopeNameNamespace: - createdObj, err = dynClient.Resource(gvr).Namespace(namespace).Create(unstruct, metav1.CreateOptions{}) + createdObj, err = dynClient.Resource(gvr).Namespace(namespace).Create(context.TODO(), unstruct, metav1.CreateOptions{}) case meta.RESTScopeNameRoot: - createdObj, err = dynClient.Resource(gvr).Create(unstruct, metav1.CreateOptions{}) + createdObj, err = dynClient.Resource(gvr).Create(context.TODO(), unstruct, metav1.CreateOptions{}) default: return "", pkgerrors.New("Got an unknown RESTSCopeName for mapping: " + gvk.String()) } @@ -133,9 +134,9 @@ func (g genericPlugin) Update(yamlFilePath string, namespace string, client plug switch mapping.Scope.Name() { case meta.RESTScopeNameNamespace: - updatedObj, err = dynClient.Resource(gvr).Namespace(namespace).Update(unstruct, metav1.UpdateOptions{}) + updatedObj, err = dynClient.Resource(gvr).Namespace(namespace).Update(context.TODO(), unstruct, metav1.UpdateOptions{}) case meta.RESTScopeNameRoot: - updatedObj, err = dynClient.Resource(gvr).Update(unstruct, metav1.UpdateOptions{}) + updatedObj, err = dynClient.Resource(gvr).Update(context.TODO(), unstruct, metav1.UpdateOptions{}) default: return "", pkgerrors.New("Got an unknown RESTSCopeName for mapping: " + gvk.String()) } @@ -170,9 +171,9 @@ func (g genericPlugin) Get(resource helm.KubernetesResource, var unstruct *unstructured.Unstructured switch mapping.Scope.Name() { case meta.RESTScopeNameNamespace: - unstruct, err = dynClient.Resource(gvr).Namespace(namespace).Get(resource.Name, opts) + unstruct, err = dynClient.Resource(gvr).Namespace(namespace).Get(context.TODO(), resource.Name, opts) case meta.RESTScopeNameRoot: - unstruct, err = dynClient.Resource(gvr).Get(resource.Name, opts) + unstruct, err = dynClient.Resource(gvr).Get(context.TODO(), resource.Name, opts) default: return "", pkgerrors.New("Got an unknown RESTSCopeName for mapping: " + resource.GVK.String()) } @@ -212,15 +213,15 @@ func (g genericPlugin) Delete(resource helm.KubernetesResource, namespace string gvr := mapping.Resource deletePolicy := metav1.DeletePropagationForeground - opts := &metav1.DeleteOptions{ + opts := metav1.DeleteOptions{ PropagationPolicy: &deletePolicy, } switch mapping.Scope.Name() { case meta.RESTScopeNameNamespace: - err = dynClient.Resource(gvr).Namespace(namespace).Delete(resource.Name, opts) + err = dynClient.Resource(gvr).Namespace(namespace).Delete(context.TODO(), resource.Name, opts) case meta.RESTScopeNameRoot: - err = dynClient.Resource(gvr).Delete(resource.Name, opts) + err = dynClient.Resource(gvr).Delete(context.TODO(), resource.Name, opts) default: return pkgerrors.New("Got an unknown RESTSCopeName for mapping: " + resource.GVK.String()) } -- cgit 1.2.3-korg