-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(features): add experimental features management
- Loading branch information
Showing
4 changed files
with
121 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
const { getFeatures, setFeature } = require('../models/configuration.js'); | ||
const { AVAILABLE_FEATURES } = require('../models/features.js'); | ||
const Logger = require('../logger.js'); | ||
|
||
async function list (params) { | ||
const { format } = params.options; | ||
const features = await getFeatures(); | ||
|
||
switch (format) { | ||
case 'json': { | ||
Logger.printJson(features); | ||
break; | ||
} | ||
case 'human': | ||
default: { | ||
for (const feature in features) { | ||
console.log(`- ${feature}: ${features[feature]}`); | ||
} | ||
} | ||
} | ||
} | ||
|
||
async function enable (params) { | ||
const { 'feature-name': featureName } = params.namedArgs; | ||
|
||
if (!AVAILABLE_FEATURES.includes(featureName)) { | ||
throw new Error(`Feature '${featureName}' is not available`); | ||
} | ||
|
||
await setFeature(featureName, true); | ||
Logger.println(`Experimental feature '${featureName}' enabled`); | ||
} | ||
|
||
async function disable (params) { | ||
const { 'feature-name': featureName } = params.namedArgs; | ||
|
||
if (!AVAILABLE_FEATURES.includes(featureName)) { | ||
throw new Error(`Feature '${featureName}' is not available`); | ||
} | ||
|
||
await setFeature(featureName, false); | ||
Logger.println(`Experimental feature '${featureName}' disabled`); | ||
} | ||
|
||
module.exports = { disable, enable, list }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
const AVAILABLE_FEATURES = ['faas', 'kv', 'ng']; | ||
|
||
module.exports = { AVAILABLE_FEATURES }; |