@abgov/nx-oc 12.2.0 → 12.2.1
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/package.json
CHANGED
|
@@ -6,7 +6,7 @@ const pipeline_envs_1 = require("../../pipeline-envs");
|
|
|
6
6
|
const oc_utils_1 = require("../../utils/oc-utils");
|
|
7
7
|
function mapOcProject(project, i) {
|
|
8
8
|
if (typeof project === 'string') {
|
|
9
|
-
return { project
|
|
9
|
+
return { project, tag: pipeline_envs_1.pipelineEnvs[i].toLowerCase() };
|
|
10
10
|
}
|
|
11
11
|
else {
|
|
12
12
|
return project;
|
|
@@ -25,9 +25,9 @@ function runExecutor(options_1, _a) {
|
|
|
25
25
|
const failed = ocProjects
|
|
26
26
|
.map(({ project, tag }) => {
|
|
27
27
|
const processResult = (0, oc_utils_1.runOcCommand)('process', [
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
'-f', `.openshift/${projectName}/${projectName}.yml`,
|
|
29
|
+
'-p', `PROJECT=${project}`,
|
|
30
|
+
'-p', `DEPLOY_TAG=${tag}`,
|
|
31
31
|
]);
|
|
32
32
|
if (!processResult.success) {
|
|
33
33
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/src/executors/apply/apply.ts"],"names":[],"mappings":";;AAwBA,8BAkCC;;AAzDD,uDAA2D;AAC3D,mDAAoD;AAGpD,SAAS,YAAY,CACnB,OAAqC,EACrC,CAAS;IAET,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../../../../../packages/nx-oc/src/executors/apply/apply.ts"],"names":[],"mappings":";;AAwBA,8BAkCC;;AAzDD,uDAA2D;AAC3D,mDAAoD;AAGpD,SAAS,YAAY,CACnB,OAAqC,EACrC,CAAS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CAAC,GAAG,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,EAAE,CAAC,CAAC;gBAEhC,OAAO,OAAO,CAAC;YACjB,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;QAEjC,OAAO;YACL,OAAO,EAAE,CAAC,MAAM,CAAC,MAAM;SACxB,CAAC;IACJ,CAAC;CAAA"}
|
package/src/utils/git-utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function getGitRemoteUrl(): string;
|
|
1
|
+
export declare function getGitRemoteUrl(): string | undefined;
|
package/src/utils/oc-utils.js
CHANGED
|
@@ -3,16 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.runOcCommand = runOcCommand;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
function runOcCommand(command, params, input) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const args = input
|
|
7
|
+
? [command, '-f', '-', ...params]
|
|
8
|
+
: [command, ...params];
|
|
9
9
|
try {
|
|
10
|
-
console.log(`Executing command: ${
|
|
11
|
-
const stdout = (0, child_process_1.
|
|
10
|
+
console.log(`Executing command: oc ${args.join(' ')}`);
|
|
11
|
+
const stdout = (0, child_process_1.execFileSync)('oc', args, { stdio: 'pipe', input });
|
|
12
12
|
return { success: true, stdout };
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
15
|
-
console.log(`Failed to execute command: ${
|
|
15
|
+
console.log(`Failed to execute command: oc ${args.join(' ')}`, e);
|
|
16
16
|
return { success: false };
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oc-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-oc/src/utils/oc-utils.ts"],"names":[],"mappings":";;AAEA,oCAiBC;AAnBD,
|
|
1
|
+
{"version":3,"file":"oc-utils.js","sourceRoot":"","sources":["../../../../../packages/nx-oc/src/utils/oc-utils.ts"],"names":[],"mappings":";;AAEA,oCAiBC;AAnBD,iDAA6C;AAE7C,SAAgB,YAAY,CAC1B,OAAwD,EACxD,MAAgB,EAChB,KAAc;IAEd,MAAM,IAAI,GAAG,KAAK;QAChB,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;IAEzB,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,IAAA,4BAAY,EAAC,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAClE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
|
|
@@ -1,55 +1,58 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFileSync } from 'child_process';
|
|
2
2
|
import { mocked } from 'jest-mock';
|
|
3
3
|
import { runOcCommand } from './oc-utils';
|
|
4
4
|
|
|
5
5
|
jest.mock('child_process');
|
|
6
|
-
const
|
|
6
|
+
const mockedExecFileSync = mocked(execFileSync);
|
|
7
7
|
|
|
8
8
|
describe('runOcCommand', () => {
|
|
9
9
|
beforeEach(() => {
|
|
10
|
-
|
|
10
|
+
mockedExecFileSync.mockReset();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
it('returns success with stdout on successful command', () => {
|
|
14
14
|
const output = Buffer.from('project set to test-dev');
|
|
15
|
-
|
|
15
|
+
mockedExecFileSync.mockReturnValue(output);
|
|
16
16
|
|
|
17
17
|
const result = runOcCommand('project', ['test-dev']);
|
|
18
18
|
expect(result.success).toBe(true);
|
|
19
19
|
expect(result.stdout).toBe(output);
|
|
20
20
|
});
|
|
21
21
|
|
|
22
|
-
it('builds the correct
|
|
23
|
-
|
|
22
|
+
it('builds the correct args array without input', () => {
|
|
23
|
+
mockedExecFileSync.mockReturnValue(Buffer.from(''));
|
|
24
24
|
|
|
25
|
-
runOcCommand('process', ['-f .openshift/app.yml', '-p ENV=dev']);
|
|
26
|
-
expect(
|
|
27
|
-
'oc
|
|
25
|
+
runOcCommand('process', ['-f', '.openshift/app.yml', '-p', 'ENV=dev']);
|
|
26
|
+
expect(mockedExecFileSync).toHaveBeenCalledWith(
|
|
27
|
+
'oc',
|
|
28
|
+
['process', '-f', '.openshift/app.yml', '-p', 'ENV=dev'],
|
|
28
29
|
expect.objectContaining({ stdio: 'pipe' })
|
|
29
30
|
);
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
it('
|
|
33
|
-
|
|
33
|
+
it('prepends -f - when input buffer is provided', () => {
|
|
34
|
+
mockedExecFileSync.mockReturnValue(Buffer.from(''));
|
|
34
35
|
const input = Buffer.from('{"kind":"List"}');
|
|
35
36
|
|
|
36
37
|
runOcCommand('apply', [], input);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
expect(mockedExecFileSync).toHaveBeenCalledWith(
|
|
39
|
+
'oc',
|
|
40
|
+
['apply', '-f', '-'],
|
|
41
|
+
expect.objectContaining({ stdio: 'pipe' })
|
|
42
|
+
);
|
|
40
43
|
});
|
|
41
44
|
|
|
42
|
-
it('passes input buffer to
|
|
43
|
-
|
|
45
|
+
it('passes input buffer to execFileSync', () => {
|
|
46
|
+
mockedExecFileSync.mockReturnValue(Buffer.from(''));
|
|
44
47
|
const input = Buffer.from('yaml-content');
|
|
45
48
|
|
|
46
49
|
runOcCommand('apply', [], input);
|
|
47
|
-
const [, options] =
|
|
50
|
+
const [, , options] = mockedExecFileSync.mock.calls[0];
|
|
48
51
|
expect((options as { input: Buffer }).input).toBe(input);
|
|
49
52
|
});
|
|
50
53
|
|
|
51
54
|
it('returns failure when command throws', () => {
|
|
52
|
-
|
|
55
|
+
mockedExecFileSync.mockImplementation(() => {
|
|
53
56
|
throw new Error('oc: command not found');
|
|
54
57
|
});
|
|
55
58
|
|