Skip to content

A basic http client for rust to GET resources in k8s when running in-cluster

License

Notifications You must be signed in to change notification settings

GalleyBytes/inclusterget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

[dependencies]
inclusterget = { path = "../inclusterget" }

or

[dependencies]
inclusterget = { git = "https://github.com/galleybytes/inclusterget.git" }

Example code:

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.

About

A basic http client for rust to GET resources in k8s when running in-cluster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages