From f73dfee6611ab4964cccb4c2588981ae290fa309 Mon Sep 17 00:00:00 2001 From: ShifnaZarnaz Date: Fri, 7 Jun 2024 21:25:31 +0530 Subject: [PATCH] Updated the support for Provider cloud type --- .../plugin-store/plugin_deployment_handler.go | 39 ++----------------- capten/common-pkg/workers/deployment.go | 2 +- capten/model/app_types.go | 9 ----- 3 files changed, 5 insertions(+), 45 deletions(-) diff --git a/capten/common-pkg/plugin-store/plugin_deployment_handler.go b/capten/common-pkg/plugin-store/plugin_deployment_handler.go index bac354e0..82b2b333 100644 --- a/capten/common-pkg/plugin-store/plugin_deployment_handler.go +++ b/capten/common-pkg/plugin-store/plugin_deployment_handler.go @@ -3,7 +3,6 @@ package pluginstore import ( "bytes" "context" - "encoding/json" "fmt" "text/template" @@ -49,43 +48,10 @@ func (p *PluginStore) UnDeployClusterPlugin(ctx context.Context, request *cluste return nil } -// func (p *PluginStore) deployPluginWithWorkflow(pluginData *clusterpluginspb.Plugin) { -// wd := workers.NewDeployment(p.tc, p.log) -// _, err := wd.SendEventV2(context.TODO(), wd.GetPluginWorkflowName(), string(model.AppInstallAction), pluginData) -// if err != nil { -// // pluginConfig.InstallStatus = string(model.AppIntallFailedStatus) -// // if err := a.pas.UpsertPluginConfig(pluginConfig); err != nil { -// // a.log.Errorf("failed to update plugin config for plugin %s, %v", pluginConfig.PluginName, err) -// // return -// // } -// p.log.Errorf("sendEventV2 failed, plugin: %s, reason: %v", pluginData.PluginName, err) -// return -// } -// // TODO: workflow will update the final status -// // Write a periodic scheduler which will go through all apps not in installed status and check the status till either success or failed. -// // Make SendEventV2 asynchrounous so that periodic scheduler will take care of monitoring. -// } - func (p *PluginStore) deployPluginWithWorkflow(pluginData *clusterpluginspb.Plugin) { wd := workers.NewDeployment(p.tc, p.log) - - // Convert pluginData to a JSON string - pluginDataJSON, err := json.Marshal(pluginData) - if err != nil { - p.log.Errorf("failed to marshal pluginData: %s, reason: %v", pluginData.PluginName, err) - return - } - - // Create a PluginDeployRequest instance - pluginDeployRequest := &model.PluginDeployRequest{ - Data: string(pluginDataJSON), - } - //log.Println("Plugin Deploy Req", pluginDeployRequest.String()) - - // Ensure the payload is a model.DeployRequest - _, err = wd.SendEventV2(context.TODO(), wd.GetPluginWorkflowName(), string(model.AppInstallAction), pluginDeployRequest) + _, err := wd.SendEventV2(context.TODO(), wd.GetPluginWorkflowName(), string(model.AppInstallAction), pluginData) if err != nil { - // Uncomment and update the plugin configuration if needed // pluginConfig.InstallStatus = string(model.AppIntallFailedStatus) // if err := a.pas.UpsertPluginConfig(pluginConfig); err != nil { // a.log.Errorf("failed to update plugin config for plugin %s, %v", pluginConfig.PluginName, err) @@ -94,6 +60,9 @@ func (p *PluginStore) deployPluginWithWorkflow(pluginData *clusterpluginspb.Plug p.log.Errorf("sendEventV2 failed, plugin: %s, reason: %v", pluginData.PluginName, err) return } + // TODO: workflow will update the final status + // Write a periodic scheduler which will go through all apps not in installed status and check the status till either success or failed. + // Make SendEventV2 asynchrounous so that periodic scheduler will take care of monitoring. } func (p *PluginStore) unInstallPluginWithWorkflow(request *clusterpluginspb.UnDeployClusterPluginRequest, plugin *clusterpluginspb.Plugin) { diff --git a/capten/common-pkg/workers/deployment.go b/capten/common-pkg/workers/deployment.go index 29a4396b..81902094 100644 --- a/capten/common-pkg/workers/deployment.go +++ b/capten/common-pkg/workers/deployment.go @@ -95,7 +95,7 @@ func (d *Deployment) SendEventV2( return nil, err } - d.log.Infof("Sending event to temporal: workflow: %s, action: %s, payload: %s", workflowName, action, string(deployPayloadJSON)) + d.log.Infof("Sending event to temporal: workflow: %s, action: %s", workflowName, action) run, err := d.client.ExecuteWorkflow(ctx, options, workflowName, action, json.RawMessage(deployPayloadJSON)) if err != nil { d.log.Errorf("failed to send event to workflow for plugin %s, %v", deployPayload.String(), err) diff --git a/capten/model/app_types.go b/capten/model/app_types.go index 8153d413..27dda68c 100644 --- a/capten/model/app_types.go +++ b/capten/model/app_types.go @@ -31,15 +31,6 @@ type DeployRequest interface { String() string } - -type PluginDeployRequest struct { - Data string -} - -func (p *PluginDeployRequest) String() string { - return p.Data -} - type AppConfig struct { AppName string `json:"AppName,omitempty"` Version string `json:"Version,omitempty"`