@soft-artel/ci 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/k8s/App.d.ts +22 -0
- package/k8s/App.d.ts.map +1 -0
- package/k8s/App.js +130 -0
- package/k8s/App.js.map +1 -0
- package/k8s/DockerImage.d.ts +15 -0
- package/k8s/DockerImage.d.ts.map +1 -0
- package/k8s/DockerImage.js +108 -0
- package/k8s/DockerImage.js.map +1 -0
- package/k8s/Node.d.ts +17 -0
- package/k8s/Node.d.ts.map +1 -0
- package/k8s/Node.js +103 -0
- package/k8s/Node.js.map +1 -0
- package/libs/Exception.d.ts +5 -0
- package/libs/Exception.d.ts.map +1 -0
- package/libs/Exception.js +13 -0
- package/libs/Exception.js.map +1 -0
- package/libs/Git.d.ts +44 -0
- package/libs/Git.d.ts.map +1 -0
- package/libs/Git.js +160 -0
- package/libs/Git.js.map +1 -0
- package/libs/Gitlab.d.ts +12 -0
- package/libs/Gitlab.d.ts.map +1 -0
- package/libs/Gitlab.js +78 -0
- package/libs/Gitlab.js.map +1 -0
- package/libs/Jira.d.ts +31 -0
- package/libs/Jira.d.ts.map +1 -0
- package/libs/Jira.js +157 -0
- package/libs/Jira.js.map +1 -0
- package/libs/Project.d.ts +39 -0
- package/libs/Project.d.ts.map +1 -0
- package/libs/Project.js +177 -0
- package/libs/Project.js.map +1 -0
- package/libs/Reporter.d.ts +34 -0
- package/libs/Reporter.d.ts.map +1 -0
- package/libs/Reporter.js +135 -0
- package/libs/Reporter.js.map +1 -0
- package/libs/Shell.d.ts +39 -0
- package/libs/Shell.d.ts.map +1 -0
- package/libs/Shell.js +107 -0
- package/libs/Shell.js.map +1 -0
- package/libs/helpers.d.ts +29 -0
- package/libs/helpers.d.ts.map +1 -0
- package/libs/helpers.js +101 -0
- package/libs/helpers.js.map +1 -0
- package/libs/prototype.d.ts +6 -0
- package/libs/prototype.d.ts.map +1 -0
- package/libs/prototype.js +176 -0
- package/libs/prototype.js.map +1 -0
- package/package.json +53 -0
- package/sa-ci-k8s.d.ts +3 -0
- package/sa-ci-k8s.d.ts.map +1 -0
- package/sa-ci-k8s.js +183 -0
- package/sa-ci-k8s.js.map +1 -0
- package/sa-ci-xcode.d.ts +3 -0
- package/sa-ci-xcode.d.ts.map +1 -0
- package/sa-ci-xcode.js +163 -0
- package/sa-ci-xcode.js.map +1 -0
- package/upd_pkg.d.ts +3 -0
- package/upd_pkg.d.ts.map +1 -0
- package/upd_pkg.js +28 -0
- package/upd_pkg.js.map +1 -0
package/k8s/App.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import '../libs/prototype';
|
|
2
|
+
import { Project } from '../libs/Project';
|
|
3
|
+
import { DockerImage } from './DockerImage';
|
|
4
|
+
export interface Config {
|
|
5
|
+
appFile: string;
|
|
6
|
+
sharedPaths?: string[];
|
|
7
|
+
ignorePaths?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare class App {
|
|
10
|
+
group: string;
|
|
11
|
+
app: string;
|
|
12
|
+
name: string;
|
|
13
|
+
path: string;
|
|
14
|
+
$pathComp: string[];
|
|
15
|
+
constructor(path?: string);
|
|
16
|
+
writeManifest(prj: Project, image: DockerImage): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare function getApps(prj: Project, config: Config, updatedPaths: string[], maxdepth?: number, ignore?: string[]): Promise<{
|
|
19
|
+
apps: Record<string, App>;
|
|
20
|
+
updated: string[] | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
//# sourceMappingURL=App.d.ts.map
|
package/k8s/App.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../k8s/App.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAQ3B,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAI5C,MAAM,WAAW,MAAM;IAEtB,OAAO,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CAEvB;AAID,qBAAa,GAAG;IAEf,KAAK,SAAM;IACX,GAAG,SAAM;IAET,IAAI,SAAM;IACV,IAAI,SAAM;IAEV,SAAS,EAAE,MAAM,EAAE,CAAY;gBAInB,IAAI,GAAE,MAAW;IAqBvB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW;CAyDpD;AAID,wBAAsB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,MAAU,EAAE,MAAM,GAAE,MAAM,EAAyC,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,CAAC,CAsDxO"}
|
package/k8s/App.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getApps = exports.App = void 0;
|
|
16
|
+
require("../libs/prototype");
|
|
17
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
18
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
19
|
+
const fs_1 = require("fs");
|
|
20
|
+
const Shell_1 = __importDefault(require("../libs/Shell"));
|
|
21
|
+
const helpers_1 = require("../libs/helpers");
|
|
22
|
+
const Exception_1 = require("../libs/Exception");
|
|
23
|
+
class App {
|
|
24
|
+
constructor(path = '') {
|
|
25
|
+
this.group = '';
|
|
26
|
+
this.app = '';
|
|
27
|
+
this.name = '';
|
|
28
|
+
this.path = '';
|
|
29
|
+
this.$pathComp = ['./'];
|
|
30
|
+
const pathComp = path.split('/');
|
|
31
|
+
if (pathComp.length > 1) {
|
|
32
|
+
this.group = pathComp[0];
|
|
33
|
+
this.app = pathComp[1];
|
|
34
|
+
this.name = `${this.group}-${this.app}`;
|
|
35
|
+
this.path = path;
|
|
36
|
+
this.$pathComp.push(`./${this.group}/`);
|
|
37
|
+
this.$pathComp.push(`./${this.path}/`);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.app = path;
|
|
41
|
+
this.name = path;
|
|
42
|
+
this.path = '';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
writeManifest(prj, image) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const k8s_tpl_fileName = 'k8s_tpl.yaml';
|
|
48
|
+
const k8s_spec_fileName = 'k8s_spec.json';
|
|
49
|
+
let k8s_tpl = '';
|
|
50
|
+
const k8s_spec = {};
|
|
51
|
+
for (const path of this.$pathComp) {
|
|
52
|
+
const k8s_tplFile = yield Shell_1.default.cat(path + k8s_tpl_fileName, { silent: helpers_1.log.debug, ignoreError: true });
|
|
53
|
+
k8s_tpl = k8s_tplFile && k8s_tplFile !== '' ? k8s_tplFile : k8s_tpl;
|
|
54
|
+
const k8s_specFile = yield Shell_1.default.cat(path + k8s_spec_fileName, { silent: helpers_1.log.debug, ignoreError: true });
|
|
55
|
+
if (k8s_specFile && k8s_specFile !== '') {
|
|
56
|
+
try {
|
|
57
|
+
const sObj = JSON.parse(k8s_specFile);
|
|
58
|
+
k8s_spec.mergeFrom(sObj, true);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
helpers_1.log.error(e);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (k8s_tpl.length < 10) {
|
|
66
|
+
throw new Exception_1.Exception(`No K8s template [${k8s_tpl_fileName}] found for app:${this.name}`, this.$pathComp);
|
|
67
|
+
}
|
|
68
|
+
helpers_1.log.dbg(`${this.name} k8s specs`, k8s_spec);
|
|
69
|
+
for (const stage of prj.$stages) {
|
|
70
|
+
const k8s_data = {};
|
|
71
|
+
k8s_data.stage = stage;
|
|
72
|
+
k8s_data.app = this;
|
|
73
|
+
k8s_data.image = image;
|
|
74
|
+
k8s_data.prj = prj;
|
|
75
|
+
k8s_data.spec = k8s_spec[stage] || {};
|
|
76
|
+
k8s_data.spec.volumeMounts = k8s_data.spec.volumes;
|
|
77
|
+
const manifest = mustache_1.default.render(k8s_tpl, k8s_data);
|
|
78
|
+
js_yaml_1.default.loadAll(manifest);
|
|
79
|
+
yield Shell_1.default.mkdir(`${prj.rootPath}/_k8s/${stage}`);
|
|
80
|
+
yield fs_1.promises.writeFile(`${prj.rootPath}/_k8s/${stage}/${this.name}.yml`, manifest);
|
|
81
|
+
helpers_1.log.dbg(`[${stage}] ${this.name} writed -> ${prj.rootPath}/_k8s/${stage}/${this.name}.yml `);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.App = App;
|
|
87
|
+
function getApps(prj, config, updatedPaths, maxdepth = 3, ignore = ['*/_*', '*/\.*', '*/node_modules*']) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
Shell_1.default.cd(prj.rootPath);
|
|
90
|
+
const appsPaths = yield Shell_1.default.find(prj.rootPath, config.appFile, maxdepth, ignore);
|
|
91
|
+
const ignorePaths = [...config.ignorePaths || [], ...config.sharedPaths || []];
|
|
92
|
+
const apps = {};
|
|
93
|
+
const watchPaths = {};
|
|
94
|
+
for (const file of appsPaths.sort()) {
|
|
95
|
+
const path = file.replace(prj.rootPath + '/', '').replace('/' + config.appFile, '');
|
|
96
|
+
if (path === '' || ignorePaths.includes(path)) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const app = new App(path);
|
|
100
|
+
if (app.name === config.appFile) {
|
|
101
|
+
app.name = prj.name;
|
|
102
|
+
app.app = prj.name;
|
|
103
|
+
app.group = '';
|
|
104
|
+
app.path = '';
|
|
105
|
+
}
|
|
106
|
+
apps[app.name] = app;
|
|
107
|
+
watchPaths[app.path] = app.name;
|
|
108
|
+
}
|
|
109
|
+
helpers_1.log.dbg(`Find apps by ${config.appFile}`, Object.keys(apps).sort());
|
|
110
|
+
const sharedPaths = config.sharedPaths || [];
|
|
111
|
+
const watchPathsArr = Object.keys(watchPaths);
|
|
112
|
+
let appsChanged = {};
|
|
113
|
+
for (const file of updatedPaths) {
|
|
114
|
+
if (sharedPaths.includes(file)) {
|
|
115
|
+
appsChanged = apps;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
for (const testPath of watchPathsArr) {
|
|
119
|
+
const appName = watchPaths[testPath];
|
|
120
|
+
if ((RegExp(testPath).exec(file)) && apps[appName] && appsChanged[appName] === undefined) {
|
|
121
|
+
appsChanged[appName] = apps[appName];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const changed = Object.keys(appsChanged);
|
|
126
|
+
return { apps, updated: changed.length > 0 ? changed : undefined };
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.getApps = getApps;
|
|
130
|
+
//# sourceMappingURL=App.js.map
|
package/k8s/App.js.map
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AAW,GAAwB,EAAE,CAAC;QAE1C,KAAK,MAAM,IAAI,IAAI,YAAY,EAAE;YAEhC,IAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAC;gBAC7B,WAAW,GAAG,IAAI,CAAC;gBACnB,MAAM;aACN;YAED,KAAI,MAAM,QAAQ,IAAI,aAAa,EAAC;gBACnC,MAAM,OAAO,GAAG,UAAU,CAAE,QAAQ,CAAE,CAAC;gBACvC,IAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAE,OAAO,CAAE,IAAI,WAAW,CAAE,OAAO,CAAE,KAAK,SAAS,EAAC;oBAC3F,WAAW,CAAE,OAAO,CAAE,GAAG,IAAI,CAAE,OAAO,CAAE,CAAC;iBACzC;aACD;SACD;QAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAEpE,CAAC;CAAA;AAtDD,0BAsDC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type DockerImagePrebuildAction = (img: DockerImage) => void;
|
|
2
|
+
export declare class DockerImage {
|
|
3
|
+
path: string;
|
|
4
|
+
key: string;
|
|
5
|
+
srcImage: string;
|
|
6
|
+
tag: string;
|
|
7
|
+
fullTag: string;
|
|
8
|
+
$prebuild_typed?: DockerImagePrebuildAction;
|
|
9
|
+
constructor(path: string, ver: string, build: number);
|
|
10
|
+
prebuild(): Promise<void>;
|
|
11
|
+
build(): Promise<void>;
|
|
12
|
+
push(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=DockerImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockerImage.d.ts","sourceRoot":"","sources":["../../k8s/DockerImage.ts"],"names":[],"mappings":"AASA,aAAK,yBAAyB,GAAG,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;AAG5D,qBAAa,WAAW;IAEvB,IAAI,SAAM;IACV,GAAG,SAAM;IAET,QAAQ,SAAM;IAEd,GAAG,SAAM;IACT,OAAO,SAAM;IAEb,eAAe,CAAC,EAAE,yBAAyB,CAAa;gBAI5C,IAAI,EAAE,MAAM,EAAG,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IA4B/C,QAAQ;IAOR,KAAK;IAOL,IAAI;CASV"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DockerImage = void 0;
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const helpers_1 = require("../libs/helpers");
|
|
18
|
+
const Shell_1 = __importDefault(require("../libs/Shell"));
|
|
19
|
+
const ENV = process.env;
|
|
20
|
+
const PREBUILD = {};
|
|
21
|
+
class DockerImage {
|
|
22
|
+
constructor(path, ver, build) {
|
|
23
|
+
this.path = '';
|
|
24
|
+
this.key = '';
|
|
25
|
+
this.srcImage = '';
|
|
26
|
+
this.tag = '';
|
|
27
|
+
this.fullTag = '';
|
|
28
|
+
this.$prebuild_typed = undefined;
|
|
29
|
+
this.path = (0, helpers_1.resolvePath)(path);
|
|
30
|
+
const dockerfile = fs_1.default.readFileSync(this.path + '/dockerfile', 'utf8');
|
|
31
|
+
this.key = (0, helpers_1.md5)(dockerfile);
|
|
32
|
+
const dockerImage = /FROM (.+)/.exec(dockerfile);
|
|
33
|
+
if (!dockerImage || dockerImage.length < 2) {
|
|
34
|
+
throw new Error(`Wrong dockerfile format:\n${dockerfile}`);
|
|
35
|
+
}
|
|
36
|
+
this.srcImage = dockerImage[1];
|
|
37
|
+
const dockerName = /#[ ]?IMAGE NAME (.+)/.exec(dockerfile);
|
|
38
|
+
const name = dockerName && dockerName.length > 1 ? dockerName[1] : ENV.CI_PROJECT_NAME || this.key;
|
|
39
|
+
this.tag = `${name}-v${ver}:${build}`;
|
|
40
|
+
this.fullTag = `${ENV.CI_REGISTRY_IMAGE}/${this.tag}`;
|
|
41
|
+
const dockerType = /#[ ]?IMAGE TYPE (.+)/.exec(dockerfile);
|
|
42
|
+
const type = dockerType && dockerType.length > 1 ? dockerType[1].toLowerCase() : this.srcImage.split(':')[0].toLowerCase();
|
|
43
|
+
this.$prebuild_typed = PREBUILD[type];
|
|
44
|
+
}
|
|
45
|
+
prebuild() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (!this.$prebuild_typed) {
|
|
48
|
+
throw new Error(`No prebuild action for ${this.tag}`);
|
|
49
|
+
}
|
|
50
|
+
yield this.$prebuild_typed(this);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
build() {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
Shell_1.default.cd(this.path);
|
|
56
|
+
helpers_1.log.info(`Build docker image: ${this.tag}`);
|
|
57
|
+
yield Shell_1.default.exec(`docker build --platform amd64 -t ${this.fullTag} -f ${this.path}/dockerfile ${this.path}/.`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
push() {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
yield Shell_1.default.execRepeat(`docker login -u ${ENV.CI_REGISTRY_USER} -p ${ENV.CI_REGISTRY_PASSWORD} ${ENV.CI_REGISTRY}`);
|
|
63
|
+
helpers_1.log.info(`Push docker image: ${this.tag} to registry`);
|
|
64
|
+
yield Shell_1.default.execRepeat(`docker push ${this.fullTag}`);
|
|
65
|
+
helpers_1.log.dbg(`Clear local docker image: ${this.tag}`);
|
|
66
|
+
yield Shell_1.default.exec(`docker rmi -f ${this.fullTag}`);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.DockerImage = DockerImage;
|
|
71
|
+
PREBUILD.nginx = (img) => __awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
Shell_1.default.cd(img.path);
|
|
73
|
+
const mounts = { '/etc/nginx': `${img.path}/nginx` };
|
|
74
|
+
helpers_1.log.info(`Test nginx configs`);
|
|
75
|
+
yield run(img.srcImage, 'nginx -t', mounts);
|
|
76
|
+
yield run('yandex/gixy', 'yandex/gixy /etc/nginx/nginx.conf', mounts);
|
|
77
|
+
});
|
|
78
|
+
PREBUILD.gateway = (img) => __awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
Shell_1.default.cd(img.path);
|
|
80
|
+
const mounts = { '/etc/nginx': `${img.path}/nginx`, '/etc/certs': `${img.path}/certs` };
|
|
81
|
+
helpers_1.log.info(`Test gateway nginx configs`);
|
|
82
|
+
yield run(img.srcImage, 'nginx -t', mounts);
|
|
83
|
+
yield run('yandex/gixy', 'yandex/gixy /etc/nginx/nginx.conf', mounts);
|
|
84
|
+
});
|
|
85
|
+
PREBUILD.spa = (img) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
Shell_1.default.cd(img.path);
|
|
87
|
+
yield PREBUILD.nginx(img);
|
|
88
|
+
helpers_1.log.info(`Test and Distrib WEB SPA sources`);
|
|
89
|
+
yield Shell_1.default.exec(`npm run distrib`);
|
|
90
|
+
});
|
|
91
|
+
PREBUILD.node = (img) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
Shell_1.default.cd(img.path);
|
|
93
|
+
helpers_1.log.info(`Test and Distrib Node sources`);
|
|
94
|
+
yield Shell_1.default.exec(`npm run distrib`);
|
|
95
|
+
});
|
|
96
|
+
function run(srcImage, cmd, mnt) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
let extCmd = `docker run --rm`;
|
|
99
|
+
for (const path in mnt) {
|
|
100
|
+
if (mnt.hasOwnProperty(path)) {
|
|
101
|
+
extCmd += ` -v ${mnt[path]}:${path}`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
extCmd += ` ${srcImage} ${cmd}`;
|
|
105
|
+
yield Shell_1.default.exec(`${extCmd}`);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=DockerImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DockerImage.js","sourceRoot":"","sources":["../../k8s/DockerImage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAAoB;AAEpB,6CAAwD;AACxD,0DAAkC;AAElC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAKxB,MAAM,QAAQ,GAA8C,EAAE,CAAC;AAE/D,MAAa,WAAW;IAcvB,YAAY,IAAY,EAAG,GAAW,EAAE,KAAa;QAZrD,SAAI,GAAG,EAAE,CAAC;QACV,QAAG,GAAG,EAAE,CAAC;QAET,aAAQ,GAAG,EAAE,CAAC;QAEd,QAAG,GAAG,EAAE,CAAC;QACT,YAAO,GAAG,EAAE,CAAC;QAEb,oBAAe,GAA+B,SAAS,CAAC;QAKvD,IAAI,CAAC,IAAI,GAAI,IAAA,qBAAW,E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AC;AACrC,CAAC,CAAA,CAAC;AAIF,SAAe,GAAG,CAAC,QAAgB,EAAE,GAAW,EAAE,GAA4B;;QAC7E,IAAI,MAAM,GAAG,iBAAiB,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE;YACvB,IAAG,GAAG,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;gBAC5B,MAAM,IAAI,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;aACrC;SACD;QAED,MAAM,IAAI,IAAK,QAAS,IAAK,GAAI,EAAE,CAAC;QACpC,MAAM,eAAK,CAAC,IAAI,CAAC,GAAI,MAAO,EAAE,CAAC,CAAC;IACjC,CAAC;CAAA"}
|
package/k8s/Node.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import '../libs/prototype';
|
|
2
|
+
import { ExecOptions } from '../libs/Shell';
|
|
3
|
+
import { Stage } from '../libs/Project';
|
|
4
|
+
import { Reporter } from '../libs/Reporter';
|
|
5
|
+
export declare class Node {
|
|
6
|
+
configFile: string;
|
|
7
|
+
namespace: string;
|
|
8
|
+
constructor(stage: Stage);
|
|
9
|
+
applyObject(manifestObj: Record<string, any>): Promise<void>;
|
|
10
|
+
apply(manifestFile: string, appName: string): Promise<{
|
|
11
|
+
valid: boolean;
|
|
12
|
+
msg: string;
|
|
13
|
+
}>;
|
|
14
|
+
status(reporter?: Reporter | undefined, appsOnly?: boolean): Promise<string[]>;
|
|
15
|
+
exec(cmd: string, opt?: ExecOptions | undefined, cmdPrefix?: string): Promise<string>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=Node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Node.d.ts","sourceRoot":"","sources":["../../k8s/Node.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,CAAC;AAI3B,OAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAO5C,qBAAa,IAAI;IAEhB,UAAU,SAAM;IAChB,SAAS,SAAM;gBAIH,KAAK,EAAE,KAAK;IAmBlB,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAO5C,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,CAAC;IAyCpF,MAAM,CAAC,QAAQ,GAAE,QAAQ,GAAG,SAAqB,EAAE,QAAQ,GAAE,OAAc,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAyB/F,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,GAAE,WAAW,GAAG,SAAqB,EAAE,SAAS,SAAK,GAAG,OAAO,CAAC,MAAM,CAAC;CAIlG"}
|
package/k8s/Node.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Node = void 0;
|
|
16
|
+
require("../libs/prototype");
|
|
17
|
+
const js_yaml_1 = __importDefault(require("js-yaml"));
|
|
18
|
+
const Shell_1 = __importDefault(require("../libs/Shell"));
|
|
19
|
+
const helpers_1 = require("../libs/helpers");
|
|
20
|
+
const Exception_1 = require("../libs/Exception");
|
|
21
|
+
const ENV = process.env;
|
|
22
|
+
class Node {
|
|
23
|
+
constructor(stage) {
|
|
24
|
+
this.configFile = '';
|
|
25
|
+
this.namespace = '';
|
|
26
|
+
this.namespace = stage;
|
|
27
|
+
const configKey = `K8S_${stage.toUpperCase()}_CONFIG`;
|
|
28
|
+
let configFile = ENV[configKey];
|
|
29
|
+
if (stage !== 'prod' && !configFile) {
|
|
30
|
+
configFile = ENV.K8S_STAGES_CONFIG;
|
|
31
|
+
}
|
|
32
|
+
if (!configFile) {
|
|
33
|
+
throw new Exception_1.Exception(`K8s config file not found: ${configKey}`);
|
|
34
|
+
}
|
|
35
|
+
this.configFile = (0, helpers_1.resolvePath)(configFile);
|
|
36
|
+
}
|
|
37
|
+
applyObject(manifestObj) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const manifestYaml = js_yaml_1.default.dump(manifestObj);
|
|
40
|
+
yield this.exec(`apply -f -\n${manifestYaml}`, { silent: false }, 'cat <<EOF | ');
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
apply(manifestFile, appName) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
let status;
|
|
46
|
+
try {
|
|
47
|
+
yield this.exec(`apply -f ${manifestFile} --dry-run=server --validate='strict'`);
|
|
48
|
+
status = (yield Shell_1.default.exec(`cat ${manifestFile} | grep 'image:'`)).replace('image: ', '').replace(ENV.CI_REGISTRY_IMAGE + '/', '').trim();
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
helpers_1.log.error(e);
|
|
52
|
+
helpers_1.log.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
53
|
+
helpers_1.log.error(`VALIDATE FAIL: ${appName} at ${manifestFile}`);
|
|
54
|
+
helpers_1.log.error(e.message);
|
|
55
|
+
helpers_1.log.error(`${yield Shell_1.default.cat(manifestFile)}`);
|
|
56
|
+
helpers_1.log.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
57
|
+
return { valid: false, msg: e.message };
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
status = yield this.exec(`apply -f ${manifestFile}`);
|
|
61
|
+
yield this.exec(`rollout status deploy/${appName} --watch=true --timeout=300s`);
|
|
62
|
+
helpers_1.log.info('+++++++++++++++++++++++++++++');
|
|
63
|
+
helpers_1.log.info(`DEPLOYED: ${appName}`);
|
|
64
|
+
helpers_1.log.info(yield this.exec(`get pods --no-headers -l app=${appName} -o wide`, { ignoreError: true, silent: true }));
|
|
65
|
+
helpers_1.log.info('+++++++++++++++++++++++++++++');
|
|
66
|
+
return { valid: true, msg: status };
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
helpers_1.log.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
70
|
+
helpers_1.log.error(`DEPLOY FAIL: ${appName}`);
|
|
71
|
+
helpers_1.log.error('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
|
|
72
|
+
helpers_1.log.error(yield this.exec(`get pods --no-headers -l app=${appName} -o wide`, { ignoreError: true, silent: true }));
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
status(reporter = undefined, appsOnly = true) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
const cmd = `get pods -o=jsonpath='{range .items[*]}{"\\n"}{"<b>"}{.metadata.labels.app}{"</b> "}{range .spec.containers[*]}{.image}{end}{" "}{.metadata.labels.pod-template-hash}{" "}{.status.phase}{end}'`;
|
|
80
|
+
const statusArr = (yield this.exec(cmd)).split('\n');
|
|
81
|
+
const result = [];
|
|
82
|
+
for (const row of statusArr) {
|
|
83
|
+
if (row.length < 4 || (appsOnly && (RegExp((ENV.CI_REGISTRY_IMAGE || '')).exec(row)) === null)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
result.push(row.replace(ENV.CI_REGISTRY_IMAGE + '/', ''));
|
|
87
|
+
}
|
|
88
|
+
helpers_1.log.info(`K8S Node: ${this.namespace.toUpperCase()}`, result);
|
|
89
|
+
if (reporter) {
|
|
90
|
+
const msg = `\n<b>${this.namespace.toUpperCase()}</b> Pods:\n-----------------\n ` + result.join('\n-----------------\n ');
|
|
91
|
+
yield reporter.send(msg, '');
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exec(cmd, opt = undefined, cmdPrefix = '') {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
return Shell_1.default.exec(`${cmdPrefix}kubectl --kubeconfig ${this.configFile} -n ${this.namespace} ${cmd}`, opt);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.Node = Node;
|
|
103
|
+
//# sourceMappingURL=Node.js.map
|
package/k8s/Node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Node.js","sourceRoot":"","sources":["../../k8s/Node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6BAA2B;AAE3B,sDAA2B;AAE3B,0DAAmD;AACnD,6CAAmD;AAEnD,iDAA8C;AAG9C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;AAKxB,MAAa,IAAI;IAOhB,YAAY,KAAY;QALxB,eAAU,GAAG,EAAE,CAAC;QAChB,cAAS,GAAG,EAAE,CAAC;QAKd,IAAI,CAAC,SAAS,GAAI,KAAK,CAAC;QAExB,MAAM,SAAS,GAAG,OAAQ,KAAK,CAAC,WAAW,EAA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+1 @@
|
|
|
1
|
+
{"version":3,"file":"Exception.d.ts","sourceRoot":"","sources":["../../libs/Exception.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAU,SAAQ,KAAK;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;gBAK5B,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAW7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Exception = void 0;
|
|
4
|
+
class Exception extends Error {
|
|
5
|
+
constructor(message, params) {
|
|
6
|
+
super();
|
|
7
|
+
this.message = message;
|
|
8
|
+
this.params = params;
|
|
9
|
+
Object.setPrototypeOf(this, Exception.prototype);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Exception = Exception;
|
|
13
|
+
//# sourceMappingURL=Exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Exception.js","sourceRoot":"","sources":["../../libs/Exception.ts"],"names":[],"mappings":";;;AAAA,MAAa,SAAU,SAAQ,KAAK;IAKnC,YACC,OAAe,EACf,MAA4B;QAC5B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAKrB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACD;AAlBD,8BAkBC"}
|
package/libs/Git.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
declare class Commit {
|
|
2
|
+
date: Date;
|
|
3
|
+
sha: string;
|
|
4
|
+
msg: string;
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
constructor(row: string, delimetr: string);
|
|
8
|
+
get issuesKeys(): RegExpMatchArray;
|
|
9
|
+
}
|
|
10
|
+
declare function setOrigin(opts?: {
|
|
11
|
+
url?: string;
|
|
12
|
+
jobId?: number;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
declare function push(branch: string): Promise<void>;
|
|
15
|
+
declare function makeTag(version: string): Promise<void>;
|
|
16
|
+
declare function getTags(limit?: number, mask?: RegExp): Promise<string[]>;
|
|
17
|
+
declare function lastTag(): Promise<string | undefined>;
|
|
18
|
+
declare function existTag(version: string): Promise<string | undefined>;
|
|
19
|
+
declare function getCommitsAndIssues(opt: {
|
|
20
|
+
onlyJira?: boolean;
|
|
21
|
+
limit?: number;
|
|
22
|
+
fromTag: string;
|
|
23
|
+
toTag: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
commits: Record<string, any>;
|
|
26
|
+
issues: Record<string, any>;
|
|
27
|
+
}>;
|
|
28
|
+
declare function getDiffFiles(fromTag?: string, opt?: {
|
|
29
|
+
silent: boolean;
|
|
30
|
+
ignoreError: boolean;
|
|
31
|
+
}): Promise<string[]>;
|
|
32
|
+
declare const _default: {
|
|
33
|
+
Commit: typeof Commit;
|
|
34
|
+
setOrigin: typeof setOrigin;
|
|
35
|
+
push: typeof push;
|
|
36
|
+
makeTag: typeof makeTag;
|
|
37
|
+
lastTag: typeof lastTag;
|
|
38
|
+
existTag: typeof existTag;
|
|
39
|
+
getTags: typeof getTags;
|
|
40
|
+
getCommitsAndIssues: typeof getCommitsAndIssues;
|
|
41
|
+
getDiffFiles: typeof getDiffFiles;
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
44
|
+
//# sourceMappingURL=Git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Git.d.ts","sourceRoot":"","sources":["../../libs/Git.ts"],"names":[],"mappings":"AAYA,cAAM,MAAM;IAEX,IAAI,OAAgD;IACpD,GAAG,SAA6B;IAChC,GAAG,SAAiC;IACpC,IAAI,SAA+B;IACnC,KAAK,SAA8B;gBAEvB,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAczC,IAAI,UAAU,qBAGb;CAED;AAKD,iBAAe,SAAS,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAM,iBAYlE;AAID,iBAAe,IAAI,CAAC,MAAM,EAAE,MAAM,iBAGjC;AAID,iBAAe,OAAO,CAAC,OAAO,EAAE,MAAM,iBAIrC;AAID,iBAAe,OAAO,CAAC,KAAK,SAAO,EAAE,IAAI,SAA0B,qBAuBlE;AAID,iBAAe,OAAO,gCAMrB;AAID,iBAAe,QAAQ,CAAC,OAAO,EAAE,MAAM,+BAQtC;AAID,iBAAe,mBAAmB,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC;aAKnF,OAAO,MAAM,EAAE,GAAG,CAAC;YAAU,OAAO,MAAM,EAAE,GAAG,CAAC;GAuCzE;AAID,iBAAe,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG;;;CAAsC,qBAYtF;;;;;;;;;;;;AAID,wBAUE"}
|