mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	refactor: use lowercase names for run environment and config files (#801)
This commit is contained in:
		
							
								
								
									
										4
									
								
								.github/workflows/auto-release-tag.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/auto-release-tag.yml
									
									
									
									
										vendored
									
									
								
							| @ -34,7 +34,7 @@ jobs: | ||||
|         with: | ||||
|           build-args: | | ||||
|             BINARY=scheduler | ||||
|             SCHEDULER_FLOW=Consumer | ||||
|             SCHEDULER_FLOW=consumer | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: juspaydotin/orca-consumer:${{ github.ref_name }} | ||||
| @ -44,7 +44,7 @@ jobs: | ||||
|         with: | ||||
|           build-args: | | ||||
|             BINARY=scheduler | ||||
|             SCHEDULER_FLOW=Producer | ||||
|             SCHEDULER_FLOW=producer | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: juspaydotin/orca-producer:${{ github.ref_name }} | ||||
|  | ||||
							
								
								
									
										10
									
								
								.github/workflows/manual-release.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								.github/workflows/manual-release.yml
									
									
									
									
										vendored
									
									
								
							| @ -6,11 +6,11 @@ on: | ||||
|       environment: | ||||
|         description: "Environment to create image for" | ||||
|         required: true | ||||
|         default: "Sandbox" | ||||
|         default: "sandbox" | ||||
|         type: choice | ||||
|         options: | ||||
|           - Sandbox | ||||
|           - Production | ||||
|           - sandbox | ||||
|           - production | ||||
|       multiple_mca: | ||||
|         description: "Whether to enable the multiple_mca feature" | ||||
|         required: true | ||||
| @ -53,7 +53,7 @@ jobs: | ||||
|           build-args: | | ||||
|             RUN_ENV=${{ inputs.environment }} | ||||
|             BINARY=scheduler | ||||
|             SCHEDULER_FLOW=Consumer | ||||
|             SCHEDULER_FLOW=consumer | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: juspaydotin/orca-consumer:${{ github.sha }} | ||||
| @ -64,7 +64,7 @@ jobs: | ||||
|           build-args: | | ||||
|             RUN_ENV=${{ inputs.environment }} | ||||
|             BINARY=scheduler | ||||
|             SCHEDULER_FLOW=Producer | ||||
|             SCHEDULER_FLOW=producer | ||||
|           context: . | ||||
|           push: true | ||||
|           tags: juspaydotin/orca-producer:${{ github.sha }} | ||||
|  | ||||
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -249,8 +249,8 @@ logs/ | ||||
| **/*.log | ||||
| **/*.log.* | ||||
| monitoring/*.tmp/ | ||||
| config/Sandbox.toml | ||||
| config/Production.toml | ||||
| config/sandbox.toml | ||||
| config/production.toml | ||||
| !loadtest/.env | ||||
| loadtest/*.tmp/ | ||||
|  | ||||
|  | ||||
							
								
								
									
										14
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								Dockerfile
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| FROM rust:slim as builder | ||||
|  | ||||
| ARG RUN_ENV=Sandbox | ||||
| ARG RUN_ENV=sandbox | ||||
| ARG EXTRA_FEATURES="" | ||||
|  | ||||
| RUN apt-get update \ | ||||
| @ -33,9 +33,7 @@ ENV RUST_BACKTRACE="short" | ||||
| ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL="sparse" | ||||
|  | ||||
| COPY . . | ||||
|  | ||||
| # Use bash variable substitution to convert environment name to lowercase | ||||
| RUN bash -c 'cargo build --release --features ${RUN_ENV@L} ${EXTRA_FEATURES}' | ||||
| RUN cargo build --release --features ${RUN_ENV} ${EXTRA_FEATURES} | ||||
|  | ||||
|  | ||||
|  | ||||
| @ -46,14 +44,14 @@ ARG CONFIG_DIR=/local/config | ||||
| ARG BIN_DIR=/local/bin | ||||
|  | ||||
| # RUN_ENV decides the corresponding config file to be used | ||||
| ARG RUN_ENV=Sandbox | ||||
| ARG RUN_ENV=sandbox | ||||
|  | ||||
| # args for deciding the executable to export. three binaries: | ||||
| # 1. BINARY=router - for main application | ||||
| # 2. BINARY=scheduler, SCHEDULER_FLOW=Consumer - part of process tracker | ||||
| # 3. BINARY=scheduler, SCHEDULER_FLOW=Producer - part of process tracker | ||||
| # 2. BINARY=scheduler, SCHEDULER_FLOW=consumer - part of process tracker | ||||
| # 3. BINARY=scheduler, SCHEDULER_FLOW=producer - part of process tracker | ||||
| ARG BINARY=router | ||||
| ARG SCHEDULER_FLOW=Consumer | ||||
| ARG SCHEDULER_FLOW=consumer | ||||
|  | ||||
| RUN apt-get update \ | ||||
|     && apt-get install -y ca-certificates tzdata libpq-dev curl procps | ||||
|  | ||||
| @ -148,8 +148,8 @@ impl Settings { | ||||
|         // 1. Defaults from the implementation of the `Default` trait. | ||||
|         // 2. Values from config file. The config file accessed depends on the environment | ||||
|         //    specified by the `RUN_ENV` environment variable. `RUN_ENV` can be one of | ||||
|         //    `Development`, `Sandbox` or `Production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/Development.toml` file is read. | ||||
|         //    `development`, `sandbox` or `production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/development.toml` file is read. | ||||
|         // 3. Environment variables prefixed with `DRAINER` and each level separated by double | ||||
|         //    underscores. | ||||
|         // | ||||
|  | ||||
| @ -397,8 +397,8 @@ impl Settings { | ||||
|         // 1. Defaults from the implementation of the `Default` trait. | ||||
|         // 2. Values from config file. The config file accessed depends on the environment | ||||
|         //    specified by the `RUN_ENV` environment variable. `RUN_ENV` can be one of | ||||
|         //    `Development`, `Sandbox` or `Production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/Development.toml` file is read. | ||||
|         //    `development`, `sandbox` or `production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/development.toml` file is read. | ||||
|         // 3. Environment variables prefixed with `ROUTER` and each level separated by double | ||||
|         //    underscores. | ||||
|         // | ||||
|  | ||||
| @ -3,7 +3,6 @@ | ||||
| use std::path::PathBuf; | ||||
|  | ||||
| use serde::{Deserialize, Serialize}; | ||||
| use strum::{Display, EnumString}; | ||||
|  | ||||
| /// Environment variables accessed by the application. This module aims to be the source of truth | ||||
| /// containing all environment variable that the application accesses. | ||||
| @ -11,7 +10,7 @@ pub mod vars { | ||||
|     /// Parent directory where `Cargo.toml` is stored. | ||||
|     pub const CARGO_MANIFEST_DIR: &str = "CARGO_MANIFEST_DIR"; | ||||
|  | ||||
|     /// Environment variable that sets Development/Sandbox/Production environment. | ||||
|     /// Environment variable that sets development/sandbox/production environment. | ||||
|     pub const RUN_ENV: &str = "RUN_ENV"; | ||||
|  | ||||
|     /// Directory of config TOML files. Default is `config`. | ||||
| @ -19,7 +18,11 @@ pub mod vars { | ||||
| } | ||||
|  | ||||
| /// Current environment. | ||||
| #[derive(Debug, Default, Deserialize, Serialize, Clone, Copy, Display, EnumString)] | ||||
| #[derive( | ||||
|     Debug, Default, Deserialize, Serialize, Clone, Copy, strum::Display, strum::EnumString, | ||||
| )] | ||||
| #[serde(rename_all = "lowercase")] | ||||
| #[strum(serialize_all = "lowercase")] | ||||
| pub enum Env { | ||||
|     /// Development environment. | ||||
|     #[default] | ||||
| @ -30,7 +33,7 @@ pub enum Env { | ||||
|     Production, | ||||
| } | ||||
|  | ||||
| /// Name of current environment. Either "Development", "Sandbox" or "Production". | ||||
| /// Name of current environment. Either "development", "sandbox" or "production". | ||||
| pub fn which() -> Env { | ||||
|     #[cfg(debug_assertions)] | ||||
|     let default_env = Env::Development; | ||||
|  | ||||
| @ -123,8 +123,8 @@ impl Config { | ||||
|         // 1. Defaults from the implementation of the `Default` trait. | ||||
|         // 2. Values from config file. The config file accessed depends on the environment | ||||
|         //    specified by the `RUN_ENV` environment variable. `RUN_ENV` can be one of | ||||
|         //    `Development`, `Sandbox` or `Production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/Development.toml` file is read. | ||||
|         //    `development`, `sandbox` or `production`. If nothing is specified for `RUN_ENV`, | ||||
|         //    `/config/development.toml` file is read. | ||||
|         // 3. Environment variables prefixed with `ROUTER` and each level separated by double | ||||
|         //    underscores. | ||||
|         // | ||||
| @ -166,9 +166,9 @@ impl Config { | ||||
|             let config_directory = | ||||
|                 std::env::var(crate::env::vars::CONFIG_DIR).unwrap_or_else(|_| "config".into()); | ||||
|             let config_file_name = match environment { | ||||
|                 "Production" => "Production.toml", | ||||
|                 "Sandbox" => "Sandbox.toml", | ||||
|                 _ => "Development.toml", | ||||
|                 "production" => "production.toml", | ||||
|                 "sandbox" => "sandbox.toml", | ||||
|                 _ => "development.toml", | ||||
|             }; | ||||
|  | ||||
|             config_path.push(crate::env::workspace_path()); | ||||
|  | ||||
| @ -400,16 +400,16 @@ The application configuration files are present under the | ||||
|  | ||||
| The configuration file read varies with the environment: | ||||
|  | ||||
| - Development: [`config/Development.toml`][config-development] | ||||
| - Sandbox: `config/Sandbox.toml` | ||||
| - Production: `config/Production.toml` | ||||
| - Development: [`config/development.toml`][config-development] | ||||
| - Sandbox: `config/sandbox.toml` | ||||
| - Production: `config/production.toml` | ||||
|  | ||||
| Refer to [`config.example.toml`][config-example] for all the available | ||||
| configuration options. | ||||
| Refer to [`Development.toml`][config-development] for the recommended defaults for | ||||
| Refer to [`development.toml`][config-development] for the recommended defaults for | ||||
| local development. | ||||
|  | ||||
| Ensure to update the [`Development.toml`][config-development] file if you opted | ||||
| Ensure to update the [`development.toml`][config-development] file if you opted | ||||
| to use different database credentials as compared to the sample ones included in | ||||
| this guide. | ||||
|  | ||||
| @ -417,7 +417,7 @@ Once you're done with configuring the application, proceed with | ||||
| [running the application](#run-the-application). | ||||
|  | ||||
| [config-directory]: /config | ||||
| [config-development]: /config/Development.toml | ||||
| [config-development]: /config/development.toml | ||||
| [config-example]: /config/config.example.toml | ||||
| [config-docker-compose]: /config/docker_compose.toml | ||||
|  | ||||
| @ -463,7 +463,7 @@ Once you're done with configuring the application, proceed with | ||||
|       [`config/docker_compose.toml`][config-docker-compose], search for | ||||
|       `admin_api_key` to find the admin API key. | ||||
|    2. If you set up the dependencies locally, you can find the configuration | ||||
|       file at [`config/Development.toml`][config-development], search for | ||||
|       file at [`config/development.toml`][config-development], search for | ||||
|       `admin_api_key` to find the admin API key | ||||
|  | ||||
| 4. Open the ["Quick Start" folder][quick-start] in the collection. | ||||
|  | ||||
| @ -42,13 +42,13 @@ services: | ||||
|       - -c | ||||
|       - | | ||||
|         ./diesel migration run | ||||
|         ./router -f /config/Development.toml | ||||
|         ./router -f /config/development.toml | ||||
|     ports: | ||||
|       - "8080" | ||||
|     environment: | ||||
|       DATABASE_URL: postgres://postgres:postgres@db/loadtest_router | ||||
|       RUST_LOG: INFO | ||||
|       RUN_ENV: Development | ||||
|       RUN_ENV: development | ||||
|       OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4317 | ||||
|     networks: | ||||
|       - loadtest_net | ||||
|  | ||||
| @ -41,7 +41,7 @@ cd $SCRIPT/.. | ||||
|  | ||||
| # remove template files if already created for this connector | ||||
| rm -rf $conn/$pg $conn/$pg.rs | ||||
| git checkout $conn.rs $src/types/api.rs $src/configs/settings.rs config/Development.toml config/docker_compose.toml config/config.example.toml loadtest/config/Development.toml crates/api_models/src/enums.rs $src/core/payments/flows.rs | ||||
| git checkout $conn.rs $src/types/api.rs $src/configs/settings.rs config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml crates/api_models/src/enums.rs $src/core/payments/flows.rs | ||||
|  | ||||
| # add enum for this connector in required places | ||||
| prvc='' | ||||
| @ -51,14 +51,14 @@ sed -i'' -e "s|pub mod $prvc;|pub mod $prvc;\npub mod ${pg};|" $conn.rs | ||||
| sed -i'' -e "s/};/${pg}::${pgc},\n};/" $conn.rs  | ||||
| sed -i'' -e "s|\"$prvc\" \(.*\)|\"$prvc\" \1\n\t\t\t\"${pg}\" => Ok(Box::new(\&connector::${pgc})),|" $src/types/api.rs | ||||
| sed -i'' -e "s/pub $prvc: \(.*\)/pub $prvc: \1\n\tpub ${pg}: ConnectorParams,/" $src/configs/settings.rs | ||||
| sed -i'' -e "s|$prvc.base_url \(.*\)|$prvc.base_url \1\n${pg}.base_url = \"$base_url\"|" config/Development.toml config/docker_compose.toml config/config.example.toml loadtest/config/Development.toml | ||||
| sed  -r -i'' -e "s/\"$prvc\",/\"$prvc\",\n    \"${pg}\",/" config/Development.toml config/docker_compose.toml config/config.example.toml loadtest/config/Development.toml | ||||
| sed -i'' -e "s|$prvc.base_url \(.*\)|$prvc.base_url \1\n${pg}.base_url = \"$base_url\"|" config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml | ||||
| sed  -r -i'' -e "s/\"$prvc\",/\"$prvc\",\n    \"${pg}\",/" config/development.toml config/docker_compose.toml config/config.example.toml loadtest/config/development.toml | ||||
| sed -i'' -e "s/Dummy,/Dummy,\n\t${pgc},/" crates/api_models/src/enums.rs | ||||
| sed -i'' -e "s/pub enum RoutableConnectors {/pub enum RoutableConnectors {\n\t${pgc},/" crates/api_models/src/enums.rs | ||||
| sed -i'' -e "s/^default_imp_for_\(.*\)/default_imp_for_\1\n\tconnector::${pgc},/" $src/core/payments/flows.rs | ||||
|  | ||||
| # remove temporary files created in above step | ||||
| rm $conn.rs-e $src/types/api.rs-e $src/configs/settings.rs-e config/Development.toml-e config/docker_compose.toml-e config/config.example.toml-e loadtest/config/Development.toml-e crates/api_models/src/enums.rs-e $src/core/payments/flows.rs-e | ||||
| rm $conn.rs-e $src/types/api.rs-e $src/configs/settings.rs-e config/development.toml-e config/docker_compose.toml-e config/config.example.toml-e loadtest/config/development.toml-e crates/api_models/src/enums.rs-e $src/core/payments/flows.rs-e | ||||
| cd $conn/  | ||||
|  | ||||
| # generate template files for the connector | ||||
|  | ||||
		Reference in New Issue
	
	Block a user