Skip to content

Commit 30d9997

Browse files
committed
implement teams filter
1 parent eb67eb7 commit 30d9997

File tree

16 files changed

+167
-54
lines changed

16 files changed

+167
-54
lines changed

client/src/components/accounts/teams.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class="ma-2"
2727
color="grey"
2828
size="small"
29+
prepend-icon="mdi-account-group"
2930
>
3031
{{ item.name }}
3132
</v-chip>

client/src/components/accounts/users.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
{{ item.isActive ? 'Aktive' : 'Disabled' }}
2727
</v-chip>
2828
</template>
29-
<template v-slot:[`item.username`]="{ item }">
30-
<span>{{ item.username }}</span>
31-
</template>
3229
<template v-slot:[`item.name`]="{ item }">
3330
<span>{{ item.firstName }} {{ item.lastName }}</span>
3431
</template>
@@ -52,6 +49,7 @@
5249
class="ma-2"
5350
color="grey"
5451
size="small"
52+
prepend-icon="mdi-account-group"
5553
closable-disabled
5654
@click:close="deleteGroupFromUser(team, item)"
5755
>
@@ -75,7 +73,7 @@
7573
<v-avatar size="32" class="mr-2">
7674
<v-img :src="`/api/users/${item.id}/avatar`" />
7775
</v-avatar>
78-
<b><span>{{ item.username }}</span></b>
76+
<b><span><nobr>{{ item.username }}</nobr></span></b>
7977
</template>
8078
<template v-slot:[`item.createdAt`]="{ item }">
8179
{{ formatDate(item.createdAt) }}

client/src/components/pipelines/list.vue

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,30 @@
6868
<h3>
6969
<span class="text-h5">{{ item.name }}</span>
7070
</h3>
71+
<!--
72+
<p v-if="item.domain">
73+
<v-icon start size="small" >mdi-domain</v-icon>
74+
<span>{{ item.domain }}</span>
75+
</p>
76+
-->
77+
<p v-if="item.access?.teams && item.access.teams.length > 0">
78+
<span>
79+
<v-chip
80+
class="my-0 mx-1"
81+
color="grey"
82+
size="small"
83+
prepend-icon="mdi-account-group"
84+
v-for="team in item.access.teams" :key="team"
85+
>
86+
{{ team }}
87+
</v-chip>
88+
</span>
89+
</p>
7190
<p v-if="item.git.repository.admin">
7291
<v-icon start size="small" >mdi-link</v-icon>
7392
<span>{{ item.git.repository.description }}</span>
7493
</p>
94+
7595
</v-col>
7696
<v-col cols="12" sm="12" md="5" style="cursor: pointer;" @click="$router.push({ name: 'Pipeline Apps', params: { pipeline: item.name } })">
7797
<v-chip
@@ -132,6 +152,13 @@ const authStore = useAuthStore();
132152
133153
type Pipeline = {
134154
name: string,
155+
domain: string,
156+
buildpacks: any,
157+
reviewapps?: boolean,
158+
access?: {
159+
teams: string[],
160+
//users: string[],
161+
},
135162
git: {
136163
repository: {
137164
admin: boolean,

server/src/apps/apps.controller.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ export class AppsController {
5050
@Param('pipeline') pipeline: string,
5151
@Param('phase') phase: string,
5252
@Param('app') app: string,
53+
@Request() req: any,
5354
) {
54-
return this.appsService.getApp(pipeline, phase, app);
55+
return this.appsService.getApp(pipeline, phase, app, req.user.userGroups);
5556
}
5657

5758
@Post('/:pipeline/:phase/:app')
@@ -94,7 +95,7 @@ export class AppsController {
9495
strategy: req.user.strategy,
9596
username: req.user.username,
9697
};
97-
return this.appsService.createApp(app, user);
98+
return this.appsService.createApp(app, user, req.user.userGroups);
9899
}
99100

100101
@Put('/:pipeline/:phase/:app/:resourceVersion')
@@ -128,7 +129,7 @@ export class AppsController {
128129
strategy: req.user.strategy,
129130
username: req.user.username,
130131
};
131-
return this.appsService.updateApp(app, resourceVersion, user);
132+
return this.appsService.updateApp(app, resourceVersion, user, req.user.userGroups);
132133
}
133134

134135
@Delete('/:pipeline/:phase/:app')
@@ -153,7 +154,7 @@ export class AppsController {
153154
strategy: req.user.strategy,
154155
username: req.user.username,
155156
};
156-
return this.appsService.deleteApp(pipeline, phase, app, user);
157+
return this.appsService.deleteApp(pipeline, phase, app, user, req.user.userGroups);
157158
}
158159

159160
@Post('/pullrequest')
@@ -166,12 +167,16 @@ export class AppsController {
166167
isArray: false,
167168
})
168169
@ApiBearerAuth('bearerAuth')
169-
async startPullRequest(@Body() body: any) {
170+
async startPullRequest(
171+
@Body() body: any,
172+
@Request() req: any,
173+
) {
170174
return this.appsService.createPRApp(
171175
body.branch,
172176
body.branch,
173177
body.ssh_url,
174178
body.pipelineName,
179+
req.user.userGroups,
175180
);
176181
}
177182

@@ -189,8 +194,9 @@ export class AppsController {
189194
@Param('pipeline') pipeline: string,
190195
@Param('phase') phase: string,
191196
@Param('app') app: string,
197+
@Request() req: any,
192198
) {
193-
return this.appsService.getTemplate(pipeline, phase, app);
199+
return this.appsService.getTemplate(pipeline, phase, app, req.user.userGroups);
194200
}
195201

196202
@Get('/:pipeline/:phase/:app/restart')
@@ -216,7 +222,7 @@ export class AppsController {
216222
username: req.user.username,
217223
};
218224

219-
return this.appsService.restartApp(pipeline, phase, app, user);
225+
return this.appsService.restartApp(pipeline, phase, app, user, req.user.userGroups);
220226
}
221227

222228
@Get('/:pipeline/:phase/:app/pods')
@@ -233,8 +239,9 @@ export class AppsController {
233239
@Param('pipeline') pipeline: string,
234240
@Param('phase') phase: string,
235241
@Param('app') app: string,
242+
@Request() req: any,
236243
) {
237-
return this.appsService.getPods(pipeline, phase, app);
244+
return this.appsService.getPods(pipeline, phase, app, req.user.userGroups);
238245
}
239246

240247
@Post('/:pipeline/:phase/:app/console')
@@ -294,6 +301,7 @@ export class AppsController {
294301
containerName,
295302
command,
296303
user,
304+
req.user.userGroups,
297305
);
298306
}
299307
}

server/src/apps/apps.service.ts

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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-z0-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

Comments
 (0)