Skip to content

Releases: cloudfoundry-rs/cf-env

v0.1.9 - update dependencies

13 Feb 19:03
ee88bac
Compare
Choose a tag to compare
Update Cargo.toml

chore: update version to 0.1.9

v0.1.8 - updating serde dependency

03 Aug 12:47
0.1.8
11e71dc
Compare
Choose a tag to compare

v0.1.7 - updating dependencies

28 Jul 18:17
1aa969f
Compare
Choose a tag to compare
feat:bump version to 0.1.7

v0.1.6 - Dependency updates

18 Feb 08:09
Compare
Choose a tag to compare
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

01 Feb 15:00
Compare
Choose a tag to compare
feat: update version

v0.1.4 - Dependency updates

11 Jan 20:15
Compare
Choose a tag to compare

v0.1.3 - Tested and Used

09 Dec 20:45
Compare
Choose a tag to compare

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

09 Dec 02:58
Compare
Choose a tag to compare

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