Feature metadata (#1661)
* feat: 🎸 load edition from controller-metadata.json * refactor: 💡 rename edition and add licensed features support * chore: 🤖 support dev toggling of licensed features * chore: 🤖 rename ent edition * Update ui/admin/app/services/feature-edition.js * Update ui/admin/app/instance-initializers/feature-edition.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * chore: 🤖 cleanup * chore: 🤖 feature edition disabled in tests / fix test cases * test: 💍 remove feature disable calls in tests * test: 💍 fix broken tests * fix: 🐛 fix config bug * fix: 🐛 fix broken test due to feature flags --------- Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
This commit is contained in:
1 parent
ee1cd4100c
commit
7350c0e08c
27 files changed
+250
-127
No files matched your search
@@ -3,9 +3,37 @@
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*/
|
||||
|
||||
export function initialize(owner) {
|
||||
import fetch from 'fetch';
|
||||
|
||||
async function autoInitializeFeatureEdition(owner) {
|
||||
const service = owner.lookup('service:feature-edition');
|
||||
service.initialize();
|
||||
const url = '/metadata.json';
|
||||
let edition;
|
||||
let features;
|
||||
|
||||
// Attempt to load edition for the metadata JSON
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const json = await response.json();
|
||||
edition = json?.license?.edition;
|
||||
features = json?.license?.features;
|
||||
} catch (e) {
|
||||
// if the request fails, the service will initialize the default edition
|
||||
// as specified in the config
|
||||
}
|
||||
|
||||
// Initialize the feature edition and its associated features
|
||||
service.initialize(edition, features);
|
||||
}
|
||||
|
||||
export async function initialize(owner) {
|
||||
const config = owner.resolveRegistration('config:environment');
|
||||
const isTesting = config.environment === 'test';
|
||||
// Do not auto-init in a test environment.
|
||||
// Tests should explicitly enable editions and features as needed.
|
||||
if (!isTesting) {
|
||||
await autoInitializeFeatureEdition(owner);
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in new issue
Block a user