Releases: cloudfoundry-rs/cf-env
Releases · cloudfoundry-rs/cf-env
v0.1.9 - update dependencies
Update Cargo.toml chore: update version to 0.1.9
v0.1.8 - updating serde dependency
v0.1.7 - updating dependencies
feat:bump version to 0.1.7
v0.1.6 - Dependency updates
Merge pull request #23 from somehowchris/renovate/serde_json-1.x fix(deps): update rust crate serde_json to 1.0.79
v0.1.5 - Dependency updates
feat: update version
v0.1.4 - Dependency updates
style: cargo fmt
v0.1.3 - Tested and Used
Includes the following progresses:
- Tests for over 90% of the code, using codecov, tests are loosly checked with assert macros
- Changes to the
Application
struct with more optional fields for better compatibility
v0.1.2 - Initial release
This initial release lets you access all the common known environment variables in a cloud foundry environment
Usage
Getting this crate is easy as adding it to your dependencies
[dependencies]
cf-env = "0.0.1"
After that, just check what you need and get it, you may wanna check out the docs.rs page. For example CF_INSTANCE_INDEX
let instance_index = cf_env::get_instance_index().unwrap();
Or for example if you need to get some credentials:
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct CustomCredentials {
pub password: String,
pub username: String,
pub host: String,
pub port: u16,
}
// After that you can use it
let service = cf_env::get_service_by_name::<CustomCredentials>("my_db").unwrap();
There is no need for typed credentials if you would like to parse it anyway and then deal with the Value
enum from serde_json
use serde_json::Value;
use cf_env::Service;
let service: Service<Value> = cf_env::get_service_by_name("my_db").unwrap();
let uri = service.credentials["uri"].as_str().unwrap();
Full Changelog: https://github.com/somehowchris/cf-env/commits/0.1.0