Skip to content

Commit

Permalink
Updated the support for Provider cloud type
Browse files Browse the repository at this point in the history
  • Loading branch information
Shifna12Zarnaz committed Jun 7, 2024
1 parent 81054af commit f73dfee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 45 deletions.
39 changes: 4 additions & 35 deletions capten/common-pkg/plugin-store/plugin_deployment_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package pluginstore
import (
"bytes"
"context"
"encoding/json"
"fmt"
"text/template"

Expand Down Expand Up @@ -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)
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion capten/common-pkg/workers/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions capten/model/app_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit f73dfee

Please sign in to comment.