Comments (5)
@jcaesar you are more than welcome to submit a pull request that adds the example. tests/mod.rs
has a few examples.
As for env expansion, nothing is built into this crate that would do something like that automatically, contributions welcome.
from docker-compose-types.
@jcaesar I'm going to close this issue for now, feel free to come by and help us improve the README if you still want to at some point in the future.
from docker-compose-types.
Hm. Looking at haddock, variable interpolation is somewhat complex (there's a nom parser behind this). I could make a PR that copies that code, but... :/ (One concrete problem is that that's GPL.).
[Edit:] Hm. compose_yml
implements variable interpolation. But it's quite out of dateβ¦
from docker-compose-types.
All right, since I have a concrete thing I need to implement, I'll go with
struct OsEnv;
impl compose_yml::v2::Environment for OsEnv {
fn var(&self, key: &str) -> Result<String, VarError> {
std::env::var(key)
}
}
fn interpolate(v: &mut YamlValue, e: &dyn compose_yml::v2::Environment) -> Result<()> {
match v {
YamlValue::String(s) => {
*s = compose_yml::v2::raw::<String, _>(s.clone())?
.interpolate_env(e)?
.clone();
}
YamlValue::Sequence(s) => {
for s in s {
interpolate(s, e)?;
}
}
YamlValue::Mapping(m) => {
for v in m.values_mut() {
interpolate(v, e)?;
}
}
YamlValue::Tagged(tagged) => interpolate(&mut tagged.value, e)?,
_ => (),
}
Ok(())
}
interpolate(&mut def, &OsEnv)?;
for now and worry about a pretty PR to docker-compose-types later.
from docker-compose-types.
Perfectly valid solution! Glad you managed to get something working for yourself.
from docker-compose-types.
Related Issues (15)
- docker compose version HOT 6
- Bump serde-yaml dependency to 0.9 HOT 1
- Environment too strict HOT 1
- Implement 'Clone' for ComposeFile, SingleService and Compose
- Top level Volume labels don't appear to work HOT 5
- Missing properties HOT 5
- Update indexmap to v2 HOT 1
- Support for Docker Compose Secrets? HOT 1
- Implement (behind a feature branch) the Merge Crate HOT 2
- Cannot mix long syntax and short syntax volume declaration HOT 2
- Add `userns_mode` and `cap_drop` fields to `Service` HOT 2
- Add `group_add` property to `Service`
- 'entrypoint' could be a string as well as a list
- Add missing Service properties
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-compose-types.