From dade42a759b2f15247cd08fdc5312824b9e79899 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 28 May 2019 10:20:22 +0000 Subject: [PATCH 1/3] cargo: add envsubst --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index e600c444..94b65050 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2018" [dependencies] actix = "^0.8.1" env_logger = "^0.6.1" +envsubst = "^0.1.0" failure = "^0.1.5" futures = "^0.1.26" chrono = "^0.4.6" From 62633dc9e3463484bad05195516534ee0807e854 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 28 May 2019 10:20:34 +0000 Subject: [PATCH 2/3] lockfile: refresh after changes --- Cargo.lock | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index c1c723eb..012b3910 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -437,6 +437,14 @@ dependencies = [ "termcolor 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "envsubst" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.8.1" @@ -2081,6 +2089,7 @@ dependencies = [ "actix 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "envsubst 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2147,6 +2156,7 @@ dependencies = [ "checksum encoding_rs 0.8.17 (registry+https://github.com/rust-lang/crates.io-index)" = "4155785c79f2f6701f185eb2e6b4caf0555ec03477cb4c70db67b465311620ed" "checksum enum-as-inner 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d58266c97445680766be408285e798d3401c6d4c378ec5552e78737e681e37d" "checksum env_logger 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b61fa891024a945da30a9581546e8cfaf5602c7b3f4c137a2805cf388f92075a" +"checksum envsubst 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "96bb109e9bbf902e948594cc5143cc21a97016bb56252db357657da5407cdf10" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum error-chain 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6930e04918388a9a2e41d518c25cf679ccafe26733fb4127dbf21993f2575d46" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" From e7758f57a4515b8947698c3408b93ea278c0ef51 Mon Sep 17 00:00:00 2001 From: Luca Bruno Date: Tue, 28 May 2019 10:21:11 +0000 Subject: [PATCH 3/3] cincinnati: support templated values in base URL This adds support for simple templated variables substitution on Cincinnati base URL. --- src/cincinnati/mod.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cincinnati/mod.rs b/src/cincinnati/mod.rs index 91e58076..dc489c33 100644 --- a/src/cincinnati/mod.rs +++ b/src/cincinnati/mod.rs @@ -28,11 +28,16 @@ impl Cincinnati { bail!("empty Cincinnati base URL"); } - // TODO(lucab): add envsubst - let _env = id.url_variables(); - let c = Self { - base_url: cfg.base_url, + /// Substitute templated key with agent runtime values. + let base_url = if envsubst::is_templated(&cfg.base_url) { + let context = id.url_variables(); + envsubst::validate_vars(&context)?; + envsubst::substitute(cfg.base_url, &context)? + } else { + cfg.base_url }; + + let c = Self { base_url }; Ok(c) }