Skip to content

Commit 7602c78

Browse files
committed
remove debug messages
1 parent a788900 commit 7602c78

File tree

11 files changed

+43
-104
lines changed

11 files changed

+43
-104
lines changed

client/src/components/addons/list.vue

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export default {
5050
const self = this;
5151
axios.get(`/api/addons`)
5252
.then(response => {
53-
console.log(response);
5453
self.addons = response.data;
5554
})
5655
.catch(error => {

client/src/components/apps/addons.vue

-3
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ export default {
151151
loadAddons() {
152152
axios.get(`/api/addons`)
153153
.then(response => {
154-
console.log(response.data);
155154
for (let addon of response.data) {
156155
this.availableAddons.push({
157156
text: addon.name,
@@ -164,13 +163,11 @@ export default {
164163
});
165164
},
166165
addonChange(event) {
167-
console.log(event);
168166
this.selectedAddon = event;
169167
},
170168
submitForm() {
171169
this.dialog = false;
172170
this.addons.push(this.selectedAddon);
173-
console.log(this.addons);
174171
}
175172
}
176173
}

client/src/components/apps/logs.vue

-14
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,7 @@ import axios from "axios";
2323
export default {
2424
sockets: {
2525
log: function(data) {
26-
console.log(data);
2726
this.loglines.unshift(data)
28-
/*
29-
NOT Need
30-
display: flex;
31-
flex-direction: column-reverse;
32-
33-
this.loglines.push(data);
34-
*/
3527
},
3628
},
3729
mounted() {
@@ -76,23 +68,17 @@ export default {
7668
},
7769
methods: {
7870
socketJoin() {
79-
console.log("socketJoin");
80-
8171
this.$socket.client.emit("join", {
8272
room: `${this.pipeline}-${this.phase}-${this.app}`,
83-
//user: this.$store.state.user.name,
8473
});
8574
},
8675
socketLeave() {
87-
console.log("socketLeave");
8876
this.$socket.client.emit("leave", {
8977
room: `${this.pipeline}-${this.phase}-${this.app}`,
90-
//user: this.$store.state.user.name,
9178
});
9279
},
9380
startLogs() {
9481
axios.get(`/api/logs/${this.pipeline}/${this.phase}/${this.app}`).then(() => {
95-
//this.podsizesList = response.data;
9682
console.log("logs started");
9783
});
9884
},

client/src/components/apps/new.vue

-2
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,6 @@ export default {
508508
methods: {
509509
loadPodsizeList() {
510510
axios.get('/api/config/podsize').then(response => {
511-
//this.podsizesList = response.data;
512511
for (let i = 0; i < response.data.length; i++) {
513512
this.podsizes.push({
514513
text: response.data[i].description,
@@ -522,7 +521,6 @@ export default {
522521
//this.podsize = podsize;
523522
},
524523
deleteAddon(addon) {
525-
//console.log(addon);
526524
527525
// remove addon in kubernetes cluster
528526
axios.delete(`/api/addons/${this.pipeline}/${this.phase}/${addon.id}`, {

client/src/components/pipelines/detail.vue

-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ export default {
8181
const self = this;
8282
axios.get('/api/pipelines/' + this.pipeline + '/apps')
8383
.then(response => {
84-
console.log(response);
8584
self.phases = response.data.phases;
8685
self.reviewapps = response.data.reviewapps;
8786
return response.data.phases;

client/src/components/pipelines/list.vue

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ export default {
8989
const self = this;
9090
axios.get(`/api/pipelines`)
9191
.then(response => {
92-
console.log(response);
93-
//self.appsList = response.data;
9492
self.apps = response.data.items;
9593
})
9694
.catch(error => {

client/src/components/pipelines/new.vue

-9
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,6 @@ export default {
281281
axios.post('/api/github/connect', {
282282
gitrepo: this.gitrepo
283283
}).then(response => {
284-
console.log(response.data);
285-
286284
//TODO check if connectiondata is valid
287285
this.github.repository = response.data.repository.data;
288286
this.github.webhook = response.data.webhook.data;
@@ -294,13 +292,6 @@ export default {
294292
});
295293
},
296294
saveForm() {
297-
/*
298-
let phasesList = [];
299-
for (let key in this.phases) {
300-
phasesList.push({name: key, enabled: this.phases[key]});
301-
}
302-
console.log(phasesList);
303-
*/
304295
axios.post(`/api/pipelines`, {
305296
pipelineName: this.pipelineName,
306297
gitrepo: this.gitrepo,

src/github/api.ts

-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export class GithubApi {
3636
owner: owner,
3737
repo: repo,
3838
})
39-
//console.log(res)
4039

4140
ret = {
4241
status: res.status,
@@ -127,7 +126,6 @@ export class GithubApi {
127126
repo: repo,
128127
})
129128
for (let webhook of existingWebhooksRes.data) {
130-
console.log(webhook)
131129
if (webhook.config.url === url) {
132130
debug.log("Webhook already exists");
133131

src/keroku.ts

+19-39
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,17 @@ export class Keroku {
2828
public config: IKuberoConfig;
2929

3030
constructor(io: Server) {
31-
console.log("keroku");
3231
this.kubectl = new Kubectl();
3332
this._io = io;
3433

3534
this.githubApi = new GithubApi(process.env.GITHUB_PERSONAL_ACCESS_TOKEN as string);
3635
this.config = this.loadConfig(process.env.KUBERO_CONFIG_PATH as string || './config.yaml');
37-
console.log(this.config);
36+
debug.debug('Kubero Config: '+JSON.stringify(this.config));
3837
}
3938

4039
public init() {
4140
this.listPipelines().then(pl => {
4241
for (const pipeline of pl.items as IPipeline[]) {
43-
//console.log(pipeline)
4442
this.pipelineStateList.push(pipeline);
4543

4644
for (const phase of pipeline.phases) {
@@ -58,10 +56,9 @@ export class Keroku {
5856
}
5957
}
6058
}
61-
//this.emitLogs('popo', 'production', 'ppppp', 'ppppp-kuberoapp-web-6ccb6795bb-48qtt', 'kuberoapp-web')
6259
}
6360
).catch(error => {
64-
console.log(error);
61+
debug.log(error);
6562
});
6663
}
6764

@@ -115,12 +112,9 @@ export class Keroku {
115112
public async newPipeline(pipeline: IPipeline) {
116113
debug.debug('create newPipeline: '+pipeline.name);
117114

118-
//console.log(pipeline.phases);
119-
120115
// Create the Pipeline CRD
121116
await this.kubectl.createPipeline(pipeline);
122117

123-
//console.log(pipeline.phases);
124118
// create namespace for each phase
125119
let secretData = {
126120
'github.pub': Buffer.from(process.env.GIT_DEPLOYMENTKEY_PUBLIC as string).toString('base64'),
@@ -317,13 +311,13 @@ export class Keroku {
317311
}
318312

319313
public async handleGithubWebhook(event: string, delivery: string, signature: string, body: any) {
320-
console.log('handleGithubWebhook');
314+
debug.log('handleGithubWebhook');
321315

322316
//https://docs.github.com/en/developers/webhooks-and-events/webhooks/securing-your-webhooks
323317
let secret = process.env.GITHUB_WEBHOOK_SECRET as string;
324318
let hash = 'sha256='+crypto.createHmac('sha256', secret).update(JSON.stringify(body)).digest('hex')
325319
if (hash === signature) {
326-
console.log('Github webhook signature is valid for event: '+delivery);
320+
debug.debug('Github webhook signature is valid for event: '+delivery);
327321

328322
switch (event) {
329323
case 'push':
@@ -333,19 +327,18 @@ export class Keroku {
333327
this.handleGithubPullRequest(body);
334328
break;
335329
default:
336-
console.log('Github webhook event not handled: '+event);
330+
debug.log('Github webhook event not handled: '+event);
337331
break;
338332
}
339-
//console.log(body);
340333
} else {
341334
debug.log('ERROR: invalid signature for event: '+delivery);
342-
console.log(hash);
343-
console.log(signature);
335+
debug.log(hash);
336+
debug.log(signature);
344337
}
345338
}
346339

347340
private async handleGithubPush(body: any) {
348-
console.log('handleGithubPush');
341+
debug.log('handleGithubPush');
349342
let ref = body.ref
350343
let refs = ref.split('/')
351344
let branch = refs[refs.length - 1]
@@ -357,7 +350,7 @@ export class Keroku {
357350
}
358351

359352
private async getAppsByBranch(branch: string) {
360-
console.log('getAppsByBranch: '+branch);
353+
debug.log('getAppsByBranch: '+branch);
361354
let apps: IApp[] = [];
362355
for (const app of this.appStateList) {
363356
if (app.branch === branch) {
@@ -368,9 +361,9 @@ export class Keroku {
368361
}
369362

370363
private async handleGithubPullRequest(body: any) {
371-
console.log('handleGithubPullRequest');
364+
debug.log('handleGithubPullRequest');
372365
let pullRequest = body.pull_request;
373-
console.log(body.action);
366+
debug.debug(body.action);
374367

375368
switch (body.action) {
376369
case 'opened':
@@ -388,15 +381,14 @@ export class Keroku {
388381
// creates a PR App in all Pipelines that have review apps enabled and the same ssh_url
389382
private async createPRApp(branch: string, title: string, ssh_url: string) {
390383
let pipelines = await this.listPipelines() as IKubectlPipelineList;
391-
//console.log(pipelines.items);
392384

393385
for (const pipeline of pipelines.items) {
394386

395387
if (pipeline.spec.reviewapps &&
396388
pipeline.spec.github.repository &&
397389
pipeline.spec.github.repository.ssh_url === ssh_url) {
398390

399-
console.log('found pipeline: '+pipeline.spec.name);
391+
debug.debug('found pipeline: '+pipeline.spec.name);
400392
let pipelaneName = pipeline.spec.name
401393
let phaseName = 'review';
402394
let websaveTitle = title.toLowerCase().replace(/[^a-z0-9-]/g, '-'); //TODO improve websave title
@@ -444,7 +436,7 @@ export class Keroku {
444436

445437
// delete a pr app in all pipelines that have review apps enabled and the same ssh_url
446438
private async deletePRApp(branch: string, title: string, ssh_url: string) {
447-
console.log('destroyPRApp');
439+
debug.log('destroyPRApp');
448440
let websaveTitle = title.toLowerCase().replace(/[^a-z0-9-]/g, '-'); //TODO improve websave title
449441

450442
for (const app of this.appStateList) {
@@ -461,11 +453,7 @@ export class Keroku {
461453

462454
private async createAddons(addons: IAddon[], namespace: string, context: string) {
463455
for (const addon of addons) {
464-
//console.log(addon);
465-
//console.log('createAddon: '+addon.name);
466456
for (const field in addon.formfields) {
467-
console.log(addon.formfields[field]);
468-
469457
let val = addon.formfields[field].default;
470458

471459
if (addon.formfields[field].type === 'number') {
@@ -475,29 +463,27 @@ export class Keroku {
475463
set(addon.crd, field, val);
476464
}
477465

478-
console.log(addon.crd);
479466
this.kubectl.createAddon(addon, namespace, context);
480467
}
481468
}
482469

483470
// delete a addon in a namespace
484471
public async deleteAddon(addon: IAddonMinimal): Promise<void> {
485-
console.log(`Deleting addon ${addon.id}`)
472+
debug.log(`Deleting addon ${addon.id}`)
486473
const contextName = this.getContext(addon.pipeline, addon.phase);
487474
if (contextName) {
488475
this.kubectl.deleteAddon(addon, contextName);
489476
}
490477
}
491478

479+
// Loads the app config from the config file
492480
private loadConfig(path:string): IKuberoConfig {
493481
try {
494-
//let config = JSON.parse(fs.readFileSync(path, 'utf8'));
495-
//let config: IKuberoConfig = require(path);
496482
let config = YAML.parse(fs.readFileSync(path, 'utf8')) as IKuberoConfig;
497483
return config;
498484
} catch (error) {
499485
debug.log('FATAL ERROR: could not load config file: '+path);
500-
console.log(error);
486+
debug.log(error);
501487
process.exit(1);
502488
}
503489
}
@@ -532,23 +518,20 @@ export class Keroku {
532518

533519
if (contextName) {
534520
this.kubectl.setCurrentContext(contextName);
535-
console.log('logs: '+podName+' '+container);
536521

537522
if (!this.podLogStreams.includes(podName)) {
538523

539524
this.kubectl.log.log(namespace, podName, container, logStream, {follow: true, tailLines: 50, pretty: false, timestamps: false})
540525
.then(res => {
541-
console.log('logs done');
526+
debug.log('logs started for '+podName+' '+container);
542527
this.podLogStreams.push(podName);
543528
})
544529
.catch(err => {
545-
console.log(err);
530+
debug.log(err);
546531
});
547532
} else {
548-
console.log('logs already running '+podName+' '+container);
533+
debug.debug('logs already running '+podName+' '+container);
549534
}
550-
}else{
551-
console.log('no context found for: '+pipelineName+' '+phaseName);
552535
}
553536
}
554537

@@ -559,7 +542,6 @@ export class Keroku {
559542
if (contextName) {
560543
this.kubectl.getPods(namespace, contextName).then((pods: any[]) => {
561544
for (const pod of pods) {
562-
//console.log(pod)
563545

564546
if (pod.metadata.name.startsWith(appName)) {
565547
for (const container of pod.spec.containers) {
@@ -568,8 +550,6 @@ export class Keroku {
568550
}
569551
}
570552
});
571-
}else{
572-
console.log('no context found for: '+pipelineName+' '+phaseName);
573553
}
574554
}
575555
}

0 commit comments

Comments
 (0)