-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide ability to 'feature flag' an ISV App #59
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ const fs = require('fs'); | |
const path = require('path'); | ||
const jsYaml = require('js-yaml'); | ||
const constants = require('../../../utils/constants'); | ||
const features = require('../../../utils/features'); | ||
|
||
// TODO: Retrieve from the correct group for dashboard quick starts | ||
const quickStartsGroup = 'odh.openshift.io'; | ||
|
@@ -24,13 +25,17 @@ const getInstalledQuickStarts = async (fastify) => { | |
// fastify.log.error(e, 'failed to get quickstarts'); | ||
// } | ||
|
||
const featureFlags = features.getComponentFeatureFlags(); | ||
|
||
// TODO: Remove local quick starts when we get the correct quick starts from OpenShift | ||
const normalizedPath = path.join(__dirname, '../../../../data/quickstarts'); | ||
fs.readdirSync(normalizedPath).forEach((file) => { | ||
if (constants.yamlRegExp.test(file)) { | ||
try { | ||
const doc = jsYaml.load(fs.readFileSync(path.join(normalizedPath, file), 'utf8')); | ||
installedQuickStarts.push(doc); | ||
if (!doc.spec.featureFlag || featureFlags[doc.spec.featureFlag]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future: this may also work with just the one check and optional chaining, I'd need to fully confirm. Regardless, what you have works, pre-opt chaining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea is that if there is no feature flag it is allowed, if there is a feature flag, check the flags. |
||
installedQuickStarts.push(doc); | ||
} | ||
} catch (e) { | ||
console.error(`Error loading quick start ${file}: ${e}`); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const getComponentFeatureFlags = () => { | ||
const normalizedPath = path.join(__dirname, '../../data/features.json'); | ||
try { | ||
return JSON.parse(fs.readFileSync(normalizedPath, 'utf8')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. future: since not sure if that may be a file prone to update, then using what you have is good, JSON can also be brought through with a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the idea is that the feature flags can be enabled on the deployed site |
||
} catch { | ||
return {}; | ||
} | ||
}; | ||
|
||
module.exports = { getComponentFeatureFlags }; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"example-feature-app-name": true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future: this may also work with just the one check and optional chaining, I'd need to fully confirm. Regardless, what you have works, pre-opt chaining