tcurls

package module
v10.1.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2018 License: MPL-2.0 Imports: 2 Imported by: 613

README

Taskcluster URL Building Library

Build Status npm License

A simple library to generate URLs for various Taskcluster resources across our various deployment methods.

This serves as both a simple shim for projects that use JavaScript but also is the reference implementation for how we define these paths.

URLs are defined in the 'Taskcluster URL Format' document.

Changelog

View the changelog on the releases page.

Requirements

This is tested on and should run on any of Node.js {8, 10}.

JS Usage

This package exports several methods for generating URLs conditionally based on a root URL, as well as a few helper classes for generating URLs for a pre-determined root 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
  • ui(rootUrl, path) -> String
  • servicesManifest(rootUrl) -> String
  • testRootUrl() -> String
  • withRootUrl(rootUrl) -> Class instance for above methods

When the rootUrl is https://taskcluster.net, the generated URLs will be to the Heroku cluster. Otherwise they will follow the spec defined in this project.

testRootUrl is used to share a common rootUrl between various Taskcluster mocks in testing.

// 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.servicesManifest(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.servicesManifest();
urls.docs('foo/bar');

If you would like, you can set this up via taskcluster-lib-loader as follows:

{
  libUrlss: {
    require: ['cfg'],
    setup: ({cfg}) => withRootUrl(cfg.rootURl),
  },
}

Go Usage

The go package exports the following functions:

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 UI(rootURL string, path string) string
func ServicesManifest(rootURL string) string

Python Usage

You can install the python client with pip install taskcluster-urls;

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_reference(root_url, 'auth', 'v1')
taskcluster_urls.exchange_reference(root_url, 'auth', 'v1')
taskcluster_urls.ui(root_url, 'foo/bar')
taskcluster_urls.servicesManifest(root_url)
taskcluster_urls.docs(root_url, 'foo/bar')

Testing

yarn install and yarn test.

Hacking

New releases should be tested on Travis to allow for all supported versions of Node to be tested. Once satisfied that it works, new versions should be created with yarn version rather than by manually editing package.json and tags should be pushed to Github. Make sure to update the changelog!

License

Mozilla Public License Version 2.0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func API

func API(rootURL string, service string, version string, path string) string

API generates a url for a resource in a taskcluster service

func APIReference

func APIReference(rootURL string, service string, version string) string

APIReference enerates a url for a taskcluster service reference doc

func Docs

func Docs(rootURL string, path string) string

Docs generates a url for a taskcluster docs-site page

func ExchangeReference

func ExchangeReference(rootURL string, service string, version string) string

ExchangeReference generates a url for a taskcluster exchange reference doc

func Schema

func Schema(rootURL string, service string, name string) string

Schema generates a url for a taskcluster schema

func ServicesManifest

func ServicesManifest(rootURL string) string

ServicesManifest returns a URL for the service manifest of a taskcluster deployment

func UI

func UI(rootURL string, path string) string

UI generates a url for a page in taskcluster tools site

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL