envlet 0.1.0

Pull your Envlet environment at runtime with one token.
Documentation
  • Coverage
  • 0%
    0 out of 20 items documented0 out of 6 items with examples
  • Size
  • Source code size: 51.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 167.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • fonseca-luisf

envlet

Pull your Envlet environment at runtime. The host platform holds one secret, an Envlet token, and your app loads everything else at boot.

use envlet::{inject, Error, Options};

fn main() -> Result<(), Error> {
    inject(&Options::default())?;
    Ok(())
}

inject fetches every value the token identity may read and sets the process environment. Values already set by the host are never overwritten. Set override_existing to replace existing values.

use envlet::{inject, Error, Options};

fn main() -> Result<(), Error> {
    let options = Options {
        override_existing: true,
        ..Options::default()
    };
    inject(&options)?;
    Ok(())
}

Use load to fetch all values or get to fetch one value. Each call fetches current values from Envlet, with no cache or partial result.

use envlet::{get, load, Error, Options};

fn read_values() -> Result<(), Error> {
    let options = Options::default();
    let _values = load(&options)?;
    let _stripe_key = get("STRIPE_KEY", &options)?;
    Ok(())
}

Configuration comes from ENVLET_TOKEN or Options::token. The API URL comes from ENVLET_API_URL, then defaults to https://api.envlet.dev. Set Options::api_url to select another URL. Network failures and 5xx responses retry up to three total attempts. Set Options::retry to false to send one request.

Errors use the Error enum. Error::Auth { code } carries API codes such as token_expired and unauthorized. Missing values use Error::NotFound, network failures use Error::Network, an absent token uses Error::ConfigMissing, a bad token or API URL uses Error::ConfigInvalid, and other API failures use Error::Api { code, status }. Error::code() returns the API code or the fixed code for fieldless variants.

The crate depends on ureq with rustls and nothing else. The Rust standard library has no HTTP client or TLS, so this is the one SDK with a dependency.

Use version 0.1.0 from crates.io after it is released:

[dependencies]
envlet = "0.1.0"

The crate is licensed under MIT. Source: https://github.com/selcor/envlet.