Skip to content

Commit d0980f1

Browse files
committed
add readonly feature for builds
1 parent ec876ca commit d0980f1

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

server/src/kubero.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class Kubero {
186186
debug.debug('create Pipeline: '+pipeline.name);
187187

188188
if ( process.env.KUBERO_READONLY == 'true'){
189-
console.log('KUBERO_READONLY is set to true, not deleting app');
189+
console.log('KUBERO_READONLY is set to true, not creting pipeline '+ pipeline.name);
190190
return;
191191
}
192192

@@ -216,7 +216,7 @@ export class Kubero {
216216
debug.debug('update Pipeline: '+pipeline.name);
217217

218218
if ( process.env.KUBERO_READONLY == 'true'){
219-
console.log('KUBERO_READONLY is set to true, not deleting app');
219+
console.log('KUBERO_READONLY is set to true, not updating pipelline ' + pipeline.name);
220220
return;
221221
}
222222

@@ -294,7 +294,7 @@ export class Kubero {
294294
debug.debug('deletePipeline: '+pipelineName);
295295

296296
if ( process.env.KUBERO_READONLY == 'true'){
297-
console.log('KUBERO_READONLY is set to true, not deleting app');
297+
console.log('KUBERO_READONLY is set to true, not deleting pipeline '+ pipelineName);
298298
return;
299299
}
300300

@@ -333,7 +333,7 @@ export class Kubero {
333333
debug.log('create App: '+app.name+' in '+ app.pipeline+' phase: '+app.phase + ' deploymentstrategy: '+app.deploymentstrategy);
334334

335335
if ( process.env.KUBERO_READONLY == 'true'){
336-
console.log('KUBERO_READONLY is set to true, not creating app');
336+
console.log('KUBERO_READONLY is set to true, not creating app ' + app.name);
337337
return;
338338
}
339339

@@ -371,7 +371,7 @@ export class Kubero {
371371
await this.setContext(app.pipeline, app.phase);
372372

373373
if ( process.env.KUBERO_READONLY == 'true'){
374-
console.log('KUBERO_READONLY is set to true, not deleting app');
374+
console.log('KUBERO_READONLY is set to true, not updating app ' + app.name);
375375
return;
376376
}
377377

@@ -407,7 +407,7 @@ export class Kubero {
407407
debug.debug('delete App: '+appName+' in '+ pipelineName+' phase: '+phaseName);
408408

409409
if ( process.env.KUBERO_READONLY == 'true'){
410-
console.log('KUBERO_READONLY is set to true, not deleting app');
410+
console.log('KUBERO_READONLY is set to true, not deleting app '+appName+' in '+ pipelineName+' phase: '+phaseName);
411411
return;
412412
}
413413

@@ -506,6 +506,12 @@ export class Kubero {
506506
}
507507

508508
public restartApp(pipelineName: string, phaseName: string, appName: string, user: User) {
509+
510+
if ( process.env.KUBERO_READONLY == 'true'){
511+
console.log('KUBERO_READONLY is set to true, not restarting app'+appName+' in '+ pipelineName+' phase: '+phaseName);
512+
return;
513+
}
514+
509515
debug.debug('restart App: '+appName+' in '+ pipelineName+' phase: '+phaseName);
510516
const contextName = this.getContext(pipelineName, phaseName);
511517
if (contextName) {
@@ -662,6 +668,12 @@ export class Kubero {
662668

663669
// creates a PR App in all Pipelines that have review apps enabled and the same ssh_url
664670
private async createPRApp(branch: string, title: string, ssh_url: string, pipelineName: string | undefined) {
671+
672+
if ( process.env.KUBERO_READONLY == 'true'){
673+
console.log('KUBERO_READONLY is set to true, not creating PR app '+title+' in '+ branch+' pipeline: '+pipelineName);
674+
return;
675+
}
676+
665677
debug.log('createPRApp: ', branch, title, ssh_url);
666678
let pipelines = await this.listPipelines() as IPipelineList;
667679

server/src/modules/deployments.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ export class Deployments {
210210
dockerfilePath: string,
211211
user: User
212212
): Promise<any> {
213+
214+
if ( process.env.KUBERO_READONLY == 'true'){
215+
console.log('KUBERO_READONLY is set to true, not triggering build for app: '+app + ' in pipeline: '+pipeline);
216+
return;
217+
}
218+
213219
const namespace = pipeline + "-" + phase
214220

215221
if ( process.env.KUBERO_READONLY == 'true'){
@@ -260,6 +266,12 @@ export class Deployments {
260266
}
261267

262268
public async deleteBuildjob(pipeline: string, phase: string, app: string, buildName: string, user: User): Promise<any> {
269+
270+
if ( process.env.KUBERO_READONLY == 'true'){
271+
console.log('KUBERO_READONLY is set to true, not creating app: '+app + ' in pipeline: '+pipeline);
272+
return;
273+
}
274+
263275
const namespace = pipeline + "-" + phase
264276
await this.kubectl.deleteKuberoBuildJob(namespace, buildName)
265277

0 commit comments

Comments
 (0)