@@ -31,13 +31,15 @@ export class AppsService {
3131 pipelineName : string ,
3232 phaseName : string ,
3333 appName : string ,
34+ userGroups : string [ ]
3435 ) {
3536 this . logger . debug (
3637 'get App: ' + appName + ' in ' + pipelineName + ' phase: ' + phaseName ,
3738 ) ;
3839 const contextName = await this . pipelinesService . getContext (
3940 pipelineName ,
4041 phaseName ,
42+ userGroups ,
4143 ) ;
4244
4345 if ( contextName ) {
@@ -58,7 +60,7 @@ export class AppsService {
5860 }
5961 }
6062
61- public async createApp ( app : App , user : IUser ) {
63+ public async createApp ( app : App , user : IUser , userGroups : string [ ] ) {
6264 this . logger . debug (
6365 'create App: ' +
6466 app . name +
@@ -80,6 +82,7 @@ export class AppsService {
8082 const contextName = await this . pipelinesService . getContext (
8183 app . pipeline ,
8284 app . phase ,
85+ userGroups ,
8386 ) ;
8487 if ( contextName ) {
8588 await this . kubectl . createApp ( app , contextName ) ;
@@ -112,7 +115,7 @@ export class AppsService {
112115 app . buildstrategy == 'nixpacks' ||
113116 app . buildstrategy == 'buildpacks' )
114117 ) {
115- this . triggerImageBuildDelayed ( app . pipeline , app . phase , app . name ) ;
118+ this . triggerImageBuildDelayed ( app . pipeline , app . phase , app . name , userGroups ) ;
116119 }
117120 }
118121 }
@@ -121,21 +124,23 @@ export class AppsService {
121124 pipeline : string ,
122125 phase : string ,
123126 appName : string ,
127+ userGroups : string [ ]
124128 ) {
125129 // delay for 2 seconds to trigger the Image build
126130 await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
127- return this . triggerImageBuild ( pipeline , phase , appName ) ;
131+ return this . triggerImageBuild ( pipeline , phase , appName , userGroups ) ;
128132 }
129133
130134 public async triggerImageBuild (
131135 pipeline : string ,
132136 phase : string ,
133137 appName : string ,
138+ userGroups : string [ ] ,
134139 ) {
135- const contextName = await this . pipelinesService . getContext ( pipeline , phase ) ;
140+ const contextName = await this . pipelinesService . getContext ( pipeline , phase , userGroups ) ;
136141 const namespace = pipeline + '-' + phase ;
137142
138- const appresult = await this . getApp ( pipeline , phase , appName ) ;
143+ const appresult = await this . getApp ( pipeline , phase , appName , userGroups ) ;
139144
140145 const app = appresult as IKubectlApp ;
141146 let repo = '' ;
@@ -190,6 +195,7 @@ export class AppsService {
190195 phaseName : string ,
191196 appName : string ,
192197 user : IUser ,
198+ userGroups : string [ ] ,
193199 ) {
194200 this . logger . debug (
195201 'delete App: ' + appName + ' in ' + pipelineName + ' phase: ' + phaseName ,
@@ -210,6 +216,7 @@ export class AppsService {
210216 const contextName = await this . pipelinesService . getContext (
211217 pipelineName ,
212218 phaseName ,
219+ userGroups ,
213220 ) ;
214221 if ( contextName ) {
215222 await this . kubectl . deleteApp (
@@ -247,6 +254,7 @@ export class AppsService {
247254 title : string ,
248255 ssh_url : string ,
249256 pipelineName : string | undefined ,
257+ userGroups : string [ ] ,
250258 ) {
251259 const podSizeList = await this . configService . getPodSizes ( ) ;
252260
@@ -384,7 +392,7 @@ export class AppsService {
384392 username : 'unknown' ,
385393 } as IUser ;
386394
387- this . createApp ( app , user ) ;
395+ this . createApp ( app , user , userGroups ) ;
388396 return { status : 'ok' , message : 'app created ' + app . name } ;
389397 }
390398 }
@@ -417,7 +425,7 @@ export class AppsService {
417425 }
418426
419427 // delete a pr app in all pipelines that have review apps enabled and the same ssh_url
420- public async deletePRApp ( branch : string , title : string , ssh_url : string ) {
428+ public async deletePRApp ( branch : string , title : string , ssh_url : string , userGroups : string [ ] ) {
421429 this . logger . debug ( 'destroyPRApp' ) ;
422430 const websaveTitle = title . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 - ] / g, '-' ) ; //TODO improve websave title
423431
@@ -436,12 +444,12 @@ export class AppsService {
436444 username : 'unknown' ,
437445 } as IUser ;
438446
439- this . deleteApp ( app . pipeline , app . phase , websaveTitle , user ) ;
447+ this . deleteApp ( app . pipeline , app . phase , websaveTitle , user , userGroups ) ;
440448 }
441449 }
442450 }
443451
444- public async rebuildApp ( app : IApp ) {
452+ public async rebuildApp ( app : IApp , userGroups : string [ ] ) {
445453 this . logger . debug (
446454 'rebuild App: ' +
447455 app . name +
@@ -454,6 +462,7 @@ export class AppsService {
454462 const contextName = await this . pipelinesService . getContext (
455463 app . pipeline ,
456464 app . phase ,
465+ userGroups ,
457466 ) ;
458467
459468 if ( contextName ) {
@@ -478,7 +487,7 @@ export class AppsService {
478487 ) ;
479488 } else {
480489 // rebuild for buildstrategy git/dockerfile or git/nixpacks
481- this . triggerImageBuild ( app . pipeline , app . phase , app . name ) ;
490+ this . triggerImageBuild ( app . pipeline , app . phase , app . name , userGroups ) ;
482491 }
483492
484493 const m = {
@@ -507,8 +516,9 @@ export class AppsService {
507516 pipelineName : string ,
508517 phaseName : string ,
509518 appName : string ,
519+ userGroups : string [ ] ,
510520 ) {
511- const app = await this . getApp ( pipelineName , phaseName , appName ) ;
521+ const app = await this . getApp ( pipelineName , phaseName , appName , userGroups ) ;
512522
513523 const a = app as IKubectlApp ;
514524 const t = new KubectlTemplate ( a . spec ) ;
@@ -527,6 +537,7 @@ export class AppsService {
527537 phaseName : string ,
528538 appName : string ,
529539 user : IUser ,
540+ userGroups : string [ ] ,
530541 ) {
531542 if ( process . env . KUBERO_READONLY == 'true' ) {
532543 console . log (
@@ -551,6 +562,7 @@ export class AppsService {
551562 const contextName = await this . pipelinesService . getContext (
552563 pipelineName ,
553564 phaseName ,
565+ userGroups ,
554566 ) ;
555567 if ( contextName ) {
556568 this . kubectl . restartApp (
@@ -591,7 +603,7 @@ export class AppsService {
591603 }
592604
593605 // update an app in a pipeline and phase
594- public async updateApp ( app : App , resourceVersion : string , user : IUser ) {
606+ public async updateApp ( app : App , resourceVersion : string , user : IUser , userGroups : string [ ] ) {
595607 this . logger . debug (
596608 'update App: ' +
597609 app . name +
@@ -612,6 +624,7 @@ export class AppsService {
612624 const contextName = await this . pipelinesService . getContext (
613625 app . pipeline ,
614626 app . phase ,
627+ userGroups ,
615628 ) ;
616629
617630 if (
@@ -620,7 +633,7 @@ export class AppsService {
620633 app . buildstrategy == 'nixpacks' ||
621634 app . buildstrategy == 'buildpacks' )
622635 ) {
623- this . triggerImageBuild ( app . pipeline , app . phase , app . name ) ;
636+ this . triggerImageBuild ( app . pipeline , app . phase , app . name , userGroups ) ;
624637 }
625638
626639 if ( contextName ) {
@@ -655,10 +668,12 @@ export class AppsService {
655668 pipelineName : string ,
656669 phaseName : string ,
657670 appName : string ,
671+ userGroups : string [ ] ,
658672 ) : Promise < Workload [ ] > {
659673 const contextName = await this . pipelinesService . getContext (
660674 pipelineName ,
661675 phaseName ,
676+ userGroups ,
662677 ) ;
663678 const namespace = pipelineName + '-' + phaseName ;
664679
@@ -711,6 +726,7 @@ export class AppsService {
711726 containerName : string ,
712727 command : string ,
713728 user : IUser ,
729+ userGroups : string [ ] ,
714730 ) {
715731 /*TODO: Fails. Needs to be loaded somewhere
716732 const settings = await this.settingsService.getSettings();
@@ -724,6 +740,7 @@ export class AppsService {
724740 const contextName = await this . pipelinesService . getContext (
725741 pipelineName ,
726742 phaseName ,
743+ userGroups ,
727744 ) ;
728745 if ( contextName ) {
729746 const streamname = `${ pipelineName } -${ phaseName } -${ appName } -${ podName } -${ containerName } -terminal` ;
0 commit comments