-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgenerateTemplatesConfig.js
61 lines (55 loc) · 2.26 KB
/
generateTemplatesConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* eslint-disable @typescript-eslint/no-require-imports */
const fs = require('fs');
const path = require('path');
const generateTemplatesConfig = (ocpVersion, templateName, jenkinsEnabled, tektonEnabled, actionsEnabled, gitlabEnabled, githubEnabled, gitlabciEnabled, bitbucketEnabled) => {
const config = {
templates: [
"dotnet-basic",
"go",
"nodejs",
"python",
"java-quarkus",
"java-springboot"
],
priority: [
"High"
],
github: {
tekton: tektonEnabled === 'true',
jenkins: jenkinsEnabled === 'true',
actions: actionsEnabled === 'true',
host: "https://api.github.com"
},
gitlab: {
tekton: tektonEnabled === 'true',
jenkins: jenkinsEnabled === 'true',
gitlabci: gitlabciEnabled === 'true',
host: "https://gitlab.com",
},
bitbucket: {
tekton: tektonEnabled === 'true',
jenkins: jenkinsEnabled === 'true',
host: "https://api.bitbucket.org/2.0",
},
pipeline: {
ocp: ocpVersion,
version: "1.4",
github: githubEnabled === 'true',
gitlab: gitlabEnabled === 'true',
bitbucket: bitbucketEnabled === 'true'
}
};
const jsonContent = JSON.stringify(config, null, 2);
const filePath = path.resolve(__dirname, templateName);
fs.writeFileSync(filePath, jsonContent, 'utf-8');
};
const ocpVersion = process.env.OCP_VERSION;
const templateName = process.env.SOFTWARE_TEMPLATES_FILE || 'softwareTemplates.json';
const jenkinsEnabled = process.env.JENKINS_ENABLED || 'false';
const tektonEnabled = process.env.TEKTON_ENABLED || 'false';
const actionsEnabled = process.env.ACTIONS_ENABLED || 'false' ; // Github Actions
const gitlabEnabled = process.env.GITLAB_ENABLED || 'false';
const githubEnabled = process.env.GITHUB_ENABLED || 'false';
const gitlabciEnabled = process.env.GITLABCI_ENABLED || 'false';
const bitbucketEnabled = process.env.BITBUCKET_ENABLED || 'false';
generateTemplatesConfig(ocpVersion, templateName, jenkinsEnabled, tektonEnabled, actionsEnabled, gitlabEnabled, githubEnabled, gitlabciEnabled, bitbucketEnabled);