Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/galleybytes/inclusterget
A basic http client for rust to GET resources in k8s when running in-cluster
https://github.com/galleybytes/inclusterget
Last synced: 8 days ago
JSON representation
A basic http client for rust to GET resources in k8s when running in-cluster
- Host: GitHub
- URL: https://github.com/galleybytes/inclusterget
- Owner: GalleyBytes
- License: apache-2.0
- Created: 2023-09-18T03:59:55.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-04T15:39:51.000Z (about 1 year ago)
- Last Synced: 2023-10-04T18:59:07.513Z (about 1 year ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# inclusterget
A basic http client for rust to GET resources in k8s when running in-cluster.
## Usage
Add the module as a Cargo.toml dependency:
```toml
[dependencies]
inclusterget = { path = "../inclusterget" }
```or
```toml
[dependencies]
inclusterget = { git = "https://github.com/galleybytes/inclusterget.git" }
```Example code:
```rust
use inclusterget;fn main() {
let group = inclusterget::env_with_default(String::from("GROUP"), String::from(""))
.expect("GROUP is not set");
let kind = inclusterget::env_with_default(String::from("KIND"), String::from(""))
.expect("KIND is not set");
let namespace = inclusterget::env_with_default(String::from("NAMESPACE"), String::from(""))
.expect("NAMESPACE is not set");
let resource = inclusterget::env_with_default(String::from("RESOURCE"), String::from(""))
.expect("RESOURCE is not set");let body =
inclusterget::get(group, kind, namespace, resource).expect("Failure getting resource");
println!("Response: {}", body);
}```
The response is a String that can then be parsed.