Skip to content

Commit

Permalink
Merge #598: Configuration overhaul: rename env vars
Browse files Browse the repository at this point in the history
97e3634 refactor: [#596] rename env vars (Jose Celano)
5910fda refactor: [#596] move env var constants to config mod (Jose Celano)
b8d0f98 refactor: [#596] merge E2E and prod common env var constants (Jose Celano)
fc1528d feat: [#596] rename common E2E env vars (Jose Celano)

Pull request description:

  Rename env vars:

  - [x] To use standard names for E2E tests. E2E tests should use standard names when vars are not specified for E2E tests. For example: `TORRUST_INDEX_TRACKER_API_TOKEN` -> `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`.
  - [x] To follow Figment conventions.
  - [x] To improve naming. For example, make them more specific: `TORRUST_INDEX_CONFIG` -> `TORRUST_INDEX_CONFIG_TOML`.

ACKs for top commit:
  josecelano:
    ACK 97e3634

Tree-SHA512: d002d64c24d183472bd98348267d0c8e7ad1b5e02b3962a2df3ccb7b47ebf91f645af0ed3fe9fcc887153c4d04dbf0bf88c9d4a827e408c178b965832e9a103b
  • Loading branch information
josecelano committed May 22, 2024
2 parents 9290cbb + 97e3634 commit 1d8d405
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .env.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DATABASE_URL=sqlite://storage/database/data.db?mode=rwc
TORRUST_INDEX_CONFIG=
TORRUST_INDEX_AUTH_SECRET_KEY=MaxVerstappenWC2021
TORRUST_INDEX_CONFIG_TOML=
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY=MaxVerstappenWC2021
USER_ID=1000
TORRUST_TRACKER_CONFIG_TOML=
TORRUST_TRACKER_CONFIG_OVERRIDE_DB_DRIVER=Sqlite3
Expand Down
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ FROM gcr.io/distroless/cc-debian12:debug as runtime
RUN ["/busybox/cp", "-sp", "/busybox/sh","/busybox/cat","/busybox/ls","/busybox/env", "/bin/"]
COPY --from=gcc --chmod=0555 /usr/local/bin/su-exec /bin/su-exec

ARG TORRUST_INDEX_PATH_CONFIG="/etc/torrust/index/index.toml"
ARG TORRUST_INDEX_CONFIG_TOML_PATH="/etc/torrust/index/index.toml"
ARG TORRUST_INDEX_DATABASE_DRIVER="Sqlite3"
ARG USER_ID=1000
ARG API_PORT=3001
ARG IMPORTER_API_PORT=3002

ENV TORRUST_INDEX_PATH_CONFIG=${TORRUST_INDEX_PATH_CONFIG}
ENV TORRUST_INDEX_CONFIG_TOML_PATH=${TORRUST_INDEX_CONFIG_TOML_PATH}
ENV TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_INDEX_DATABASE_DRIVER}
ENV USER_ID=${USER_ID}
ENV API_PORT=${API_PORT}
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ cp ./share/default/config/index.development.sqlite3.toml ./storage/index/etc/ind
vim ./storage/index/etc/index.toml

# Run the index with the updated configuration:
TORRUST_INDEX_PATH_CONFIG="./storage/index/etc/index.toml" cargo run
TORRUST_INDEX_CONFIG_TOML_PATH="./storage/index/etc/index.toml" cargo run
```

_Optionally, you may choose to supply the entire configuration as an environmental variable:_

```sh
# Use a configuration supplied on an environmental variable:
TORRUST_INDEX_CONFIG=$(cat "./storage/index/etc/index.toml") cargo run
TORRUST_INDEX_CONFIG_TOML=$(cat "./storage/index/etc/index.toml") cargo run
```

_For deployment, you __should__ override:
Expand All @@ -100,9 +100,9 @@ _For deployment, you __should__ override:
```sh
# Please use the secret that you generated for the torrust-tracker configuration.
# Override secret in configuration using an environmental variable
TORRUST_INDEX_CONFIG=$(cat "./storage/index/etc/index.toml") \
TORRUST_INDEX_TRACKER_API_TOKEN=$(cat "./storage/tracker/lib/tracker_api_admin_token.secret") \
TORRUST_INDEX_AUTH_SECRET_KEY="MaxVerstappenWC2021" \
TORRUST_INDEX_CONFIG_TOML=$(cat "./storage/index/etc/index.toml") \
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN=$(cat "./storage/tracker/lib/tracker_api_admin_token.secret") \
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY="MaxVerstappenWC2021" \
cargo run
```

Expand Down
6 changes: 3 additions & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ services:
tty: true
environment:
- USER_ID=${USER_ID}
- TORRUST_INDEX_CONFIG=${TORRUST_INDEX_CONFIG}
- TORRUST_INDEX_CONFIG_TOML=${TORRUST_INDEX_CONFIG_TOML}
- TORRUST_INDEX_DATABASE=${TORRUST_INDEX_DATABASE:-e2e_testing_sqlite3}
- TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_INDEX_DATABASE_DRIVER:-sqlite3}
- TORRUST_INDEX_TRACKER_API_TOKEN=${TORRUST_INDEX_TRACKER_API_TOKEN:-MyAccessToken}
- TORRUST_INDEX_AUTH_SECRET_KEY=${TORRUST_INDEX_AUTH_SECRET_KEY:-MaxVerstappenWC2021}
- TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN=${TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN:-MyAccessToken}
- TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY=${TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY:-MaxVerstappenWC2021}
networks:
- server_side
ports:
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/mysql/e2e-env-down.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.mysql.toml) \
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.mysql.toml) \
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \
docker compose down
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/e2e/mysql/e2e-env-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.mysql.toml
docker compose build

USER_ID=${USER_ID:-1000} \
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.mysql.toml) \
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.mysql.toml) \
TORRUST_INDEX_DATABASE="torrust_index_e2e_testing" \
TORRUST_INDEX_DATABASE_DRIVER="mysql" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \
TORRUST_INDEX_MYSQL_DATABASE="torrust_index_e2e_testing" \
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/mysql/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docker ps

# Run E2E tests with shared app instance
TORRUST_INDEX_E2E_SHARED=true \
TORRUST_INDEX_E2E_PATH_CONFIG="./share/default/config/index.e2e.container.mysql.toml" \
TORRUST_INDEX_CONFIG_TOML_PATH="./share/default/config/index.e2e.container.mysql.toml" \
TORRUST_INDEX_E2E_DB_CONNECT_URL="mysql://root:root_secret_password@localhost:3306/torrust_index_e2e_testing" \
cargo test ||
{
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/sqlite/e2e-env-down.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \
docker compose down
8 changes: 4 additions & 4 deletions contrib/dev-tools/container/e2e/sqlite/e2e-env-up.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash

TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
docker compose build

USER_ID=${USER_ID:-1000} \
TORRUST_INDEX_CONFIG=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
TORRUST_INDEX_CONFIG_TOML=$(cat ./share/default/config/index.e2e.container.sqlite3.toml) \
TORRUST_INDEX_DATABASE="e2e_testing_sqlite3" \
TORRUST_INDEX_DATABASE_DRIVER="sqlite3" \
TORRUST_INDEX_TRACKER_API_TOKEN="MyAccessToken" \
TORRUST_INDEX_AUTH_SECRET_KEY="MaxVerstappenWC2021" \
TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MyAccessToken" \
TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY="MaxVerstappenWC2021" \
TORRUST_TRACKER_CONFIG_TOML=$(cat ./share/default/config/tracker.e2e.container.sqlite3.toml) \
TORRUST_TRACKER_DATABASE="e2e_testing_sqlite3" \
TORRUST_TRACKER_CONFIG_OVERRIDE_DB_DRIVER="Sqlite3" \
Expand Down
2 changes: 1 addition & 1 deletion contrib/dev-tools/container/e2e/sqlite/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ docker ps

# Run E2E tests with shared app instance
TORRUST_INDEX_E2E_SHARED=true \
TORRUST_INDEX_E2E_PATH_CONFIG="./share/default/config/index.e2e.container.sqlite3.toml" \
TORRUST_INDEX_CONFIG_TOML_PATH="./share/default/config/index.e2e.container.sqlite3.toml" \
TORRUST_INDEX_E2E_DB_CONNECT_URL="sqlite://./storage/index/lib/database/e2e_testing_sqlite3.db?mode=rwc" \
cargo test ||
{
Expand Down
4 changes: 2 additions & 2 deletions contrib/dev-tools/container/run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

USER_ID=${USER_ID:-1000}
TORRUST_INDEX_CONFIG=$(cat config.toml)
TORRUST_INDEX_CONFIG_TOML=$(cat config.toml)

docker run -it \
--user="$USER_ID" \
--publish 3001:3001/tcp \
--env TORRUST_INDEX_CONFIG="$TORRUST_INDEX_CONFIG" \
--env TORRUST_INDEX_CONFIG_TOML="$TORRUST_INDEX_CONFIG_TOML" \
--volume "$(pwd)/storage":"/app/storage" \
torrust-index
14 changes: 7 additions & 7 deletions docs/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ Environmental variables are loaded through the `--env`, in the format `--env VAR

The following environmental variables can be set:

- `TORRUST_INDEX_PATH_CONFIG` - The in-container path to the index configuration file, (default: `"/etc/torrust/index/index.toml"`).
- `TORRUST_INDEX_TRACKER_API_TOKEN` - Override of the admin token. If set, this value overrides any value set in the config.
- `TORRUST_INDEX_AUTH_SECRET_KEY` - Override of the auth secret key. If set, this value overrides any value set in the config.
- `TORRUST_INDEX_CONFIG_TOML_PATH` - The in-container path to the index configuration file, (default: `"/etc/torrust/index/index.toml"`).
- `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN` - Override of the admin token. If set, this value overrides any value set in the config.
- `TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY` - Override of the auth secret key. If set, this value overrides any value set in the config.
- `TORRUST_INDEX_DATABASE_DRIVER` - The database type used for the container, (options: `sqlite3`, `mysql`, default `sqlite3`). Please Note: This dose not override the database configuration within the `.toml` config file.
- `TORRUST_INDEX_CONFIG` - Load config from this environmental variable instead from a file, (i.e: `TORRUST_INDEX_CONFIG=$(cat index-index.toml)`).
- `TORRUST_INDEX_CONFIG_TOML` - Load config from this environmental variable instead from a file, (i.e: `TORRUST_INDEX_CONFIG_TOML=$(cat index-index.toml)`).
- `USER_ID` - The user id for the runtime crated `torrust` user. Please Note: This user id should match the ownership of the host-mapped volumes, (default `1000`).
- `API_PORT` - The port for the index API. This should match the port used in the configuration, (default `3001`).

Expand Down Expand Up @@ -201,8 +201,8 @@ mkdir -p ./storage/index/lib/ ./storage/index/log/ ./storage/index/etc/

## Run Torrust Index Container Image
docker run -it \
--env TORRUST_INDEX_TRACKER_API_TOKEN="MySecretToken" \
--env TORRUST_INDEX_AUTH_SECRET_KEY="MaxVerstappenWC2021" \
--env TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MySecretToken" \
--env TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY="MaxVerstappenWC2021" \
--env USER_ID="$(id -u)" \
--publish 0.0.0.0:3001:3001/tcp \
--volume ./storage/index/lib:/var/lib/torrust/index:Z \
Expand All @@ -222,7 +222,7 @@ mkdir -p ./storage/index/lib/ ./storage/index/log/ ./storage/index/etc/

## Run Torrust Index Container Image
podman run -it \
--env TORRUST_INDEX_TRACKER_API_TOKEN="MySecretToken" \
--env TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN="MySecretToken" \
--env USER_ID="$(id -u)" \
--publish 0.0.0.0:3001:3001/tcp \
--volume ./storage/index/lib:/var/lib/torrust/index:Z \
Expand Down
4 changes: 2 additions & 2 deletions share/default/config/index.container.mysql.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Please override the following settings with environmental variable!
# tracker::token -> `TORRUST_INDEX_TRACKER_API_TOKEN`
# auth::secret_key -> `TORRUST_INDEX_AUTH_SECRET_KEY`
# tracker::token -> `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`
# auth::secret_key -> `TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY`

log_level = "info"

Expand Down
2 changes: 1 addition & 1 deletion share/default/config/index.container.sqlite3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ log_level = "info"
name = "Torrust"

# Please override the tracker token setting the
# `TORRUST_INDEX_TRACKER_API_TOKEN`
# `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`
# environmental variable!

[tracker]
Expand Down
4 changes: 2 additions & 2 deletions share/default/config/index.e2e.container.mysql.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Please override the following settings with environmental variable!
# tracker::token -> `TORRUST_INDEX_TRACKER_API_TOKEN`
# auth::secret_key -> `TORRUST_INDEX_AUTH_SECRET_KEY`
# tracker::token -> `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`
# auth::secret_key -> `TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY`

log_level = "info"

Expand Down
4 changes: 2 additions & 2 deletions share/default/config/index.e2e.container.sqlite3.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Please override the following settings with environmental variable!
# tracker::token -> `TORRUST_INDEX_TRACKER_API_TOKEN`
# auth::secret_key -> `TORRUST_INDEX_AUTH_SECRET_KEY`
# tracker::token -> `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`
# auth::secret_key -> `TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY`

log_level = "info"

Expand Down
26 changes: 3 additions & 23 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@

use crate::config::{Configuration, Info};

/// The whole `index.toml` file content. It has priority over the config file.
/// Even if the file is not on the default path.
const ENV_VAR_CONFIG: &str = "TORRUST_INDEX_CONFIG";

/// Token needed to communicate with the Torrust Tracker
const ENV_VAR_API_ADMIN_TOKEN: &str = "TORRUST_INDEX_TRACKER_API_TOKEN";

/// Secret key used to encrypt and decrypt
const ENV_VAR_AUTH_SECRET_KEY: &str = "TORRUST_INDEX_AUTH_SECRET_KEY";

/// The `index.toml` file location.
pub const ENV_VAR_PATH_CONFIG: &str = "TORRUST_INDEX_PATH_CONFIG";

// Default values
pub const DEFAULT_PATH_CONFIG: &str = "./share/default/config/index.development.sqlite3.toml";

Expand All @@ -30,7 +17,7 @@ pub const ENV_VAR_CORS_PERMISSIVE: &str = "TORRUST_INDEX_API_CORS_PERMISSIVE";
/// There are two methods to inject the configuration:
///
/// 1. By using a config file: `index.toml`.
/// 2. Environment variable: `TORRUST_INDEX_CONFIG`. The variable contains the same contents as the `index.toml` file.
/// 2. Environment variable: `TORRUST_INDEX_CONFIG_TOML`. The variable contains the same contents as the `index.toml` file.
///
/// Environment variable has priority over the config file.
///
Expand All @@ -39,17 +26,10 @@ pub const ENV_VAR_CORS_PERMISSIVE: &str = "TORRUST_INDEX_API_CORS_PERMISSIVE";
/// # Panics
///
/// Will panic if it can't load the configuration from either
/// `./index.toml` file or the env var `TORRUST_INDEX_CONFIG`.
/// `./index.toml` file or the env var `TORRUST_INDEX_CONFIG_TOML`.
#[must_use]
pub fn initialize_configuration() -> Configuration {
let info = Info::new(
ENV_VAR_CONFIG.to_string(),
ENV_VAR_PATH_CONFIG.to_string(),
DEFAULT_PATH_CONFIG.to_string(),
ENV_VAR_API_ADMIN_TOKEN.to_string(),
ENV_VAR_AUTH_SECRET_KEY.to_string(),
)
.unwrap();
let info = Info::new(DEFAULT_PATH_CONFIG.to_string()).unwrap();

Configuration::load(&info).unwrap()
}
Expand Down
41 changes: 24 additions & 17 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,25 @@ pub type EmailOnSignup = v1::auth::EmailOnSignup;

/// Prefix for env vars that overwrite configuration options.
const CONFIG_OVERRIDE_PREFIX: &str = "TORRUST_INDEX_CONFIG_OVERRIDE_";

/// Path separator in env var names for nested values in configuration.
const CONFIG_OVERRIDE_SEPARATOR: &str = "__";

/// The whole `index.toml` file content. It has priority over the config file.
/// Even if the file is not on the default path.
pub const ENV_VAR_CONFIG_TOML: &str = "TORRUST_INDEX_CONFIG_TOML";

/// The `index.toml` file location.
pub const ENV_VAR_CONFIG_TOML_PATH: &str = "TORRUST_INDEX_CONFIG_TOML_PATH";

/// Token needed to communicate with the Torrust Tracker.
/// Deprecated. Use `TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN`.
pub const ENV_VAR_TRACKER_API_ADMIN_TOKEN: &str = "TORRUST_INDEX_TRACKER_API_TOKEN";

/// Secret key used to encrypt and decrypt
/// Deprecated. Use `TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__SECRET_KEY`.
pub const ENV_VAR_AUTH_SECRET_KEY: &str = "TORRUST_INDEX_AUTH_SECRET_KEY";

/// Information required for loading config
#[derive(Debug, Default, Clone)]
pub struct Info {
Expand All @@ -44,28 +60,19 @@ pub struct Info {
}

impl Info {
/// Build Configuration Info
///
/// # Examples
///
/// ```no_run
/// # use torrust_index::config::Info;
/// # let (env_var_config, env_var_path_config, default_path_config, env_var_tracker_api_token, env_var_auth_secret_key) = ("".to_string(), "".to_string(), "".to_string(), "".to_string(), "".to_string());
/// let result = Info::new(env_var_config, env_var_path_config, default_path_config, env_var_tracker_api_token, env_var_auth_secret_key);
/// ```
/// Build configuration Info.
///
/// # Errors
///
/// Will return `Err` if unable to obtain a configuration.
///
#[allow(clippy::needless_pass_by_value)]
pub fn new(
env_var_config_toml: String,
env_var_config_toml_path: String,
default_config_toml_path: String,
env_var_tracker_api_token: String,
env_var_auth_secret_key: String,
) -> Result<Self, Error> {
pub fn new(default_config_toml_path: String) -> Result<Self, Error> {
let env_var_config_toml = ENV_VAR_CONFIG_TOML.to_string();
let env_var_config_toml_path = ENV_VAR_CONFIG_TOML_PATH.to_string();
let env_var_tracker_api_admin_token = ENV_VAR_TRACKER_API_ADMIN_TOKEN.to_string();
let env_var_auth_secret_key = ENV_VAR_AUTH_SECRET_KEY.to_string();

let config_toml = if let Ok(config_toml) = env::var(env_var_config_toml) {
println!("Loading configuration from environment variable {config_toml} ...");
Some(config_toml)
Expand All @@ -81,7 +88,7 @@ impl Info {
default_config_toml_path
};

let tracker_api_token = env::var(env_var_tracker_api_token).ok();
let tracker_api_token = env::var(env_var_tracker_api_admin_token).ok();
let auth_secret_key = env::var(env_var_auth_secret_key).ok();

Ok(Self {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,18 @@
//!
//! For more information about configuration you can visit the documentation for the [`config`]) module.
//!
//! Alternatively to the `config.toml` file you can use one environment variable `TORRUST_INDEX_CONFIG` to pass the configuration to the tracker:
//! Alternatively to the `config.toml` file you can use one environment variable `TORRUST_INDEX_CONFIG_TOML` to pass the configuration to the tracker:
//!
//! ```text
//! TORRUST_INDEX_CONFIG=$(cat config.toml)
//! TORRUST_INDEX_CONFIG_TOML=$(cat config.toml)
//! cargo run
//! ```
//!
//! In the previous example you are just setting the env var with the contents of the `config.toml` file.
//!
//! The env var contains the same data as the `config.toml`. It's particularly useful in you are [running the index with docker](https://github.com/torrust/torrust-index/tree/develop/docker).
//!
//! > **NOTICE**: The `TORRUST_INDEX_CONFIG` env var has priority over the `config.toml` file.
//! > **NOTICE**: The `TORRUST_INDEX_CONFIG_TOML` env var has priority over the `config.toml` file.
//!
//! > **NOTICE**: You can also change the location for the configuration file with the `TORRUST_INDEX_CONFIG_PATH` env var.
//!
Expand Down
Loading

0 comments on commit 1d8d405

Please sign in to comment.