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;
39 remoteHostsViaDNS: boolean;
45 sourceVersion: string;
46 source_version: string;
52 vocabularyUrl: string;
55 export const fetchConfig = () => {
57 .get<ConfigJSON>(CONFIG_URL + "?nocache=" + (new Date()).getTime())
58 .then(response => response.data)
59 .catch(() => Promise.resolve(getDefaultConfig()))
61 .get<Config>(getDiscoveryURL(config.API_HOST))
63 config: {...response.data, vocabularyUrl: config.VOCABULARY_URL },
64 apiHost: config.API_HOST,
69 export const mockConfig = (config: Partial<Config>): Config => ({
75 crunchLimitLogBytesPerJob: 0,
76 crunchLogBytesPerEvent: 0,
77 crunchLogPartialLineThrottlePeriod: 0,
78 crunchLogSecondsBetweenEvents: 0,
79 crunchLogThrottleBytes: 0,
80 crunchLogThrottleLines: 0,
81 crunchLogThrottlePeriod: 0,
82 defaultCollectionReplication: 0,
83 defaultTrashLifetime: 0,
86 dockerImageFormats: [],
87 documentationLink: '',
91 keepWebServiceUrl: '',
99 remoteHostsViaDNS: false,
116 interface ConfigJSON {
118 VOCABULARY_URL: string;
121 const getDefaultConfig = (): ConfigJSON => ({
122 API_HOST: process.env.REACT_APP_ARVADOS_API_HOST || "",
126 const getDiscoveryURL = (apiHost: string) => `${window.location.protocol}//${apiHost}/discovery/v1/apis/arvados/v1/rest`;