How to use the taskcluster-lib-urls.schema function in taskcluster-lib-urls

To help you get started, we’ve selected a few taskcluster-lib-urls examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskcluster / taskcluster / services / references / src / update.js View on Github external
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#');
    }
  });
};
github taskcluster / taskcluster / libraries / references / src / validate.js View on Github external
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`);
        }
      };
github taskcluster / taskcluster / services / references / src / update.js View on Github external
}
    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#');
    }
  });
};
github taskcluster / taskcluster / libraries / validate / src / index.js View on Github external
return _.mapValues(this._schemas, (schema, jsonName) => {
      const newSchema = _.clone(schema);
      newSchema.$id = libUrls.schema(rootUrl, this.cfg.serviceName, jsonName + '#');
      // rewrite a relative `/schemas//
github taskcluster / taskcluster / services / github / src / handlers.js View on Github external
}
  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;
  }
github taskcluster / taskcluster / libraries / references / src / validate.js View on Github external
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`);
        }
      };
github taskcluster / taskcluster / libraries / references / src / validate.js View on Github external
content.entries.forEach(({schema}) => {
          const fullSchema = libUrls.schema(references.rootUrl, content.serviceName, schema);
          recurse(fullSchema);
        });
      } else if (metadata.name === 'logs') {

taskcluster-lib-urls

Build urls for taskcluster resources.

MPL-2.0
Latest version published 4 years ago

Package Health Score

54 / 100
Full package analysis

Similar packages