@redhat-cloud-services/frontend-components-config-utilities 1.5.16 → 1.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -19,17 +19,25 @@ module.exports = ({ env }) => ({
|
|
|
19
19
|
'entitlements-config': `https://github.com/redhatinsights/entitlements-config#${getEntitlementsBranch(env)}`
|
|
20
20
|
},
|
|
21
21
|
register({ app, config }) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
app.get('/api/entitlements/v1/services', (_req, res) => {
|
|
23
|
+
try {
|
|
24
|
+
const configPath = path.join(config.entitlements.assets['entitlements-config'], '/configs/stage/bundles.yml');
|
|
25
|
+
|
|
26
|
+
// Use { json: true } in case of duplicate keys
|
|
27
|
+
const outerYaml = yaml.load(fs.readFileSync(configPath, 'utf8'), { json: true });
|
|
28
|
+
const serviceSKUs = yaml.load(outerYaml.objects[0].data['bundles.yml'], { json: true });
|
|
29
|
+
|
|
30
|
+
const services = serviceSKUs.map(serviceSKU => serviceSKU.name);
|
|
31
|
+
// Grant access to all services
|
|
32
|
+
const entitlements = services.reduce((acc, cur) => {
|
|
33
|
+
acc[cur] = { is_entitled: true, is_trial: false };
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
|
|
37
|
+
res.json(entitlements);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
res.status(500).json({ error });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
35
43
|
});
|