Skip to content

Commit

Permalink
fix(2240): Convert MULTI_BUILD_CLUSTER_ENABLED value from string to b…
Browse files Browse the repository at this point in the history
…oolean. (#2242)

* fix: convert to boolean from string

* fix function name

* add JSDoc and fix indent

* fix: convert bool function

* Include multiple revert.

This reverts commit c454744.

Revert "add JSDoc and fix indent"

This reverts commit 60836e7.

Revert "fix function name"

This reverts commit c56b045.

Revert "fix: convert to boolean from string"

This reverts commit 41d3178.

* fix: add format to MULTI_BUILD_CLUSTER_ENABLED env

* Revert "fix: add format to MULTI_BUILD_CLUSTER_ENABLED env"

This reverts commit 44a6ec4.

* Revert "Include multiple revert."

This reverts commit 6d01009.

* fix: add a true list based on yaml definition

* fix: add to single quote

* fix: space charactor

* fix: remove comment out

* fix: add .node-version on .gitignore

* fix: remove .node-version

Co-authored-by: sugarnaoming <[email protected]>
Co-authored-by: kkisic <[email protected]>
Co-authored-by: Yuichi Sawada <[email protected]>
  • Loading branch information
4 people authored Oct 19, 2020
1 parent 1b6b9b7 commit c60feaf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ docker-compose.yml
mw-data
.vscode
.envrc
.node-version
20 changes: 19 additions & 1 deletion bin/server
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ const hoek = require('@hapi/hoek');
const { Bookend } = require('screwdriver-build-bookend');
const logger = require('screwdriver-logger');

/**
* convert value to Boolean
* @method convertToBool
* @param {(Boolean|String)} value
* @return {Boolean}
*/
function convertToBool(value) {
if (typeof value === 'boolean') {
return value;
}

// trueList refers to https://yaml.org/type/bool.html
const trueList = ['on', 'true', 'yes', 'y'];
const lowerValue = String(value).toLowerCase();

return trueList.includes(lowerValue);
}

// Setup Authentication
const authConfig = config.get('auth');

Expand All @@ -29,7 +47,7 @@ ecosystem.api = httpdConfig.uri;
const notificationConfig = config.get('notifications');

// Multiple build cluster feature flag
const multiBuildClusterEnabled = config.get('multiBuildCluster').enabled;
const multiBuildClusterEnabled = convertToBool(config.get('multiBuildCluster').enabled);

// Default cluster environment variable
const clusterEnvConfig = config.get('build').environment; // readonly
Expand Down

0 comments on commit c60feaf

Please sign in to comment.