Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
serviceName = reference.exchangePrefix.split('/')[1].replace('taskcluster-', '');
}
}
reference.serviceName = serviceName;
if (!reference.version) {
reference.version = 'v1';
}
delete reference.name;
delete reference.baseUrl;
// Someday, when we are not munging the reference above, this can allow
// multiple versions of the schema. For now, assign the only schema.
if (reference.exchangePrefix) {
reference.$schema = libUrls.schema(rootUrl, 'common', 'exchanges-reference-v0.json#');
} else {
reference.$schema = libUrls.schema(rootUrl, 'common', 'api-reference-v0.json#');
}
});
};
continue;
}
if (ajv.errors) {
ajv
.errorsText(ajv.errors, {separator: '%%/%%', dataVar: 'reference'})
.split('%%/%%')
.forEach(err => problems.push(`${filename}: ${err}`));
}
}
}
// If we're still doing OK, let's check that the schema references from various
// reference entries are correctly formatted
if (!problems.length) {
const metaschemaUrl = libUrls.schema(references.rootUrl, 'common', 'metaschema.json#');
// check that a schema link is relative to the service
for (let {filename, content} of references.references) {
const checkRelativeSchema = (name, serviceName, schemaName, i) => {
if (schemaName.match(/^\/|^[a-z]*:|^\.\./)) {
problems.push(`${filename}: entries[${i}].${name} is not relative to the service`);
return;
}
const fullSchema = libUrls.schema(references.rootUrl, serviceName, schemaName);
const schema = references.getSchema(fullSchema, {skipValidation: true});
if (!schema) {
problems.push(`${filename}: entries[${i}].${name} does not exist`);
} else if (schema.$schema !== metaschemaUrl) {
problems.push(`${serviceName}/${schemaName}'s $schema is not the metaschema`);
}
};
}
reference.serviceName = serviceName;
if (!reference.version) {
reference.version = 'v1';
}
delete reference.name;
delete reference.baseUrl;
// Someday, when we are not munging the reference above, this can allow
// multiple versions of the schema. For now, assign the only schema.
if (reference.exchangePrefix) {
reference.$schema = libUrls.schema(rootUrl, 'common', 'exchanges-reference-v0.json#');
} else {
reference.$schema = libUrls.schema(rootUrl, 'common', 'api-reference-v0.json#');
}
});
};
return _.mapValues(this._schemas, (schema, jsonName) => {
const newSchema = _.clone(schema);
newSchema.$id = libUrls.schema(rootUrl, this.cfg.serviceName, jsonName + '#');
// rewrite a relative `/schemas//
}
if (!repoconf) { return; }
let groupState = 'pending';
let taskGroupId = 'nonexistent';
let graphConfig;
// Now we can try processing the config and kicking off a task.
try {
graphConfig = this.intree({
config: repoconf,
payload: message.payload,
validator: context.validator,
schema: {
0: libUrls.schema(this.rootUrl, 'github', 'v1/taskcluster-github-config.yml'),
1: libUrls.schema(this.rootUrl, 'github', 'v1/taskcluster-github-config.v1.yml'),
},
});
if (graphConfig.tasks !== undefined && !Array.isArray(graphConfig.tasks)) {
throw new Error('tasks field of .taskcluster.yml must be array of tasks or empty array');
}
if (!graphConfig.tasks || graphConfig.tasks.length === 0) {
debug(`intree config for ${organization}/${repository}@${sha} compiled with zero tasks. Skipping.`);
return;
}
} catch (e) {
debug(`.taskcluster.yml for ${organization}/${repository}@${sha} was not formatted correctly.
Leaving comment on Github.`);
await this.createExceptionComment({instGithub, organization, repository, sha, error: e, pullNumber});
return;
}
const checkRelativeSchema = (name, serviceName, schemaName, i) => {
if (schemaName.match(/^\/|^[a-z]*:|^\.\./)) {
problems.push(`${filename}: entries[${i}].${name} is not relative to the service`);
return;
}
const fullSchema = libUrls.schema(references.rootUrl, serviceName, schemaName);
const schema = references.getSchema(fullSchema, {skipValidation: true});
if (!schema) {
problems.push(`${filename}: entries[${i}].${name} does not exist`);
} else if (schema.$schema !== metaschemaUrl) {
problems.push(`${serviceName}/${schemaName}'s $schema is not the metaschema`);
}
};
content.entries.forEach(({schema}) => {
const fullSchema = libUrls.schema(references.rootUrl, content.serviceName, schema);
recurse(fullSchema);
});
} else if (metadata.name === 'logs') {