Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #25 from Nike-Inc/ctorTokenFix
Browse files Browse the repository at this point in the history
use ctor token if provided
  • Loading branch information
kyeotic authored Jun 20, 2019
2 parents 31417ca + 793f0f8 commit 03adc18
Show file tree
Hide file tree
Showing 5 changed files with 1,882 additions and 1,859 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [2.0.1] - 2019-06-20
## Fixed
- Use Client ctor `token` option

## [2.0.0] - 2018-12-19
## Added
- Support for STS Authentication
Expand Down
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const cerberusVersion = 'v1'
* @type {object}
* @property {string} hostUrl required base url for the Cerberus API.
* @property {string} [region] region to sign sts auth request for, defaults to us-west-2
* @property {string} [token] Override the cerberus token. Useful for testing
* @property {boolean} [debug] If set to true additional logging occurs.
*/

Expand Down Expand Up @@ -93,11 +94,16 @@ class CerberusClient {
}
this._log = options.debug ? log : noop

// Override context with env variables
let envToken = getEnvironmentVariable(process.env.CERBERUS_TOKEN)
if (envToken) {
this._log('environment variable token found', envToken)
this._token = envToken
if (options.token) {
this._log('constructor options token found', options.token)
this._token = options.token
} else {
// Override context with env variables
let envToken = getEnvironmentVariable(process.env.CERBERUS_TOKEN)
if (envToken) {
this._log('environment variable token found', envToken)
this._token = envToken
}
}

// Validate configuration
Expand Down
Loading

0 comments on commit 03adc18

Please sign in to comment.