-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9ebc2b
commit a53bc79
Showing
10 changed files
with
133 additions
and
34 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 was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/services/report/data/features/protected_exterrnally.ts
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,10 @@ | ||
import { GatewayService } from '../../../keystone/types'; | ||
import { ReportOfNamespaces } from '../namespaces'; | ||
import { ReportOfProducts } from '../products'; | ||
|
||
export function has_feature_protected_externally( | ||
ns: ReportOfNamespaces, | ||
product: ReportOfProducts | ||
): Boolean { | ||
return 'protected-externally' === product.prod_env_flow; | ||
} |
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
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,55 @@ | ||
import { lookupServicesByNamespaceForReporting } from '../../keystone/gateway-service'; | ||
import { Keystone } from '@keystonejs/keystone'; | ||
import { ReportOfNamespaces } from './namespaces'; | ||
import { getServiceMetrics, calculateStats } from '../../keystone'; | ||
import { dateRange } from '../../utils'; | ||
import { getFeatures, getPlugins } from './features'; | ||
import { lookupEnvironmentsByNS } from '../../../services/keystone/product-environment'; | ||
import { Environment } from '../../../services/keystone/types'; | ||
import { has_feature_protected_externally } from './features/protected_exterrnally'; | ||
|
||
export interface ReportOfProducts { | ||
namespace: string; | ||
display_name?: string; | ||
prod_name?: string; | ||
prod_env_active: string; | ||
prod_env_name?: string; | ||
prod_env_flow?: string; | ||
prod_env_app_id?: string; | ||
features: string[]; | ||
} | ||
|
||
export async function getProducts( | ||
ksCtx: Keystone, | ||
namespaces: ReportOfNamespaces[] | ||
): Promise<ReportOfProducts[]> { | ||
const dataPromises = namespaces.map( | ||
async (ns): Promise<ReportOfProducts[]> => { | ||
const environments = await lookupEnvironmentsByNS(ksCtx, ns.name); | ||
return environments.map((env) => { | ||
const product = { | ||
namespace: ns.name, | ||
display_name: ns.displayName, | ||
prod_name: env.product?.name, | ||
prod_env_name: env.name, | ||
prod_env_app_id: env.appId, | ||
prod_env_flow: env.flow, | ||
prod_env_active: env.active ? 'Y' : 'N', | ||
features: [], | ||
} as ReportOfProducts; | ||
|
||
const featureProtectedExternally = has_feature_protected_externally( | ||
ns, | ||
product | ||
); | ||
if (featureProtectedExternally) { | ||
product.features.push('protected_externally'); | ||
} | ||
return product; | ||
}); | ||
} | ||
); | ||
|
||
const reportOfReports = await Promise.all(dataPromises); | ||
return [].concat.apply([], reportOfReports); | ||
} |
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
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