docker_secrets 0.2.0

Returns Docker secrets in Rust
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 9.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.06 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • olex-green/docker_secrets
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • olex-green

Docker Secrets

Crates.io Documentation License

A Rust library to easily access Docker secrets.

Docker secrets are mounted into the container at /run/secrets. This library provides a simple interface to read them.

Installation

Add this to your Cargo.toml:

[dependencies]
docker_secrets = "0.2.0"

Usage

Get all secrets

Returns a list of secret names found in /run/secrets.

use docker_secrets::get_list;

fn main() {
    match get_list() {
        Ok(secrets) => {
            for secret in secrets {
                println!("Found secret: {}", secret);
            }
        }
        Err(e) => eprintln!("Error listing secrets: {}", e),
    }
}

Get a specific secret

Reads the content of a specific secret.

use docker_secrets::get;

fn main() {
    match get("my_secret") {
        Ok(secret_value) => println!("Secret value: {}", secret_value),
        Err(e) => eprintln!("Error reading secret: {}", e),
    }
}

Configuration

By default, the library looks for secrets in /run/secrets. You can override this path by setting the DOCKER_SECRETS_DIR environment variable. This is useful for local development and testing.

export DOCKER_SECRETS_DIR=./my_local_secrets
cargo run

License

This project is licensed under either of

at your option.