From bbf66d4328b6f79daf7b372f87f4c966774492b9 Mon Sep 17 00:00:00 2001 From: Ruturaj Mohite Date: Fri, 3 Jun 2022 00:39:01 +0530 Subject: [PATCH 1/2] Add Support for Multi-Context Signed-off-by: Ruturaj Mohite --- appmesh/addons.go | 78 ++++++++++++++----- appmesh/app_mesh.go | 28 ++++--- appmesh/custom_operation.go | 4 +- appmesh/install.go | 149 +++++++++++++++++++++++++----------- appmesh/oam.go | 25 +++--- appmesh/sample_apps.go | 72 ++++++++++++----- go.mod | 2 +- go.sum | 4 +- 8 files changed, 249 insertions(+), 113 deletions(-) diff --git a/appmesh/addons.go b/appmesh/addons.go index eb4e3a3..bb69a0e 100644 --- a/appmesh/addons.go +++ b/appmesh/addons.go @@ -3,46 +3,86 @@ package appmesh import ( "context" "net/url" + "sync" "github.com/layer5io/meshery-adapter-library/status" "github.com/layer5io/meshkit/utils" kubernetes "github.com/layer5io/meshkit/utils/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + mesherykube "github.com/layer5io/meshkit/utils/kubernetes" ) -func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patches []string, helmChartURL string) (string, error) { +func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patches []string, helmChartURL string, kubeconfigs []string) (string, error) { st := status.Installing if del { st = status.Removing } - err := appMesh.MesheryKubeclient.ApplyHelmChart(kubernetes.ApplyHelmChartConfig{ - URL: helmChartURL, - Namespace: ns, - }) - if err != nil { - return st, ErrAddonFromHelm(err) - } - for _, patch := range patches { - if !del { - _, err := url.ParseRequestURI(patch) + var wg sync.WaitGroup + var errs []error + var errMx sync.Mutex + + + for _, config := range kubeconfigs { + wg.Add(1); + go func(config string) { + defer wg.Done() + kClient, err := mesherykube.New([]byte(config)) if err != nil { - return st, ErrAddonFromTemplate(err) + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return } - content, err := utils.ReadFileSource(patch) + err = kClient.ApplyHelmChart(kubernetes.ApplyHelmChartConfig{ + URL: helmChartURL, + Namespace: ns, + }) if err != nil { - return st, ErrAddonFromTemplate(err) + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return } - _, err = appMesh.KubeClient.CoreV1().Services(ns).Patch(context.TODO(), svcName, types.MergePatchType, []byte(content), metav1.PatchOptions{}) - if err != nil { - return st, ErrAddonFromTemplate(err) + for _, patch := range patches { + if !del { + _, err := url.ParseRequestURI(patch) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + content, err := utils.ReadFileSource(patch) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + _, err = kClient.KubeClient.CoreV1().Services(ns).Patch(context.TODO(), svcName, types.MergePatchType, []byte(content), metav1.PatchOptions{}) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + } } - } + }(config) + } + + wg.Wait() + if len(errs) == 0 { + return st, nil } - return st, nil + + return st, ErrAddonFromHelm(mergeErrors(errs)) } diff --git a/appmesh/app_mesh.go b/appmesh/app_mesh.go index e714741..5219d4d 100644 --- a/appmesh/app_mesh.go +++ b/appmesh/app_mesh.go @@ -26,13 +26,14 @@ func New(c meshkitCfg.Handler, l logger.Handler, kc meshkitCfg.Handler) adapter. Adapter: adapter.Adapter{ Config: c, Log: l, - KubeconfigHandler: kc, }, } } // ApplyOperation applies the requested operation on app-mesh -func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.OperationRequest) error { +func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.OperationRequest, hchan *chan interface{}) error { + kubeConfigs := opReq.K8sConfigs + appMesh.SetChannel(hchan); operations := make(adapter.Operations) err := appMesh.Config.GetObject(adapter.OperationsKey, &operations) @@ -51,7 +52,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat case internalconfig.AppMeshOperation: go func(hh *AppMesh, ee *adapter.Event) { version := string(operations[opReq.OperationName].Versions[0]) - if stat, err = hh.installAppMesh(opReq.IsDeleteOperation, version, opReq.Namespace); err != nil { + if stat, err = hh.installAppMesh(opReq.IsDeleteOperation, version, opReq.Namespace, kubeConfigs); err != nil { e.Summary = fmt.Sprintf("Error while %s AWS App mesh", stat) e.Details = err.Error() hh.StreamErr(e, err) @@ -64,7 +65,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat case internalconfig.LabelNamespace: go func(hh *AppMesh, ee *adapter.Event) { - err := hh.LoadNamespaceToMesh(opReq.Namespace, opReq.IsDeleteOperation) + err := hh.LoadNamespaceToMesh(opReq.Namespace, opReq.IsDeleteOperation, kubeConfigs) operation := "enabled" if opReq.IsDeleteOperation { operation = "removed" @@ -85,7 +86,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat helmChartURL := operations[opReq.OperationName].AdditionalProperties[internalconfig.HelmChartURL] patches := make([]string, 0) patches = append(patches, operations[opReq.OperationName].AdditionalProperties[internalconfig.ServicePatchFile]) - _, err := hh.installAddon(opReq.Namespace, opReq.IsDeleteOperation, svcname, patches, helmChartURL) + _, err := hh.installAddon(opReq.Namespace, opReq.IsDeleteOperation, svcname, patches, helmChartURL, kubeConfigs) operation := "install" if opReq.IsDeleteOperation { operation = "uninstall" @@ -104,7 +105,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat case common.BookInfoOperation, common.HTTPBinOperation, common.ImageHubOperation, common.EmojiVotoOperation: go func(hh *AppMesh, ee *adapter.Event) { appName := operations[opReq.OperationName].AdditionalProperties[common.ServiceName] - stat, err := hh.installSampleApp(opReq.Namespace, opReq.IsDeleteOperation, operations[opReq.OperationName].Templates) + stat, err := hh.installSampleApp(opReq.Namespace, opReq.IsDeleteOperation, operations[opReq.OperationName].Templates, kubeConfigs) if err != nil { e.Summary = fmt.Sprintf("Error while %s %s application", stat, appName) e.Details = err.Error() @@ -118,7 +119,7 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat case common.CustomOperation: go func(hh *AppMesh, ee *adapter.Event) { - stat, err := hh.applyCustomOperation(opReq.Namespace, opReq.CustomBody, opReq.IsDeleteOperation) + stat, err := hh.applyCustomOperation(opReq.Namespace, opReq.CustomBody, opReq.IsDeleteOperation, kubeConfigs) if err != nil { e.Summary = fmt.Sprintf("Error while %s custom operation", stat) e.Details = err.Error() @@ -137,7 +138,10 @@ func (appMesh *AppMesh) ApplyOperation(ctx context.Context, opReq adapter.Operat } // ProcessOAM handles the grpc invocation for handling OAM objects -func (appMesh *AppMesh) ProcessOAM(ctx context.Context, oamReq adapter.OAMRequest) (string, error) { +func (appMesh *AppMesh) ProcessOAM(ctx context.Context, oamReq adapter.OAMRequest, hchan *chan interface{}) (string, error) { + appMesh.SetChannel(hchan) + kubeConfigs := oamReq.K8sConfigs + var comps []v1alpha1.Component for _, acomp := range oamReq.OamComps { comp, err := oam.ParseApplicationComponent(acomp) @@ -157,13 +161,13 @@ func (appMesh *AppMesh) ProcessOAM(ctx context.Context, oamReq adapter.OAMReques // If operation is delete then first HandleConfiguration and then handle the deployment if oamReq.DeleteOp { // Process configuration - msg2, err := appMesh.HandleApplicationConfiguration(config, oamReq.DeleteOp) + msg2, err := appMesh.HandleApplicationConfiguration(config, oamReq.DeleteOp, kubeConfigs) if err != nil { return msg2, ErrProcessOAM(err) } // Process components - msg1, err := appMesh.HandleComponents(comps, oamReq.DeleteOp) + msg1, err := appMesh.HandleComponents(comps, oamReq.DeleteOp, kubeConfigs) if err != nil { return msg1 + "\n" + msg2, ErrProcessOAM(err) } @@ -172,13 +176,13 @@ func (appMesh *AppMesh) ProcessOAM(ctx context.Context, oamReq adapter.OAMReques } // Process components - msg1, err := appMesh.HandleComponents(comps, oamReq.DeleteOp) + msg1, err := appMesh.HandleComponents(comps, oamReq.DeleteOp, kubeConfigs) if err != nil { return msg1, ErrProcessOAM(err) } // Process configuration - msg2, err := appMesh.HandleApplicationConfiguration(config, oamReq.DeleteOp) + msg2, err := appMesh.HandleApplicationConfiguration(config, oamReq.DeleteOp, kubeConfigs) if err != nil { return msg1 + "\n" + msg2, ErrProcessOAM(err) } diff --git a/appmesh/custom_operation.go b/appmesh/custom_operation.go index 8086240..ab2a5a4 100644 --- a/appmesh/custom_operation.go +++ b/appmesh/custom_operation.go @@ -4,10 +4,10 @@ import ( "github.com/layer5io/meshery-adapter-library/status" ) -func (appMesh *AppMesh) applyCustomOperation(namespace string, manifest string, isDel bool) (string, error) { +func (appMesh *AppMesh) applyCustomOperation(namespace string, manifest string, isDel bool, kubeclients []string) (string, error) { st := status.Starting - err := appMesh.applyManifest([]byte(manifest), isDel, namespace) + err := appMesh.applyManifest([]byte(manifest), isDel, namespace, kubeclients) if err != nil { return st, ErrCustomOperation(err) } diff --git a/appmesh/install.go b/appmesh/install.go index 3913bf6..1561c0c 100644 --- a/appmesh/install.go +++ b/appmesh/install.go @@ -4,6 +4,7 @@ import ( "fmt" "strconv" "strings" + "sync" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/status" @@ -19,7 +20,7 @@ const ( ) // Installs APP-MESH service mesh using helm charts. -func (appMesh *AppMesh) installAppMesh(del bool, version, namespace string) (string, error) { +func (appMesh *AppMesh) installAppMesh(del bool, version, namespace string, kubeconfigs []string) (string, error) { appMesh.Log.Debug(fmt.Sprintf("Requested install of version: %s", version)) appMesh.Log.Debug(fmt.Sprintf("Requested action is delete: %v", del)) appMesh.Log.Debug(fmt.Sprintf("Requested action is in namespace: %s", namespace)) @@ -35,7 +36,7 @@ func (appMesh *AppMesh) installAppMesh(del bool, version, namespace string) (str return st, ErrMeshConfig(err) } - err = appMesh.applyHelmChart(del, version, namespace) + err = appMesh.applyHelmChart(del, version, namespace, kubeconfigs) if err != nil { appMesh.Log.Error(ErrInstallAppMesh(err)) return st, ErrInstallAppMesh(err) @@ -47,11 +48,7 @@ func (appMesh *AppMesh) installAppMesh(del bool, version, namespace string) (str return status.Installed, nil } -func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string) error { - kClient := appMesh.MesheryKubeclient - if kClient == nil { - return ErrNilClient - } +func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string, kubeconfigs []string) error { version = strings.TrimPrefix(version, "v") appMesh.Log.Info("Installing using helm charts...") var act mesherykube.HelmChartAction @@ -64,51 +61,111 @@ func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string) erro if err != nil { return ErrApplyHelmChart(err) } - // Install the controller - err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ - ChartLocation: mesherykube.HelmChartLocation{ - Repository: repo, - Chart: appMeshController, - Version: cv, - }, - Namespace: namespace, - Action: act, - CreateNamespace: true, - }) - if err != nil { - return ErrApplyHelmChart(err) + + var wg sync.WaitGroup + var errs []error + var errMx sync.Mutex + + for _, config := range kubeconfigs { + wg.Add(1); + go func(config string, act mesherykube.HelmChartAction) { + defer wg.Done(); + kClient, err := mesherykube.New([]byte(config)) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + // Install the controller + err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ + ChartLocation: mesherykube.HelmChartLocation{ + Repository: repo, + Chart: appMeshController, + Version: cv, + }, + Namespace: namespace, + Action: act, + CreateNamespace: true, + }) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + // Install appmesh-injector. Only needed for controller versions older + // than 1.0.0 + if controlPlaneVersion, err := strconv.Atoi(strings.TrimPrefix(version, "v")[:1]); controlPlaneVersion < 1 && err != nil { + err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ + ChartLocation: mesherykube.HelmChartLocation{ + Repository: repo, + Chart: appMeshInject, + AppVersion: "", //defaults to latest + }, + Namespace: namespace, + Action: act, + CreateNamespace: true, + }) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + } + + + }(config, act) } - // Install appmesh-injector. Only needed for controller versions older - // than 1.0.0 - if controlPlaneVersion, err := strconv.Atoi(strings.TrimPrefix(version, "v")[:1]); controlPlaneVersion < 1 && err != nil { - err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ - ChartLocation: mesherykube.HelmChartLocation{ - Repository: repo, - Chart: appMeshInject, - AppVersion: "", //defaults to latest - }, - Namespace: namespace, - Action: act, - CreateNamespace: true, - }) - if err != nil { - return ErrApplyHelmChart(err) - } + wg.Wait() + if len(errs) == 0 { + return nil } - return err + mergedErrors := mergeErrors(errs) + return ErrApplyHelmChart(mergedErrors) } -func (appMesh *AppMesh) applyManifest(manifest []byte, isDel bool, namespace string) error { - err := appMesh.MesheryKubeclient.ApplyManifest(manifest, mesherykube.ApplyOptions{ - Namespace: namespace, - Update: true, - Delete: isDel, - }) - if err != nil { - return err +func (appMesh *AppMesh) applyManifest(manifest []byte, isDel bool, namespace string, kubeconfigs []string) error { + var wg sync.WaitGroup + var errs []error + var errMx sync.Mutex + + for _, config := range kubeconfigs { + wg.Add(1) + go func(config string) { + defer wg.Done() + kClient, err := mesherykube.New([]byte(config)) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + err = kClient.ApplyManifest(manifest, mesherykube.ApplyOptions{ + Namespace: namespace, + Update: true, + Delete: isDel, + }) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + }(config) + } + + wg.Wait() + if len(errs) == 0 { + return nil } - return nil + return mergeErrors(errs) } diff --git a/appmesh/oam.go b/appmesh/oam.go index c4b0aed..408eb54 100644 --- a/appmesh/oam.go +++ b/appmesh/oam.go @@ -9,10 +9,10 @@ import ( ) // CompHandler type functions handle OAM components -type CompHandler func(*AppMesh, v1alpha1.Component, bool) (string, error) +type CompHandler func(*AppMesh, v1alpha1.Component, bool, []string) (string, error) // HandleComponents handles the processing of OAM components -func (appMesh *AppMesh) HandleComponents(comps []v1alpha1.Component, isDel bool) (string, error) { +func (appMesh *AppMesh) HandleComponents(comps []v1alpha1.Component, isDel bool, kubeconfigs []string) (string, error) { var errs []error var msgs []string @@ -23,7 +23,7 @@ func (appMesh *AppMesh) HandleComponents(comps []v1alpha1.Component, isDel bool) for _, comp := range comps { fnc, ok := compFuncMap[comp.Spec.Type] if !ok { - msg, err := handleAppMeshCoreComponent(appMesh, comp, isDel, "", "") + msg, err := handleAppMeshCoreComponent(appMesh, comp, isDel, "", "", kubeconfigs) if err != nil { errs = append(errs, err) continue @@ -33,7 +33,7 @@ func (appMesh *AppMesh) HandleComponents(comps []v1alpha1.Component, isDel bool) continue } - msg, err := fnc(appMesh, comp, isDel) + msg, err := fnc(appMesh, comp, isDel, kubeconfigs) if err != nil { errs = append(errs, err) continue @@ -50,14 +50,14 @@ func (appMesh *AppMesh) HandleComponents(comps []v1alpha1.Component, isDel bool) } // HandleApplicationConfiguration handles the processing of OAM application configuration -func (appMesh *AppMesh) HandleApplicationConfiguration(config v1alpha1.Configuration, isDel bool) (string, error) { +func (appMesh *AppMesh) HandleApplicationConfiguration(config v1alpha1.Configuration, isDel bool, kubeconfigs []string) (string, error) { var errs []error var msgs []string for _, comp := range config.Spec.Components { for _, trait := range comp.Traits { if trait.Name == "automaticSidecarInjection.AppMesh" { namespaces := castSliceInterfaceToSliceString(trait.Properties["namespaces"].([]interface{})) - if err := handleNamespaceLabel(appMesh, namespaces, isDel); err != nil { + if err := handleNamespaceLabel(appMesh, namespaces, isDel, kubeconfigs); err != nil { errs = append(errs, err) } } @@ -74,10 +74,10 @@ func (appMesh *AppMesh) HandleApplicationConfiguration(config v1alpha1.Configura } -func handleNamespaceLabel(appMesh *AppMesh, namespaces []string, isDel bool) error { +func handleNamespaceLabel(appMesh *AppMesh, namespaces []string, isDel bool, kubeconfigs []string) error { var errs []error for _, ns := range namespaces { - if err := appMesh.LoadNamespaceToMesh(ns, isDel); err != nil { + if err := appMesh.LoadNamespaceToMesh(ns, isDel, kubeconfigs); err != nil { errs = append(errs, err) } } @@ -85,13 +85,13 @@ func handleNamespaceLabel(appMesh *AppMesh, namespaces []string, isDel bool) err return mergeErrors(errs) } -func handleComponentAppMesh(appMesh *AppMesh, comp v1alpha1.Component, isDel bool) (string, error) { +func handleComponentAppMesh(appMesh *AppMesh, comp v1alpha1.Component, isDel bool, kubeconfigs []string) (string, error) { // Get the kuma version from the settings // we are sure that the version of kuma would be present // because the configuration is already validated against the schema version := comp.Spec.Settings["version"].(string) - msg, err := appMesh.installAppMesh(isDel, version, comp.Namespace) + msg, err := appMesh.installAppMesh(isDel, version, comp.Namespace, kubeconfigs) if err != nil { return fmt.Sprintf("%s: %s", comp.Name, msg), err } @@ -104,7 +104,8 @@ func handleAppMeshCoreComponent( comp v1alpha1.Component, isDel bool, apiVersion, - kind string) (string, error) { + kind string, + kubeconfigs []string) (string, error) { if apiVersion == "" { apiVersion = getAPIVersionFromComponent(comp) if apiVersion == "" { @@ -143,7 +144,7 @@ func handleAppMeshCoreComponent( msg = fmt.Sprintf("deleted %s config \"%s\" in namespace \"%s\"", kind, comp.Name, comp.Namespace) } - return msg, appMesh.applyManifest(yamlByt, isDel, comp.Namespace) + return msg, appMesh.applyManifest(yamlByt, isDel, comp.Namespace, kubeconfigs) } func getAPIVersionFromComponent(comp v1alpha1.Component) string { diff --git a/appmesh/sample_apps.go b/appmesh/sample_apps.go index eba3cd2..69285f5 100644 --- a/appmesh/sample_apps.go +++ b/appmesh/sample_apps.go @@ -16,13 +16,15 @@ package appmesh import ( "context" + "sync" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/status" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + mesherykube "github.com/layer5io/meshkit/utils/kubernetes" ) -func (appMesh *AppMesh) installSampleApp(namespace string, del bool, templates []adapter.Template) (string, error) { +func (appMesh *AppMesh) installSampleApp(namespace string, del bool, templates []adapter.Template, kubeconfigs []string) (string, error) { st := status.Installing if del { @@ -30,7 +32,7 @@ func (appMesh *AppMesh) installSampleApp(namespace string, del bool, templates [ } for _, template := range templates { - err := appMesh.applyManifest([]byte(template.String()), del, namespace) + err := appMesh.applyManifest([]byte(template.String()), del, namespace, kubeconfigs) if err != nil { return st, ErrSampleApp(err, st) } @@ -72,25 +74,57 @@ func (appMesh *AppMesh) installSampleApp(namespace string, del bool, templates [ // LoadNamespaceToMesh enables sidecar injection on by labelling requested // namespace -func (appMesh *AppMesh) LoadNamespaceToMesh(namespace string, remove bool) error { - ns, err := appMesh.KubeClient.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{}) - if err != nil { - return ErrLoadNamespaceToMesh(err) - } - - if ns.ObjectMeta.Labels == nil { - ns.ObjectMeta.Labels = map[string]string{} +func (appMesh *AppMesh) LoadNamespaceToMesh(namespace string, remove bool, kubeconfigs []string) error { + var wg sync.WaitGroup + var errs []error + var errMx sync.Mutex + + for _, config := range kubeconfigs { + wg.Add(1) + go func(config string) { + defer wg.Done() + kClient, err := mesherykube.New([]byte(config)) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + ns, err := kClient.KubeClient.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{}) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + if ns.ObjectMeta.Labels == nil { + ns.ObjectMeta.Labels = map[string]string{} + } + //appmesh.k8s.aws/sidecarInjectorWebhook + ns.ObjectMeta.Labels["appmesh.k8s.aws/sidecarInjectorWebhook"] = "enabled" + + if remove { + ns.ObjectMeta.Labels["appmesh.k8s.aws/sidecarInjectorWebhook"] = "disabled" + } + + _, err = kClient.KubeClient.CoreV1().Namespaces().Update(context.TODO(), ns, metav1.UpdateOptions{}) + if err != nil { + errMx.Lock() + errs = append(errs, err) + errMx.Unlock() + return + } + + + }(config) } - //appmesh.k8s.aws/sidecarInjectorWebhook - ns.ObjectMeta.Labels["appmesh.k8s.aws/sidecarInjectorWebhook"] = "enabled" - if remove { - ns.ObjectMeta.Labels["appmesh.k8s.aws/sidecarInjectorWebhook"] = "disabled" + wg.Wait() + if len(errs) == 0 { + return nil } - _, err = appMesh.KubeClient.CoreV1().Namespaces().Update(context.TODO(), ns, metav1.UpdateOptions{}) - if err != nil { - return ErrLoadNamespaceToMesh(err) - } - return nil + return ErrLoadNamespaceToMesh(mergeErrors(errs)) } diff --git a/go.mod b/go.mod index f1c977c..b044a2c 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ replace ( ) require ( - github.com/layer5io/meshery-adapter-library v0.5.4 + github.com/layer5io/meshery-adapter-library v0.5.5 github.com/layer5io/meshkit v0.5.17 github.com/layer5io/service-mesh-performance v0.3.4 gopkg.in/yaml.v2 v2.4.0 diff --git a/go.sum b/go.sum index 3f48781..fd23637 100644 --- a/go.sum +++ b/go.sum @@ -878,8 +878,8 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6Fm github.com/layer5io/kuttl v0.4.1-0.20200723152044-916f10574334/go.mod h1:UmrVd7x+bNVKrpmKgTtfRiTKHZeNPcMjQproJ0vGwhE= github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34 h1:QaViadDOBCMDUwYx78kfRvHMkzRVnh/GOhm3s2gxoP4= github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34/go.mod h1:BQPLwdJt7v7y0fXIejI4whR9zMyX07Wjt5xrbgEmHLw= -github.com/layer5io/meshery-adapter-library v0.5.4 h1:QQ+nVGHd7KhV58KhY40V00kC+IEM4+AlOhQcSHSbOUE= -github.com/layer5io/meshery-adapter-library v0.5.4/go.mod h1:YmLV0w6ucBagrqUB0x9q8ZVXrhN1tJBP5j+Pu6LOY/M= +github.com/layer5io/meshery-adapter-library v0.5.5 h1:4dGsHBDCLnkOOA/RaUM5n4bPdEdySREnkd3raU9LSDI= +github.com/layer5io/meshery-adapter-library v0.5.5/go.mod h1:YmLV0w6ucBagrqUB0x9q8ZVXrhN1tJBP5j+Pu6LOY/M= github.com/layer5io/meshkit v0.5.16/go.mod h1:tj5TAjty7T/WJ8YvlDfOZF94t4g3mhWuKBCc6MOUoNU= github.com/layer5io/meshkit v0.5.17 h1:QnNuIj5CVLfaZyznEAMrwt51QImpVpQ8BTcOZOIOWhI= github.com/layer5io/meshkit v0.5.17/go.mod h1:tj5TAjty7T/WJ8YvlDfOZF94t4g3mhWuKBCc6MOUoNU= From 6f6837c540dd99c94de1c7e8de9c07038ba318fd Mon Sep 17 00:00:00 2001 From: Ruturaj Mohite Date: Sat, 4 Jun 2022 12:21:43 +0530 Subject: [PATCH 2/2] Fix static check Signed-off-by: Ruturaj Mohite --- appmesh/addons.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appmesh/addons.go b/appmesh/addons.go index bb69a0e..b26e7be 100644 --- a/appmesh/addons.go +++ b/appmesh/addons.go @@ -10,7 +10,6 @@ import ( kubernetes "github.com/layer5io/meshkit/utils/kubernetes" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - mesherykube "github.com/layer5io/meshkit/utils/kubernetes" ) func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patches []string, helmChartURL string, kubeconfigs []string) (string, error) { @@ -30,7 +29,7 @@ func (appMesh *AppMesh) installAddon(ns string, del bool, svcName string, patche wg.Add(1); go func(config string) { defer wg.Done() - kClient, err := mesherykube.New([]byte(config)) + kClient, err := kubernetes.New([]byte(config)) if err != nil { errMx.Lock() errs = append(errs, err)