为taskcluster资源提供标准化的URL生成器。
项目描述
Taskcluster URL构建库
一个简单的库,用于生成各种Taskcluster资源在不同部署方法下的URL。
这既是一个使用JavaScript的项目的一个简单垫片,也是我们定义这些路径的参考实现。
URL在《Taskcluster URL格式》中定义。
变更日志
在发布页面上查看变更日志。
需求
该软件已在Node.js {8, 10}
上测试,并且应该在任何这些版本上运行。
通用用法
尽管函数名称的大小写和标点符号因语言而异,但每种语言都提供了以下方法
方法 | 结果 |
---|---|
api(rootUrl, service, version, path) -> | <rootUrl>/api/<service>/<version>/<path> |
apiReference(rootUrl, service, version) -> | <rootUrl>/references/<service>/<version>/api.json |
docs(rootUrl, path) -> | <rootUrl>/docs/<path> |
exchangeReference(rootUrl, service, version) -> | <rootUrl>/references/<service>/<version>/exchanges.json |
schema(rootUrl, service, schema) -> | <rootUrl>/schemas/<service>/<schema> |
apiSchema(rootUrl, version) -> | <rootUrl>/schemas/common/api-reference-<version>.json |
exchangesSchema(rootUrl, version) -> | <rootUrl>/schemas/common/exchanges-reference-<version>.json |
apiManifestSchema(rootUrl, version) -> | <rootUrl>/schemas/common/manifest-<version>.json |
metadataMchema(rootUrl) -> | <rootUrl>/schemas/common/metadata-metaschema.json |
ui(rootUrl, path) -> | <rootUrl>/<path> |
apiManifest(rootUrl) -> | <rootUrl>/references/manifest.json |
normalizeRootUrl(rootUrl) -> | 给定根URL的规范形式 |
testRootUrl() -> | https://tc-tests.example.com |
testRootUrl()
用于在测试中在不同Taskcluster模拟之间共享一个公共的假rootUrl
。此URL无法解析。
JavaScript用法
此包导出了一些方法,可以根据根URL有条件地生成URL,以及一些用于生成预定义根URL的辅助类
api(rootUrl, service, version, path)
->String
apiReference(rootUrl, service, version)
->String
docs(rootUrl, path)
->String
exchangeReference(rootUrl, service, version)
->String
schema(rootUrl, service, schema)
->String
apiManifestSchema(rootUrl, version)
->String
apiReferenceSchema(rootUrl, version)
->String
exchangesReferenceSchema(rootUrl, version)
->String
metadataMetaschema(rootUrl)
->String
ui(rootUrl, path)
->String
apiManifest(rootUrl)
->String
testRootUrl()
->String
withRootUrl(rootUrl)
-> 用于上述方法的对象实例normalizeRootUrl(rootUrl)
->String
(给定rootUrl的“规范”形式)
// Specifying root URL every time:
const libUrls = require('taskcluster-lib-urls');
libUrls.api(rootUrl, 'auth', 'v1', 'foo/bar');
libUrls.schema(rootUrl, 'auth', 'v1/foo.yml'); // Note that schema names have versions in them
libUrls.apiReference(rootUrl, 'auth', 'v1');
libUrls.exchangeReference(rootUrl, 'auth', 'v1');
libUrls.ui(rootUrl, 'foo/bar');
libUrls.apiManifest(rootUrl);
libUrls.docs(rootUrl, 'foo/bar');
// Specifying root URL in advance:
const libUrls = require('taskcluster-lib-urls');
const urls = libUrls.withRoot(rootUrl);
urls.api('auth', 'v1', 'foo/bar');
urls.schema('auth', 'v1/foo.yml');
urls.apiReference('auth', 'v1');
urls.exchangeReference('auth', 'v1');
urls.ui('foo/bar');
urls.apiManifest();
urls.docs('foo/bar');
如果您愿意,可以通过taskcluster-lib-loader设置如下
{
libUrlss: {
require: ['cfg'],
setup: ({cfg}) => withRootUrl(cfg.rootURl),
},
}
测试方法
yarn install
yarn test
Go用法
此Go包导出以下函数
func API(rootURL string, service string, version string, path string) string
func APIReference(rootURL string, service string, version string) string
func Docs(rootURL string, path string) string
func ExchangeReference(rootURL string, service string, version string) string
func Schema(rootURL string, service string, name string) string
func APIManifestSchema(rootURL string, version string) string
func APIReferenceSchema(rootURL string, version string) string
func ExchangesReferenceSchema(rootURL string, version string) string
func MetadataMetaschema(rootURL string) string
func UI(rootURL string, path string) string
func APIManifest(rootURL string) string
func NormalizeRootURL(rootURL string) string
安装方法
go install ./..
测试方法
go test -v ./...
Python用法
您可以使用pip install taskcluster-urls
安装Python客户端
import taskcluster_urls
taskcluster_urls.api(root_url, 'auth', 'v1', 'foo/bar')
taskcluster_urls.schema(root_url, 'auth', 'v1/foo.yml') # Note that schema names have versions in them
taskcluster_urls.api_manifest_schema(root_url, 'v1')
taskcluster_urls.api_reference_schema(root_url, 'v1')
taskcluster_urls.exchanges_reference_schema(root_url, 'v1')
taskcluster_urls.metadata_metaschema(root_url, 'v1')
taskcluster_urls.api_reference(root_url, 'auth', 'v1')
taskcluster_urls.exchange_reference(root_url, 'auth', 'v1')
taskcluster_urls.ui(root_url, 'foo/bar')
taskcluster_urls.apiManifest(root_url)
taskcluster_urls.docs(root_url, 'foo/bar')
taskcluster_urls.normalize_root_url(root_url)
taskcluster_urls.test_root_url()
测试方法
tox
Java用法
要在此Maven项目中使用此库,只需将其作为项目依赖项包含即可
<project>
...
<dependencies>
...
<dependency>
<groupId>org.mozilla.taskcluster</groupId>
<artifactId>taskcluster-lib-urls</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
taskcluster-lib-urls工件现在可以从Maven中央仓库获取
要使用此库,请按以下方法操作
import org.mozilla.taskcluster.urls.*;
...
URLProvider urlProvider = URLs.provider("https://mytaskcluster.acme.org");
String fooBarAPI = urlProvider.api("auth", "v1", "foo/bar");
String fooSchema = urlProvider.schema("auth", "v1/foo.yml"); // Note that schema names have versions in them
String apiSchema = urlProvider.apiReferenceSchema("v1");
String exchangesSchema = urlProvider.exchangesReferenceSchema("v1");
String manifestSchema = urlProvider.apiManifestSchema("v1");
String metaschema = urlProvider.metadataMetaschema();
String authAPIRef = urlProvider.apiReference("auth", "v1");
String authExchangesRef = urlProvider.exchangeReference("auth", "v1");
String uiFooBar = urlProvider.ui("foo/bar");
String apiManifest = urlProvider.apiManifest();
String docsFooBar = urlProvider.docs("foo/bar");
...
安装方法
mvn install
测试方法
mvn test
发布
应该在Travis和Taskcluster上测试新版本,以便测试所有支持的语言版本的各个版本。一旦满意它的工作,就应该使用npm version
而不是手动编辑package.json
来创建新版本,并将标签推送到Github。
首先制作Node版本,因为Python的版本依赖于其package.json
。这遵循了典型的打标签和推送到发布的做法
$ npm version minor # or patch, or major
$ git push upstream
完成此操作后,构建Python的sdists(只能由pypi上的维护者完成)
rm -rf dist/*
python setup.py sdist bdist_wheel
python3 setup.py bdist_wheel
pip install twine
twine upload dist/*
确保更新变更日志!
许可证
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
构建分发
taskcluster-urls-13.0.1.tar.gz 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b25e122ecec249c4299ac7b20b08db76e3e2025bdaeb699a9d444556de5fd367 |
|
MD5 | 656aca209d52aeb8aef78a79d21487f5 |
|
BLAKE2b-256 | fb482a94e0cca71acab9d5e6874c400594dafa9348b49fa226683fc815f1089d |
taskcluster_urls-13.0.1-py3-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | f66dcbd6572a6216ab65949f0fa0b91f2df647918028436c384e6af5cd12ae2b |
|
MD5 | 01765472c1daf27de72a75c299eabd19 |
|
BLAKE2b-256 | 247aa2462a171675fab3de5f8e9d7e7d1624a7cd81e305c07c00fbe39b860626 |
taskcluster_urls-13.0.1-py2-none-any.whl 的哈希
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5e25e7e6818e8877178b175ff43d2e6548afad72694aa125f404a7329ece0973 |
|
MD5 | 307f462d34842f82522d86d2e389c981 |
|
BLAKE2b-256 | 37afa4a16ff107498d056489410907c2ac140d10c00abbf0df5f42f75d8131ab |