1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import Axios from "axios";
7 export const CONFIG_URL = process.env.REACT_APP_ARVADOS_CONFIG_URL || "/config.json";
9 export interface Config {
14 blobSignatureTtl: number;
15 crunchLimitLogBytesPerJob: number;
16 crunchLogBytesPerEvent: number;
17 crunchLogPartialLineThrottlePeriod: number;
18 crunchLogSecondsBetweenEvents: number;
19 crunchLogThrottleBytes: number;
20 crunchLogThrottleLines: number;
21 crunchLogThrottlePeriod: number;
22 defaultCollectionReplication: number;
23 defaultTrashLifetime: number;
25 discoveryVersion: string;
26 dockerImageFormats: string[];
27 documentationLink: string;
31 keepWebServiceUrl: string;
33 maxRequestSize: number;
35 packageVersion: string;
41 remoteHostsViaDNS: boolean;
47 sourceVersion: string;
48 source_version: string;
54 vocabularyUrl: string;
58 export const fetchConfig = () => {
60 .get<ConfigJSON>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
61 .then(response => response.data)
62 .catch(() => Promise.resolve(getDefaultConfig()))
64 .get<Config>(getDiscoveryURL(config.API_HOST))
66 // TODO: After tests delete `|| '/vocabulary-example.json'`
67 config: {...response.data, vocabularyUrl: config.VOCABULARY_URL || '/vocabulary-example.json' },
68 apiHost: config.API_HOST,
73 export const mockConfig = (config: Partial<Config>): Config => ({
79 crunchLimitLogBytesPerJob: 0,
80 crunchLogBytesPerEvent: 0,
81 crunchLogPartialLineThrottlePeriod: 0,
82 crunchLogSecondsBetweenEvents: 0,
83 crunchLogThrottleBytes: 0,
84 crunchLogThrottleLines: 0,
85 crunchLogThrottlePeriod: 0,
86 defaultCollectionReplication: 0,
87 defaultTrashLifetime: 0,
90 dockerImageFormats: [],
91 documentationLink: '',
95 keepWebServiceUrl: '',
103 remoteHostsViaDNS: false,
121 interface ConfigJSON {
123 VOCABULARY_URL: string;
126 const getDefaultConfig = (): ConfigJSON => ({
127 API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
131 export const DISCOVERY_URL = 'discovery/v1/apis/arvados/v1/rest';
132 const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/${DISCOVERY_URL}`;