1010namespace OCA \AppAPI \Command \ExApp ;
1111
1212use OCA \AppAPI \DeployActions \DockerActions ;
13+ use OCA \AppAPI \DeployActions \KubernetesActions ;
1314use OCA \AppAPI \DeployActions \ManualActions ;
1415use OCA \AppAPI \Fetcher \ExAppArchiveFetcher ;
1516use OCA \AppAPI \Fetcher \ExAppFetcher ;
@@ -32,6 +33,7 @@ public function __construct(
3233 private readonly ExAppService $ exAppService ,
3334 private readonly DaemonConfigService $ daemonConfigService ,
3435 private readonly DockerActions $ dockerActions ,
36+ private readonly KubernetesActions $ kubernetesActions ,
3537 private readonly ManualActions $ manualActions ,
3638 private readonly LoggerInterface $ logger ,
3739 private readonly ExAppArchiveFetcher $ exAppArchiveFetcher ,
@@ -138,6 +140,7 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str
138140 $ actionsDeployIds = [
139141 $ this ->dockerActions ->getAcceptsDeployId (),
140142 $ this ->manualActions ->getAcceptsDeployId (),
143+ $ this ->kubernetesActions ->getAcceptsDeployId (),
141144 ];
142145 if (!in_array ($ daemonConfig ->getAcceptsDeployId (), $ actionsDeployIds )) {
143146 $ this ->logger ->error (sprintf ('Daemon config %s actions for %s not found. ' , $ daemonConfig ->getName (), $ daemonConfig ->getAcceptsDeployId ()));
@@ -236,6 +239,43 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str
236239 (int )explode ('= ' , $ deployParams ['container_params ' ]['env ' ][6 ])[1 ],
237240 $ auth ,
238241 );
242+ } elseif ($ daemonConfig ->getAcceptsDeployId () === $ this ->kubernetesActions ->getAcceptsDeployId ()) {
243+ $ deployParams = $ this ->kubernetesActions ->buildDeployParams ($ daemonConfig , $ appInfo );
244+ $ this ->kubernetesActions ->initGuzzleClient ($ daemonConfig );
245+ $ deployResult = $ this ->kubernetesActions ->deployExApp ($ exApp , $ daemonConfig , $ deployParams );
246+ if ($ deployResult ) {
247+ $ this ->logger ->error (sprintf ('ExApp %s K8s deployment update failed. Error: %s ' , $ appId , $ deployResult ));
248+ if ($ outputConsole ) {
249+ $ output ->writeln (sprintf ('ExApp %s K8s deployment update failed. Error: %s ' , $ appId , $ deployResult ));
250+ }
251+ $ this ->exAppService ->setStatusError ($ exApp , 'K8s deployment update failed ' );
252+ return 1 ;
253+ }
254+
255+ $ k8sConfig = $ daemonConfig ->getDeployConfig ()['kubernetes ' ] ?? [];
256+ $ exposeResult = $ this ->kubernetesActions ->exposeExApp (
257+ $ this ->kubernetesActions ->buildHarpK8sUrl ($ daemonConfig ),
258+ $ appId ,
259+ (int )$ appInfo ['port ' ],
260+ $ k8sConfig
261+ );
262+ if (isset ($ exposeResult ['error ' ])) {
263+ $ this ->logger ->error (sprintf ('ExApp %s K8s expose failed. Error: %s ' , $ appId , $ exposeResult ['error ' ]));
264+ if ($ outputConsole ) {
265+ $ output ->writeln (sprintf ('ExApp %s K8s expose failed. Error: %s ' , $ appId , $ exposeResult ['error ' ]));
266+ }
267+ $ this ->exAppService ->setStatusError ($ exApp , $ exposeResult ['error ' ]);
268+ return 1 ;
269+ }
270+
271+ $ exAppUrl = $ this ->kubernetesActions ->resolveExAppUrl (
272+ $ appId ,
273+ $ daemonConfig ->getProtocol (),
274+ $ daemonConfig ->getHost (),
275+ $ daemonConfig ->getDeployConfig (),
276+ (int )$ appInfo ['port ' ],
277+ $ auth ,
278+ );
239279 } else {
240280 $ this ->manualActions ->deployExApp ($ exApp , $ daemonConfig );
241281 $ exAppUrl = $ this ->manualActions ->resolveExAppUrl (
0 commit comments