Skip to content

Commit a788900

Browse files
committed
cleanup
1 parent 1c86d70 commit a788900

File tree

9 files changed

+207
-45
lines changed

9 files changed

+207
-45
lines changed

client/src/components/apps/logs.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<v-container style="height: 80%">
3-
43
<v-row class="justify-space-between">
54
<v-col cols="6" sm="6" md="6" lg="6" xl="6">
5+
<a :href="`/#/pipeline/${pipeline}/apps`"><v-icon small>mdi-arrow-left-circle</v-icon>{{ this.pipeline }}</a>
66
<h1>Logs for {{ this.app }}</h1>
77
<p></p>
88
</v-col>
@@ -101,6 +101,8 @@ export default {
101101
</script>
102102

103103
<style lang="scss">
104+
105+
a:link { text-decoration: none;}
104106
.console {
105107
height: 100%;
106108
max-height: 1000px;

client/src/components/apps/new.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
<v-container>
44
<v-row>
55
<v-col cols="12" sm="12" md="12" lg="12" xl="12">
6-
<h2>
6+
<h2 v-if="app=='new'">
77
Create a new App in {{ this.pipeline }}
88
</h2>
9+
<h2 v-if="app!='new'">
10+
Edit {{ this.app }} in {{ this.pipeline }}
11+
</h2>
912
<p class="text-justify">
1013
in phase {{ this.phase }}
1114
</p>

client/src/components/breadcrumbs.vue

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div>
3+
<v-breadcrumbs :items="items">
4+
<template v-slot:divider>
5+
<v-icon>mdi-forward</v-icon>
6+
</template>
7+
</v-breadcrumbs>
8+
9+
<v-breadcrumbs :items="items">
10+
<template v-slot:divider>
11+
<v-icon>mdi-chevron-right</v-icon>
12+
</template>
13+
</v-breadcrumbs>
14+
</div>
15+
</template>
16+
17+
18+
<script>
19+
export default {
20+
data: () => ({
21+
items: [
22+
{
23+
text: 'Dashboard',
24+
disabled: false,
25+
href: 'breadcrumbs_dashboard',
26+
},
27+
{
28+
text: 'Link 1',
29+
disabled: false,
30+
href: 'breadcrumbs_link_1',
31+
},
32+
{
33+
text: 'Link 2',
34+
disabled: true,
35+
href: 'breadcrumbs_link_2',
36+
},
37+
],
38+
}),
39+
}
40+
</script>

client/src/components/pipelines/appcard.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
v-if="this.domain"
6060
color="deep-purple lighten-2"
6161
text
62-
:href="'https:/'+domain" target="_blank"
62+
:href="'//'+domain" target="_blank"
6363
>
6464
<v-icon
6565
>mdi-open-in-new

client/src/components/pipelines/new.vue

+101
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,102 @@
2525
></v-text-field>
2626
</v-col>
2727
</v-row>
28+
<v-row>
29+
30+
31+
<v-col
32+
cols="12"
33+
md="6"
34+
>
35+
<v-tabs icons-and-text v-model="repotab" color="#8560A9">
36+
<v-tab href="#tab-github">Github <v-icon>mdi-github</v-icon> </v-tab>
37+
<v-tab href="#tab-gitlab">Gitlab <v-icon>mdi-gitlab</v-icon></v-tab>
38+
<v-tab href="#tab-bitbucket" disabled>Bitbucket <v-icon>mdi-bitbucket</v-icon></v-tab>
39+
</v-tabs>
40+
41+
<v-tabs-items v-model="repotab">
42+
<v-tab-item
43+
key="1"
44+
value="tab-github"
45+
>
46+
47+
<v-card flat>
48+
<v-card-text>
49+
<v-text-field
50+
v-model="gitrepo"
51+
:rules="repositoryRules"
52+
:counter="60"
53+
label="Repository"
54+
:disabled="gitrepo_connected"
55+
required
56+
></v-text-field>
57+
<v-container
58+
v-if="!gitrepo_connected"
59+
>
60+
<v-btn
61+
color="primary"
62+
elevation="2"
63+
@click="connectGithub()"
64+
>Connect</v-btn>
65+
</v-container>
66+
<v-container
67+
v-if="gitrepo_connected"
68+
>
69+
<v-alert class="alert"
70+
type="success"
71+
elevation="6"
72+
transition="scale-transition"
73+
>Webhook created
74+
</v-alert>
75+
<v-alert class="alert"
76+
type="success"
77+
elevation="6"
78+
transition="scale-transition"
79+
>Deploy keys added
80+
</v-alert>
81+
</v-container>
82+
</v-card-text>
83+
</v-card>
84+
85+
</v-tab-item>
86+
</v-tabs-items>
87+
88+
89+
90+
91+
<v-tabs-items v-model="repotab">
92+
<v-tab-item
93+
key="2"
94+
value="tab-gitlab"
95+
>
96+
<v-card flat>
97+
<v-card-text>
98+
<v-text-field
99+
v-model="gitrepo"
100+
:rules="repositoryRules"
101+
:counter="60"
102+
label="Repository"
103+
:disabled="gitrepo_connected"
104+
required
105+
></v-text-field>
106+
107+
<v-alert class="alert"
108+
type="warning"
109+
elevation="6"
110+
transition="scale-transition"
111+
>Not implemented yet
112+
</v-alert>
113+
</v-card-text>
114+
</v-card>
115+
</v-tab-item>
116+
</v-tabs-items>
117+
118+
119+
120+
</v-col>
121+
</v-row>
122+
123+
<!--
28124
<v-row>
29125
<v-col
30126
cols="12"
@@ -77,6 +173,7 @@
77173
</v-alert>
78174
</v-col>
79175
</v-row>
176+
-->
80177
<v-row v-for="phase in phases" :key="phase.name">
81178
<v-col
82179
cols="12"
@@ -121,6 +218,7 @@
121218
import axios from "axios";
122219
export default {
123220
data: () => ({
221+
repotab: null,
124222
valid: false,
125223
pipelineName: '',
126224
reviewapps: true,
@@ -227,4 +325,7 @@ export default {
227325
.alert i.v-icon.v-icon {
228326
color: white !important;
229327
}
328+
//.v-card {
329+
// height: 100px;
330+
//}
230331
</style>

client/src/plugins/vuetify.js

+21
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
import Vue from 'vue';
22
import Vuetify from 'vuetify/lib/framework';
3+
//import colors from 'vuetify/es5/util/colors'
34

45
Vue.use(Vuetify);
56

67
export default new Vuetify({
78
});
9+
/*
10+
export default new Vuetify({
11+
theme: {
12+
dark: true,
13+
themes: {
14+
light: {
15+
primary: colors.purple,
16+
secondary: colors.grey.darken1,
17+
accent: colors.shades.black,
18+
error: colors.red.accent3,
19+
background: colors.indigo.lighten5,
20+
},
21+
dark: {
22+
primary: colors.blue.lighten3,
23+
background: colors.indigo.base,
24+
},
25+
},
26+
},
27+
});
28+
*/

src/keroku.ts

+30-38
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import debug from 'debug';
22
import { Server } from "socket.io";
3-
import { IApp, IPipeline, IKubectlAppList, IKubectlPipelineList, IPodSize, IKuberoConfig} from './types';
3+
import { IApp, IPipeline, IKubectlAppList, IKubectlPipelineList, IKubectlApp, IPodSize, IKuberoConfig} from './types';
44
import { App } from './modules/application';
55
import { GithubApi } from './github/api';
66
import { IAddon, IAddonMinimal } from './modules/addons';
@@ -68,18 +68,23 @@ export class Keroku {
6868
public getContexts() {
6969
return this.kubectl.getContexts()
7070
}
71+
public getPipelineStateList() {
72+
return this.pipelineStateList;
73+
}
7174

72-
public getContext(pipelineName: string, phaseName: string): string | undefined {
75+
public getContext(pipelineName: string, phaseName: string): string {
76+
let context: string = 'missing-'+pipelineName+'-'+phaseName;
7377
for (const pipeline of this.pipelineStateList) {
7478
if (pipeline.name == pipelineName) {
7579
for (const phase of pipeline.phases) {
7680
if (phase.name == phaseName) {
7781
//this.kubectl.setCurrentContext(phase.context);
78-
return phase.context;
82+
context = phase.context;
7983
}
8084
}
8185
}
8286
}
87+
return context
8388
}
8489

8590
public async setContext(pipelineName: string, phaseName: string): Promise<boolean> {
@@ -168,7 +173,7 @@ export class Keroku {
168173

169174
// create a new app in a specified pipeline and phase
170175
public async newApp(app: App) {
171-
debug.debug('create App: '+app.name+' in '+ app.pipeline+' phase: '+app.phase);
176+
debug.log('create App: '+app.name+' in '+ app.pipeline+' phase: '+app.phase);
172177
const contextName = this.getContext(app.pipeline, app.phase);
173178
if (contextName) {
174179
await this.kubectl.createApp(app, contextName);
@@ -181,7 +186,7 @@ export class Keroku {
181186
}
182187

183188
// update an app in a pipeline and phase
184-
public async updateApp(app: App, envvars: { name: string; value: string; }[], resourceVersion: string) { //TODO remove env vars
189+
public async updateApp(app: App, resourceVersion: string) {
185190
debug.debug('update App: '+app.name+' in '+ app.pipeline+' phase: '+app.phase);
186191
await this.setContext(app.pipeline, app.phase);
187192

@@ -229,45 +234,32 @@ export class Keroku {
229234
}
230235

231236
// list all apps in a pipeline
232-
public async listApps(pipelineName: string) {
237+
public async getPipelineWithApps(pipelineName: string) {
233238
debug.debug('listApps in '+pipelineName);
234239
await this.kubectl.setCurrentContext(process.env.KUBERO_CONTEXT || 'default');
235-
let kpipeline = await this.kubectl.getPipeline(pipelineName);
236-
240+
const kpipeline = await this.kubectl.getPipeline(pipelineName);
237241
let pipeline = kpipeline.spec
238-
//await pipeline.phases.forEach(async (phase, key) => { // does not work, wait for all iterations to finish
239-
await Promise.all(pipeline.phases.map(async (phase, key) => {
240-
241-
console.log(phase.name)
242-
const namespace = pipeline.name+'-'+phase.name;
243-
let apps = await this.kubectl.getAppsList(namespace, phase.context);
244-
245-
pipeline.phases[key].apps = [];
246-
for (const app of apps.items) {
247-
pipeline.phases[key].apps.push(app.spec);
248-
}
249-
250-
}));
251-
/*
252-
if (pipeline.reviewapps) {
253-
254-
let review = {
255-
"enabled": true,
256-
"name": "review",
257-
"context": "", // Importand TODO: get the context from the pipeline
258-
"apps": Array()
259-
}
260242

261-
let apps = await this.kubectl.getAppsList(pipelineName+"-review");
262-
for (const app of apps.items) {
263-
review.apps.push(app.spec);
243+
if (pipeline) {
244+
for (const phase of pipeline.phases) {
245+
if (phase.enabled == true) {
246+
247+
const contextName = this.getContext(pipelineName, phase.name);
248+
if (contextName) {
249+
const namespace = pipelineName+'-'+phase.name;
250+
let apps = await this.kubectl.getAppsList(namespace, contextName);
251+
252+
let appslist = new Array();
253+
for (const app of apps.items) {
254+
appslist.push(app.spec);
255+
}
256+
// @ts-expect-error ts(2532) FIXME: Object is possibly 'undefined'.
257+
pipeline.phases.find(p => p.name == phase.name).apps = appslist;
258+
259+
}
260+
}
264261
}
265-
266-
pipeline.phases.unshift(review);
267-
268262
}
269-
*/
270-
271263
return pipeline;
272264
}
273265

src/modules/application.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class KubectlApp implements IKubectlApp{
1717
manager: 'kubero',
1818
}
1919
}
20-
this.spec = {} as IApp; // TODO: create a real object to keep it tyope safe
20+
this.spec = {} as IApp;
2121
}
2222
}
2323

src/routes.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { IAddonMinimal } from './modules/addons';
66
export const Router = express.Router();
77

88
Router.get('/config', async function (req: Request, res: Response) {
9-
res.send("config");
9+
let debug: any = {};
10+
debug['pipelineState'] = req.app.locals.keroku.getPipelineStateList();
11+
debug['appStateList'] = await req.app.locals.keroku.getAppStateList();
12+
res.send(debug);
1013
});
1114

1215
Router.post('/pipelines', async function (req: Request, res: Response) {
@@ -118,7 +121,7 @@ Router.put('/pipelines/:pipeline/:phase/:app', async function (req: Request, res
118121

119122
let app = new App(appconfig);
120123

121-
req.app.locals.keroku.updateApp(app, req.body.envvars, req.body.resourceVersion);
124+
req.app.locals.keroku.updateApp(app, req.body.resourceVersion);
122125

123126
res.send("updated");
124127
});
@@ -131,7 +134,7 @@ Router.get('/pipelines/:pipeline/:phase/:app', async function (req: Request, res
131134

132135
// get all apps in a pipeline
133136
Router.get('/pipelines/:pipeline/apps', async function (req: Request, res: Response) {
134-
let apps = await req.app.locals.keroku.listApps(req.params.pipeline);
137+
let apps = await req.app.locals.keroku.getPipelineWithApps(req.params.pipeline);
135138
res.send(apps);
136139
});
137140

0 commit comments

Comments
 (0)