@@ -3,6 +3,7 @@ package api
3
3
import (
4
4
"context"
5
5
6
+ "github.com/kube-tarian/kad/capten/agent/internal/workers"
6
7
"github.com/kube-tarian/kad/capten/common-pkg/agentpb"
7
8
"github.com/kube-tarian/kad/capten/common-pkg/credential"
8
9
"github.com/kube-tarian/kad/capten/model"
@@ -81,3 +82,24 @@ func (a *Agent) ConfigureAppSSO(ctx context.Context,
81
82
StatusMessage : "Triggerred app upgrade" ,
82
83
}, nil
83
84
}
85
+
86
+ func (a * Agent ) upgradeAppWithWorkflow (req * model.ApplicationInstallRequest ,
87
+ appConfig * agentpb.SyncAppData ) {
88
+ wd := workers .NewDeployment (a .tc , a .log )
89
+ _ , err := wd .SendEvent (context .TODO (), wd .GetWorkflowName (), string (model .AppUpgradeAction ), req )
90
+ if err != nil {
91
+ appConfig .Config .InstallStatus = string (model .AppUpgradeFaileddStatus )
92
+ if err := a .as .UpsertAppConfig (appConfig ); err != nil {
93
+ a .log .Errorf ("failed to update app config for app %s, %v" , appConfig .Config .ReleaseName , err )
94
+ return
95
+ }
96
+ a .log .Errorf ("failed to send event to workflow for app %s, %v" , appConfig .Config .ReleaseName , err )
97
+ return
98
+ }
99
+
100
+ appConfig .Config .InstallStatus = string (model .AppUpgradedStatus )
101
+ if err := a .as .UpsertAppConfig (appConfig ); err != nil {
102
+ a .log .Errorf ("failed to update app config for app %s, %v" , appConfig .Config .ReleaseName , err )
103
+ return
104
+ }
105
+ }
0 commit comments