X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/72470537b4b0a8470b6f5360817cc4039d74978c..8df73e82d637d7b2e81952fdc96a12a1011be99e:/src/common/config.ts diff --git a/src/common/config.ts b/src/common/config.ts index 2a02f8c204..7a98fd4722 100644 --- a/src/common/config.ts +++ b/src/common/config.ts @@ -84,30 +84,39 @@ export interface ClusterConfigJSON { Collections: { ForwardSlashNameSubstitution: string; ManagedProperties?: { - responsible_person_uuid?: { + [key: string]: { Function: string, + Value: string, + Protected?: boolean, + } + } + }; + Volumes: { + [key: string]: { + StorageClasses: { + [key: string]: boolean; } } }; } export class Config { - baseUrl: string; - keepWebServiceUrl: string; - keepWebInlineServiceUrl: string; - remoteHosts: { + baseUrl!: string; + keepWebServiceUrl!: string; + keepWebInlineServiceUrl!: string; + remoteHosts!: { [key: string]: string }; - rootUrl: string; - uuidPrefix: string; - websocketUrl: string; - workbenchUrl: string; - workbench2Url: string; - vocabularyUrl: string; - fileViewersConfigUrl: string; - loginCluster: string; - clusterConfig: ClusterConfigJSON; - apiRevision: number; + rootUrl!: string; + uuidPrefix!: string; + websocketUrl!: string; + workbenchUrl!: string; + workbench2Url!: string; + vocabularyUrl!: string; + fileViewersConfigUrl!: string; + loginCluster!: string; + clusterConfig!: ClusterConfigJSON; + apiRevision!: number; } export const buildConfig = (clusterConfig: ClusterConfigJSON): Config => { @@ -128,6 +137,19 @@ export const buildConfig = (clusterConfig: ClusterConfigJSON): Config => { return config; }; +export const getStorageClasses = (config: Config): string[] => { + const classes: Set = new Set(); + const volumes = config.clusterConfig.Volumes; + Object.keys(volumes).forEach(v => { + Object.keys(volumes[v].StorageClasses || {}).forEach(sc => { + if (volumes[v].StorageClasses[sc]) { + classes.add(sc); + } + }); + }); + return Array.from(classes); +}; + const getApiRevision = async (apiUrl: string) => { try { const dd = (await Axios.get(`${apiUrl}/${DISCOVERY_DOC_PATH}`)).data; @@ -140,7 +162,7 @@ const getApiRevision = async (apiUrl: string) => { const removeTrailingSlashes = (config: ClusterConfigJSON): ClusterConfigJSON => { const svcs: any = {}; - Object.keys(config.Services).map((s) => { + Object.keys(config.Services).forEach((s) => { svcs[s] = config.Services[s]; if (svcs[s].hasOwnProperty('ExternalURL')) { svcs[s].ExternalURL = svcs[s].ExternalURL.replace(/\/+$/, ''); @@ -250,6 +272,7 @@ export const mockClusterConfigJSON = (config: Partial): Clust Collections: { ForwardSlashNameSubstitution: "", }, + Volumes: {}, ...config });