Module for generating/managing resource identifiers

Source:

Members

(inner, constant) VALID_ID_TYPES :Array.<string>

TYPES: 'pr', 'sha', 'time', 'ttl', 'pid', 'deployment'

Type:
  • Array.<string>
Source:

Methods

(inner) clusternatePrefixString(name) → {string}

adds CLUSTERNATOR_PREFIX to the start of a string if it is not already there

Parameters:
Name Type Description
name string

the string to prepend

Source:
Returns:
Type
string
Examples
clusternatePrefixString('bill'); // 'the-clusternator-bill'
clusternatePrefixString('the-clusternator'); // 'the-clusternator'

(inner) generatePRSubdomain(projectId, pr) → {string}

Generates a value to use as a subdomain

Parameters:
Name Type Description
projectId string
pr string

Pull Request number

Source:
Throws:
TypeError
Returns:
Type
string
Example
generatePRSubdomain('my-project', '7');
   // my-project-pr-7

(inner) generateRID(params) → {string}

Given component pieces, produce a resource identifier string

Component pieces are in the form of an object hash, like:

Parameters:
Name Type Description
params Object

a map of TYPEs to their values

Source:
Returns:
Type
string
Example
generateRID({ pid: 'my-project', pr: '5' });
     // 'the-clusternator--my-project--pr-5'

(inner) generateSubdomain(projectId, label) → {string}

Parameters:
Name Type Description
projectId string
label string
Source:
Throws:
TypeError
Returns:
Type
string
Example
generateSubdomain('my-project', 'beta');
   // my-project-beta

(inner) isPrefixed(name) → {boolean}

Determines if a given string has a clusternator prefix

Parameters:
Name Type Description
name string
Source:
Returns:
Type
boolean

(inner) isRID(rid) → {boolean}

Is the given a resource identifier?

Parameters:
Name Type Description
rid string
Source:
Returns:
Type
boolean
Examples
isRID('hello I like hamburgers'); // false
isRID('the-clusternator--my-project'); // true

(inner) mapIdSegments(idSegment) → {Object}

Extracts the key/value of an id segment and returns a map

Parameters:
Name Type Description
idSegment string
Source:
Returns:
Type
Object

(inner) parseRID(rid) → {Object}

Convert a given resource identifier into component pieces.

Component pieces are labelled based on elements in the TYPES array

RID format: typeA-valueA--typeB-valueB

Parameters:
Name Type Description
rid string
Source:
Returns:
Type
Object
Example
parseRID('the-clusternator--my-project--pr-5');
  // { pid: 'my-project', pr: '5' }

(inner) reduceSegments(memo, seg) → {Object}

Produces a complete map from the given map segments

Parameters:
Name Type Description
memo Object
seg Object
Source:
Returns:
Type
Object