Skip to content

Commit

Permalink
Fixes post review by Rugvip:
Browse files Browse the repository at this point in the history
1. Ensuring that reloadIntervals, if present, is a valid positive number
2. Remote config error message fix
3. Removed remote config from example backend
4. Lessened the writing.md
5. Multiple changesets

Signed-off-by: Praveen Ranjan Keshri <prkeshri@gmail.com>
  • Loading branch information
prkeshri committed Dec 7, 2021
1 parent d5d69f1 commit 1e70704
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 27 deletions.
2 changes: 0 additions & 2 deletions .changeset/brave-impalas-switch.md
@@ -1,7 +1,5 @@
---
'example-backend': patch
'@backstage/backend-common': patch
'@backstage/config-loader': patch
---

Fixed bug in backend-common to allow passing of remote option in order to enable passing remote url in --config option. The remote option should be passed along with reloadIntervalSeconds from packages/backend/src/index.ts (Updated the file as well)
Expand Down
5 changes: 5 additions & 0 deletions .changeset/cuddly-cooks-enjoy.md
@@ -0,0 +1,5 @@
---
'@backstage/config-loader': patch
---

In case remote.reloadIntervalSeconds is passed, it must be a valid positive value
23 changes: 4 additions & 19 deletions docs/conf/writing.md
Expand Up @@ -75,25 +75,10 @@ files. Paths are relative to the working directory of the executed process, for
example `package/backend`. This means that to select a config file in the repo
root when running the backend, you would use `--config ../../my-config.yaml`,
and for config file on a config server you would use
`--config https://some.domain.io/app-config.yaml`<br/>

**\*Note**: In order to use remote urls, ensure that the option 'remote' is
passed in `loadBackendConfig(...)` call (See below) inside
`packages/backend/src/index.ts`, with the option of
reloadIntervalSeconds(required) as given below. This will allow the usage of
remote configs and also, will ensure that this config is checked for any changes
every 12 hours. (This can be any desired value in seconds, here 60 _ 60 _ 12 =
12 hours!):

```ts
const config = await loadBackendConfig({
argv: process.argv,
logger,
remote: {
reloadIntervalSeconds: 60 * 60 * 12, // Check remote config changes every 12 hours. Change to your desired interval in seconds
},
});
```
`--config https://some.domain.io/app-config.yaml`

**Note**: In case URLs are passed, it is also needed to set the remote option in
the loadBackendConfig call.

If no `config` flags are specified, the default behavior is to load
`app-config.yaml` and, if it exists, `app-config.local.yaml` from the repo root.
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/index.ts
Expand Up @@ -88,9 +88,6 @@ async function main() {
const config = await loadBackendConfig({
argv: process.argv,
logger,
remote: {
reloadIntervalSeconds: 60 * 60 * 12, // Check remote config changes every 12 hours. Change to your desired interval in seconds
},
});

const createEnv = makeCreateEnv(config);
Expand Down
6 changes: 3 additions & 3 deletions packages/config-loader/src/loader.ts
Expand Up @@ -129,12 +129,12 @@ export async function loadConfig(
if (remote === undefined) {
if (configUrls.length > 0) {
throw new Error(
`Remote config detected but this feature is turned off. Please enable by passing remote option in loadBackendConfig() call inside packages/backend/src/index.ts. See https://backstage.io/docs/conf/writing#configuration-files for detailed info.`,
`Please make sure you are passing the remote option when loading the configuration. See https://backstage.io/docs/conf/writing#configuration-files for detailed info.`,
);
}
} else if (remote.reloadIntervalSeconds === undefined) {
} else if (remote.reloadIntervalSeconds <= 0) {
throw new Error(
`Remote config must be contain reloadIntervalSeconds: <seconds> value`,
`Remote config must be contain a non zero reloadIntervalSeconds: <seconds> value`,
);
}

Expand Down

0 comments on commit 1e70704

Please sign in to comment.