@andrian.yablonskyy/thub-common 1.0.28 → 1.0.29
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 +1 -1
- package/src/job-spec.schema.js +6 -10
- package/src/validate-job-spec.js +5 -10
package/package.json
CHANGED
package/src/job-spec.schema.js
CHANGED
|
@@ -102,11 +102,10 @@ const DOCKER_IMAGE_PATTERN =
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
// Environment variables (`--env NAME=value`) the Client sets for every
|
|
105
|
-
// command it runs for the job — git
|
|
106
|
-
//
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
// from its database once the job ends.
|
|
105
|
+
// command it runs for the job — git and the job's command. No name
|
|
106
|
+
// means anything special. Values are secrets as far as the Coordinator
|
|
107
|
+
// is concerned: masked in the Agent API and dropped from its database
|
|
108
|
+
// once the job ends.
|
|
110
109
|
env: {
|
|
111
110
|
type: 'object',
|
|
112
111
|
maxProperties: 64,
|
|
@@ -128,9 +127,6 @@ const DOCKER_IMAGE_PATTERN =
|
|
|
128
127
|
// see README §7.1 "Dry-run the pipeline".
|
|
129
128
|
dryRun: { type: 'boolean', default: false }
|
|
130
129
|
}
|
|
131
|
-
}
|
|
130
|
+
};
|
|
132
131
|
|
|
133
|
-
|
|
134
|
-
DOCKER_LOGIN_ENV = ['DOCKER_REGISTRY', 'DOCKER_USERNAME', 'DOCKER_PASSWORD'];
|
|
135
|
-
|
|
136
|
-
module.exports = { jobSpecSchema, DOCKER_IMAGE_PATTERN, ENV_NAME_PATTERN, DOCKER_LOGIN_ENV };
|
|
132
|
+
module.exports = { jobSpecSchema, DOCKER_IMAGE_PATTERN, ENV_NAME_PATTERN };
|
package/src/validate-job-spec.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
const Ajv = require('ajv'),
|
|
17
17
|
addFormats = require('ajv-formats'),
|
|
18
|
-
{ jobSpecSchema
|
|
18
|
+
{ jobSpecSchema } = require('./job-spec.schema'),
|
|
19
19
|
{ splitArgs } = require('./split-args');
|
|
20
20
|
|
|
21
21
|
const ajv = new Ajv({ useDefaults: true, allErrors: true, strict: false });
|
|
@@ -55,8 +55,8 @@ function legacyShapeError(spec){
|
|
|
55
55
|
const GIT_URL = /^(?:(?:https?|ssh|git):\/\/[^\s]+|[A-Za-z0-9._-]+@[A-Za-z0-9.-]+:[^\s]+)$/,
|
|
56
56
|
|
|
57
57
|
// Job env names the Client sets itself for a job's commands (besides
|
|
58
|
-
// THUB_*): git's safety settings
|
|
59
|
-
RESERVED_ENV = ['GIT_TERMINAL_PROMPT', 'GIT_ALLOW_PROTOCOL'
|
|
58
|
+
// THUB_*): git's safety settings.
|
|
59
|
+
RESERVED_ENV = ['GIT_TERMINAL_PROMPT', 'GIT_ALLOW_PROTOCOL'];
|
|
60
60
|
|
|
61
61
|
// Rules across fields, spelled out here rather than as schema if/then,
|
|
62
62
|
// whose errors ("must match a schema in then") say little.
|
|
@@ -69,15 +69,10 @@ function crossFieldErrors(spec){
|
|
|
69
69
|
errors.push('/git/url must be an https://, http://, ssh:// or git:// URL, or user@host:path');
|
|
70
70
|
}
|
|
71
71
|
const envNames = Object.keys(spec.env && typeof spec.env === 'object' ? spec.env : {}),
|
|
72
|
-
reserved = envNames.filter((n) => /^THUB_/.test(n) || RESERVED_ENV.includes(n))
|
|
73
|
-
login = DOCKER_LOGIN_ENV.filter((n) => envNames.includes(n));
|
|
72
|
+
reserved = envNames.filter((n) => /^THUB_/.test(n) || RESERVED_ENV.includes(n));
|
|
74
73
|
if (reserved.length){
|
|
75
74
|
errors.push(`/env ${reserved.join(', ')}: set by the Client itself (THUB_*, ${RESERVED_ENV.join(', ')}) — use other names`);
|
|
76
75
|
}
|
|
77
|
-
if (login.length && login.length < DOCKER_LOGIN_ENV.length){
|
|
78
|
-
errors.push(`/env a Docker registry login needs all of ${DOCKER_LOGIN_ENV.join(', ')} — missing ` +
|
|
79
|
-
DOCKER_LOGIN_ENV.filter((n) => !login.includes(n)).join(', '));
|
|
80
|
-
}
|
|
81
76
|
if (spec.git?.options){
|
|
82
77
|
try {
|
|
83
78
|
splitArgs(spec.git.options);
|
|
@@ -97,4 +92,4 @@ function maskEnv(env){
|
|
|
97
92
|
|
|
98
93
|
const MASKED = '***';
|
|
99
94
|
|
|
100
|
-
module.exports = { validateJobSpec, maskEnv,
|
|
95
|
+
module.exports = { validateJobSpec, maskEnv, JOB_ENV_MASK: MASKED };
|