https://github.com/piszmog/cf-services
Retrieve configurations from Cloud Foundry with Rust.
https://github.com/piszmog/cf-services
cloud-foundry cloudfoundry pcf
Last synced: about 2 months ago
JSON representation
Retrieve configurations from Cloud Foundry with Rust.
- Host: GitHub
- URL: https://github.com/piszmog/cf-services
- Owner: Piszmog
- License: mit
- Created: 2021-11-14T23:13:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-02-05T01:15:58.000Z (over 1 year ago)
- Last Synced: 2025-03-11T17:07:43.021Z (2 months ago)
- Topics: cloud-foundry, cloudfoundry, pcf
- Language: Rust
- Homepage:
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# CF Services
[](https://crates.io/crates/cf-services)
[](https://github.com/Piszmog/cf-services/actions/workflows/rust.yml)
[](https://opensource.org/licenses/MIT)This library is aimed at removing the boilerplate code and let developers just worry about using actually connecting to
the services they have bounded to their app.## Retrieving VCAP_SERVICES
Simply use `cf_services::get_services_from_env()`.
```rust
use cf_services::get_services_from_env;fn main() {
let services = get_services_from_env().unwrap();
let service = services.get("serviceA").unwrap();
// Use information about service A to perform actions (such as creating an OAuth2 Client)
}
```## Retrieving Credentials of a Service
Call `cf_services::get_service_credentials(..)` by passing the `VCAP_SERVICES` marshalled JSON and the name of the
service to retrieve the credentials for. If `VCAP_SERVICES` is guaranteed to be an environment variable
use `cf_services::get_service_cred_from_env(..)`
instead.```rust
use cf_services::{get_services_from_env, get_service_credentials, get_service_cred_from_env};fn main() {
let services = get_services_from_env().unwrap();
let creds = get_service_credentials(services, "serviceB").unwrap();
// Use credentials...// Retrieve the JSON from the environment
let creds = get_service_cred_from_env("serviceB").unwrap();
// Use credentials...
}
```