File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed
Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,21 @@ cloudCarbonFootprint:
6565 tenantId: tenant id,
6666` ` `
6767
68+ # ## Caching
69+
70+ See [here](https://www.cloudcarbonfootprint.org/docs/data-persistence-and-caching) for more detailed documentation on data persistence and caching.
71+
72+ To use MongoDB (recommended and supported caching mode), here is an example of the configuration :
73+
74+ ` ` ` yaml
75+ # app-config.local.yaml
76+ cloudCarbonFootprint:
77+ optional:
78+ cacheMode: MONGODB
79+ mongoDbUri: mongodb://localhost:27017
80+ mongoDbCredentials: ~/keys/mongodb-certificate.pem
81+ ` ` `
82+
6883---
6984
7085© 2022 Thoughtworks, Inc.
Original file line number Diff line number Diff line change @@ -217,15 +217,25 @@ export interface Config {
217217
218218 optional ?: {
219219 /**
220- * Set with 'GCS' to store cache file in Google Cloud Storage or leave it empty to use the default.
220+ * Set with 'GCS' or 'MONGODB' to store cache file in Google Cloud Storage or Mongo Database respectively, or leave it empty to use the default.
221221 * @visibility backend
222222 */
223- cacheMode ?: 'GCP' ;
223+ cacheMode ?: 'GCP' | 'MONGODB' ;
224224 /**
225- * Is the name of you Google Cloud Storage bucket where the cache file will be stored.
225+ * If cacheMode is set to 'GCS', you need to provide a Google Cloud Storage bucket where the cache file will be stored.
226226 * @visibility backend
227227 */
228228 gcsCacheBucketName ?: string ;
229+ /**
230+ * If cacheMode is set to 'MONGODB', you need to provide a URI to your db.
231+ * @visibility backend
232+ */
233+ mongoDbUri ?: string ;
234+ /**
235+ * If cacheMode is set to 'MONGODB', you need to provide a file path to your credentials file.
236+ * @visibility backend
237+ */
238+ mongoDbCredentials ?: string ;
229239 /**
230240 * Value to set how the cloud provider queries should return data (e.g. day/week/month/quarter/year). Default to 'day'.
231241 * @visibility backend
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ export const convertConfig = (appConfig?: BackstageConfig): CCFConfig => {
1919 const awsConfig = backstageConfig . getOptionalConfig ( 'aws' ) ;
2020 const azureConfig = backstageConfig . getOptionalConfig ( 'azure' ) ;
2121 const onPremiseConfig = backstageConfig . getOptionalConfig ( 'onPremise' ) ;
22+ const mongoDbConfig = backstageConfig . getOptionalConfig ( 'mongoDb' ) ;
2223 const optionalConfig = backstageConfig . getOptionalConfig ( 'optional' ) ;
2324
2425 return {
@@ -163,6 +164,18 @@ export const convertConfig = (appConfig?: BackstageConfig): CCFConfig => {
163164 ccfDefaults . ON_PREMISE ! . DESKTOP ! . AVERAGE_WATTS ,
164165 } ,
165166 } ,
167+ MONGODB :
168+ mongoDbConfig === undefined
169+ ? ccfDefaults . MONGODB
170+ : {
171+ ...ccfDefaults . MONGODB ,
172+ URI :
173+ optionalConfig ?. getOptionalString ( 'mongoDbUri' ) ??
174+ ccfDefaults . MONGODB ?. URI ,
175+ CREDENTIALS :
176+ optionalConfig ?. getOptionalString ( 'mongoDbCredentials' ) ??
177+ ccfDefaults . MONGODB ?. CREDENTIALS ,
178+ } ,
166179 CACHE_MODE :
167180 optionalConfig ?. getOptionalString ( 'cacheMode' ) ?? ccfDefaults . CACHE_MODE ,
168181 } ;
You can’t perform that action at this time.
0 commit comments