Bug: [FEAT] add support for Hashicorp Vault Engine



**Description:**

Cripta is a service which creates keys and maintains it (includes key rotation etc.) individually for different Merchants and Users.

Currently it uses the AWS KMS as the Master Key (Key Encryption Key) for encrypting and decrypting Data Encryption Keys, But this is limited to AWS, To support deployment of Keymanager in multiple clouds, We need to support more Engines.

**Getting started:**

Go through the [README](https://github.com/juspay/hyperswitch-encryption-service/blob/main/README.md) for guidelines on the structure and functionality.

**Possible implementation:**
1. Go through the Hashcorp Vault Engine Implementation [here](https://github.com/juspay/hyperswitch/tree/main/crates/external_services/src/hashicorp_vault).
2. Add the Implementation [here](https://github.com/juspay/hyperswitch-encryption-service/tree/main/src/crypto)
3. Create a feature for Hashicorp Vault.
4. Add Initializer for Hashicorp Vault [here](https://github.com/juspay/hyperswitch-encryption-service/blob/main/src/config.rs#L174).

**Reference:**

- [Hyperswitch Keymanager](https://docs.hyperswitch.io/security-and-compliance/security#key-manager-service-encryption)

- Language: Rust
- Difficulty: Medium

### Submission Process:
- Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
- Once assigned, submit a pull request (PR).
- Maintainers will review and provide feedback, if any. 
- Maintainers can unassign issues due to inactivity, [read more here](https://github.com/juspay/hyperswitch/wiki/Hacktoberfest-Contribution-Rules).
- For this issue, please raise a PR on the https://github.com/juspay/hyperswitch-encryption-service repo, and link the issue.

Refer [here](https://github.com/juspay/hyperswitch/blob/main/docs/TERMS_OF_CONTEST.md) for Terms and conditions for the contest.
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index 5211b034eb5..982c1130207 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -7,6 +7,7 @@ default-run = "router"
 rust-version = "1.63"
 readme = "README.md"
 license = "Apache-2.0"
+build = "src/build.rs"
 
 [features]
 default = []
@@ -73,6 +74,9 @@ time = { version = "0.3.14", features = ["macros"] }
 tokio = "1.21.2"
 toml = "0.5.9"
 
+[build-dependencies]
+router_env = { version = "0.1.0", path = "../router_env", default-features = false, features = ["vergen"] }
+
 [[bin]]
 name = "router"
 path = "src/bin/router.rs"
diff --git a/crates/router/src/build.rs b/crates/router/src/build.rs
new file mode 100644
index 00000000000..4b07385af68
--- /dev/null
+++ b/crates/router/src/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+    router_env::vergen::generate_cargo_instructions();
+}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index d4dfbfb360c..6d1dd47e98d 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -11,6 +11,7 @@ use crate::{
 };
 
 #[derive(StructOpt, Default)]
+#[structopt(version = router_env::version!())]
 pub struct CmdLineConf {
     /// Config file.
     /// Application will look for "config/config.toml" if this option isn't specified.
diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml
index 53f994356ff..e97dc09d198 100644
--- a/crates/router_env/Cargo.toml
+++ b/crates/router_env/Cargo.toml
@@ -27,12 +27,13 @@ tracing-appender = "0.2.2"
 tracing-core = "0.1.29"
 tracing-opentelemetry = { version = "0.17" }
 tracing-subscriber = { version = "0.3.15", default-features = true, features = ["json", "env-filter", "registry"] }
+vergen = { version = "7.4.2", optional = true }
 
 [dev-dependencies]
 tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
 
 [build-dependencies]
-vergen = { version = "7.4.2" }
+vergen = "7.4.2"
 
 [features]
 default = ["actix_web"]
diff --git a/crates/router_env/src/build.rs b/crates/router_env/src/build.rs
index 28436458f30..aca12d76a1d 100644
--- a/crates/router_env/src/build.rs
+++ b/crates/router_env/src/build.rs
@@ -1,50 +1,5 @@
-use vergen::{vergen, Config, ShaKind};
+include!("vergen.rs");
 
 fn main() {
-    let mut config = Config::default();
-
-    let build = config.build_mut();
-    *build.enabled_mut() = false;
-    *build.skip_if_error_mut() = true;
-
-    let cargo = config.cargo_mut();
-    *cargo.enabled_mut() = true;
-    *cargo.features_mut() = false;
-    *cargo.profile_mut() = true;
-    *cargo.target_triple_mut() = true;
-
-    let git = config.git_mut();
-    *git.enabled_mut() = true;
-    *git.commit_author_mut() = false;
-    *git.commit_count_mut() = false;
-    *git.commit_message_mut() = false;
-    *git.commit_timestamp_mut() = true;
-    *git.semver_mut() = false;
-    *git.skip_if_error_mut() = true;
-    *git.sha_kind_mut() = ShaKind::Both;
-    *git.skip_if_error_mut() = true;
-
-    let rustc = config.rustc_mut();
-    *rustc.enabled_mut() = true;
-    *rustc.channel_mut() = false;
-    *rustc.commit_date_mut() = false;
-    *rustc.host_triple_mut() = false;
-    *rustc.llvm_version_mut() = false;
-    *rustc.semver_mut() = true;
-    *rustc.sha_mut() = true; // required for sever been available
-    *rustc.skip_if_error_mut() = true;
-
-    let sysinfo = config.sysinfo_mut();
-    *sysinfo.enabled_mut() = false;
-    *sysinfo.os_version_mut() = false;
-    *sysinfo.user_mut() = false;
-    *sysinfo.memory_mut() = false;
-    *sysinfo.cpu_vendor_mut() = false;
-    *sysinfo.cpu_core_count_mut() = false;
-    *sysinfo.cpu_name_mut() = false;
-    *sysinfo.cpu_brand_mut() = false;
-    *sysinfo.cpu_frequency_mut() = false;
-    *sysinfo.skip_if_error_mut() = true;
-
-    vergen(config).expect("Problem determining current platform characteristics");
+    generate_cargo_instructions();
 }
diff --git a/crates/router_env/src/env.rs b/crates/router_env/src/env.rs
index 229186f6dc5..518a1cac0cf 100644
--- a/crates/router_env/src/env.rs
+++ b/crates/router_env/src/env.rs
@@ -73,23 +73,25 @@ pub fn workspace_path() -> PathBuf {
     }
 }
 
-/// Version defined in the crate file.
+/// Version of the crate containing the following information:
 ///
-/// Example: `0.1.0`.
+/// - Semantic Version from the latest git tag. If tags are not present in the repository, crate
+///   version from the crate manifest is used instead.
+/// - Short hash of the latest git commit.
+/// - Timestamp of the latest git commit.
 ///
-
+/// Example: `0.1.0-abcd012-2038-01-19T03:14:08Z`.
 #[macro_export]
 macro_rules! version {
-    (
-    ) => {{
+    () => {
         concat!(
-            env!("CARGO_PKG_VERSION"),
+            env!("VERGEN_GIT_SEMVER"),
             "-",
             env!("VERGEN_GIT_SHA_SHORT"),
             "-",
             env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
         )
-    }};
+    };
 }
 
 ///
@@ -107,8 +109,7 @@ macro_rules! version {
 
 #[macro_export]
 macro_rules! build {
-    (
-    ) => {{
+    () => {
         concat!(
             env!("CARGO_PKG_VERSION"),
             "-",
@@ -122,7 +123,7 @@ macro_rules! build {
             "-",
             env!("VERGEN_CARGO_TARGET_TRIPLE"),
         )
-    }};
+    };
 }
 
 ///
@@ -133,10 +134,9 @@ macro_rules! build {
 
 #[macro_export]
 macro_rules! commit {
-    (
-    ) => {{
+    () => {
         env!("VERGEN_GIT_SHA")
-    }};
+    };
 }
 
 // ///
@@ -166,10 +166,9 @@ macro_rules! commit {
 
 #[macro_export]
 macro_rules! service_name {
-    (
-    ) => {{
+    () => {
         env!("CARGO_CRATE_NAME")
-    }};
+    };
 }
 
 ///
@@ -180,8 +179,7 @@ macro_rules! service_name {
 
 #[macro_export]
 macro_rules! profile {
-    (
-    ) => {
+    () => {
         env!("VERGEN_CARGO_PROFILE")
     };
 }
diff --git a/crates/router_env/src/lib.rs b/crates/router_env/src/lib.rs
index 3ecefb7a362..93eab6e2dcf 100644
--- a/crates/router_env/src/lib.rs
+++ b/crates/router_env/src/lib.rs
@@ -19,10 +19,12 @@
 #![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR" ), "/", "README.md"))]
 
 pub mod env;
-#[doc(inline)]
-pub use env::*;
-
 pub mod logger;
+/// `cargo` build instructions generation for obtaining information about the application
+/// environment.
+#[cfg(feature = "vergen")]
+pub mod vergen;
+
 // pub use literally;
 #[doc(inline)]
 pub use logger::*;
@@ -31,3 +33,6 @@ pub use tracing;
 #[cfg(feature = "actix_web")]
 pub use tracing_actix_web;
 pub use tracing_appender;
+
+#[doc(inline)]
+pub use self::env::*;
diff --git a/crates/router_env/src/vergen.rs b/crates/router_env/src/vergen.rs
new file mode 100644
index 00000000000..22e16605a2b
--- /dev/null
+++ b/crates/router_env/src/vergen.rs
@@ -0,0 +1,60 @@
+/// Configures the [`vergen`][::vergen] crate to generate the `cargo` build instructions.
+///
+/// This function should be typically called within build scripts to generate `cargo` build
+/// instructions for the corresponding crate.
+///
+/// # Panics
+///
+/// Panics if `vergen` fails to generate `cargo` build instructions.
+#[allow(clippy::expect_used)]
+pub fn generate_cargo_instructions() {
+    use vergen::{vergen, Config, ShaKind};
+
+    let mut config = Config::default();
+
+    let build = config.build_mut();
+    *build.enabled_mut() = false;
+    *build.skip_if_error_mut() = true;
+
+    let cargo = config.cargo_mut();
+    *cargo.enabled_mut() = true;
+    *cargo.features_mut() = false;
+    *cargo.profile_mut() = true;
+    *cargo.target_triple_mut() = true;
+
+    let git = config.git_mut();
+    *git.enabled_mut() = true;
+    *git.commit_author_mut() = false;
+    *git.commit_count_mut() = false;
+    *git.commit_message_mut() = false;
+    *git.commit_timestamp_mut() = true;
+    *git.semver_mut() = true;
+    *git.semver_dirty_mut() = Some("-dirty");
+    *git.skip_if_error_mut() = true;
+    *git.sha_kind_mut() = ShaKind::Both;
+    *git.skip_if_error_mut() = true;
+
+    let rustc = config.rustc_mut();
+    *rustc.enabled_mut() = true;
+    *rustc.channel_mut() = false;
+    *rustc.commit_date_mut() = false;
+    *rustc.host_triple_mut() = false;
+    *rustc.llvm_version_mut() = false;
+    *rustc.semver_mut() = true;
+    *rustc.sha_mut() = true; // required for semver to be available
+    *rustc.skip_if_error_mut() = true;
+
+    let sysinfo = config.sysinfo_mut();
+    *sysinfo.enabled_mut() = false;
+    *sysinfo.os_version_mut() = false;
+    *sysinfo.user_mut() = false;
+    *sysinfo.memory_mut() = false;
+    *sysinfo.cpu_vendor_mut() = false;
+    *sysinfo.cpu_core_count_mut() = false;
+    *sysinfo.cpu_name_mut() = false;
+    *sysinfo.cpu_brand_mut() = false;
+    *sysinfo.cpu_frequency_mut() = false;
+    *sysinfo.skip_if_error_mut() = true;
+
+    vergen(config).expect("Failed to generate `cargo` build instructions");
+}

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [x] Enhancement
- [ ] Refactoring
- [ ] Dependency updates

## Description
<!-- Describe your changes in detail -->
This PR adds the following two fields of information to the output of `router --version`:

- Short git commit hash
- Git commit timestamp

In addition, the version number in the output is obtained in the below fashion:

- If git tags are present in the repository which follow Semantic Versioning, the Semantic Version from the latest git tag is used.
- If git tags are not present in the repository, the crate version from the crate manifest is used instead.
- If git tags are present and the working directory is dirty (files are modified), then the Semantic Version also includes a `-dirty` suffix.

### Additional Changes

- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!-- 
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->
N/A

## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless its an obvious bug or documentation fix
that will have little conversation).
-->
I felt the need to include the git commit hash when adding the bug report template in #20. I realized that having the git commit hash included in the output of `router --version` would ease analyzing bug reports for us maintainers. Thus, the PR.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
Manual testing.

- When no Semantic Versioned git tags are present: `router 0.2.0-d411595-2022-11-25T11:33:52Z`
- When Semantic Versioned git tags are present: `router v0.1.0-d411595-2022-11-25T11:33:52Z`
- When Semantic Versioned git tags are present and the working directory is dirty: `router v0.1.0-dirty-d411595-2022-11-25T11:33:52Z`

PS: Let me know if the above outputs look hard to read, we can have them separated by spaces instead, to have the output like so: `router v0.1.0 d411595 2022-11-25T11:33:52Z`


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
