redisctl-config
Configuration and profile management for Redis CLI tools.
Overview
This library provides a reusable configuration and profile system for managing credentials and settings for Redis Cloud and Redis Enterprise deployments.
Features
- Multiple named profiles for different Redis deployments
- Secure credential storage using OS keyring (optional)
- Environment variable expansion in config files
- Platform-specific config file locations
- Support for both Redis Cloud and Redis Enterprise
Installation
Add this to your Cargo.toml:
[]
= "0.1"
# Optional: Enable secure credential storage
= { = "0.1", = ["secure-storage"] }
Usage
Basic Configuration
use ;
// Load configuration from standard location
let config = load?;
// Create a new Cloud profile
let profile = Profile ;
// Add profile to config
let mut config = default;
config.set_profile;
config.save?;
Profile Resolution
// Resolve which profile to use for Cloud operations
let profile_name = config.resolve_cloud_profile?;
let profile = config.profiles.get.unwrap;
// Get credentials with keyring support
if let Some = profile.resolve_cloud_credentials?
Credential Storage
use CredentialStore;
let store = new;
// Store credential in keyring (requires secure-storage feature)
let reference = store.store_credential?;
// Retrieve credential (with environment variable fallback)
let value = store.get_credential?;
Environment Variables
Credentials can reference environment variables in the config file:
[]
= "cloud"
= "${REDIS_CLOUD_API_KEY}"
= "${REDIS_CLOUD_SECRET_KEY}"
= "${REDIS_CLOUD_API_URL:-https://api.redislabs.com/v1}"
Config File Location
The config file is automatically placed in platform-specific locations:
- Linux/macOS:
~/.config/redisctl/config.toml - macOS (fallback):
~/Library/Application Support/com.redis.redisctl/config.toml - Windows:
%APPDATA%\redis\redisctl\config.toml
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.