Skip to content

Commit

Permalink
unify environment variable format (#1734)
Browse files Browse the repository at this point in the history
  • Loading branch information
phiSgr authored Sep 10, 2024
1 parent 1869347 commit e71feca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions apps/framework-cli/src/cli/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use uuid::Uuid;

use super::display::{Message, MessageType};
use super::logger::LoggerSettings;
use crate::utilities::constants::{CLI_CONFIG_FILE, CLI_USER_DIRECTORY};
use crate::utilities::constants::{
CLI_CONFIG_FILE, CLI_USER_DIRECTORY, ENVIRONMENT_VARIABLE_PREFIX,
};

/// # Config
/// Module to handle reading the config file from the user's home directory and configuring the CLI
Expand All @@ -19,8 +21,6 @@ use crate::utilities::constants::{CLI_CONFIG_FILE, CLI_USER_DIRECTORY};
/// - add a config file validation and error handling
///

const ENVIRONMENT_VARIABLE_PREFIX: &str = "MOOSE";

#[derive(Deserialize, Debug)]
pub struct Telemetry {
pub machine_id: String,
Expand Down Expand Up @@ -88,7 +88,8 @@ pub fn read_settings() -> Result<Settings, ConfigError> {
.add_source(
Environment::with_prefix(ENVIRONMENT_VARIABLE_PREFIX)
.try_parsing(true)
.separator("_"),
.prefix_separator("_")
.separator("__"),
)
.build()?;

Expand Down
6 changes: 4 additions & 2 deletions apps/framework-cli/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use python_project::PythonProject;
use serde::Deserialize;
use serde::Serialize;

use crate::utilities::constants::CLI_DEV_CLICKHOUSE_VOLUME_DIR_CONFIG_SCRIPTS;
use crate::utilities::constants::CLI_DEV_CLICKHOUSE_VOLUME_DIR_CONFIG_USERS;
use crate::utilities::constants::CLI_DEV_CLICKHOUSE_VOLUME_DIR_DATA;
use crate::utilities::constants::CLI_DEV_CLICKHOUSE_VOLUME_DIR_LOGS;
Expand All @@ -61,6 +60,9 @@ use crate::utilities::constants::{
};
use crate::utilities::constants::{APP_DIR, APP_DIR_LAYOUT, CLI_PROJECT_INTERNAL_DIR, SCHEMAS_DIR};
use crate::utilities::constants::{BLOCKS_DIR, TS_BLOCKS_FILE};
use crate::utilities::constants::{
CLI_DEV_CLICKHOUSE_VOLUME_DIR_CONFIG_SCRIPTS, ENVIRONMENT_VARIABLE_PREFIX,
};
use crate::utilities::constants::{PYTHON_INIT_FILE, PY_API_FILE, TS_API_FILE};
use crate::utilities::constants::{VSCODE_DIR, VSCODE_EXT_FILE, VSCODE_SETTINGS_FILE};
use crate::utilities::git::GitConfig;
Expand Down Expand Up @@ -187,7 +189,7 @@ impl Project {
let mut project_config: Project = Config::builder()
.add_source(File::from(project_file).required(true))
.add_source(
Environment::with_prefix("MOOSE")
Environment::with_prefix(ENVIRONMENT_VARIABLE_PREFIX)
.prefix_separator("_")
.separator("__"),
)
Expand Down
2 changes: 2 additions & 0 deletions apps/framework-cli/src/utilities/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use uuid::Uuid;

pub const CLI_VERSION: &str = env!("CARGO_PKG_VERSION");

pub const ENVIRONMENT_VARIABLE_PREFIX: &str = "MOOSE";

pub const PACKAGE_JSON: &str = "package.json";
pub const SETUP_PY: &str = "setup.py";
pub const OLD_PROJECT_CONFIG_FILE: &str = "project.toml";
Expand Down

0 comments on commit e71feca

Please sign in to comment.