Skip to content

Conversation

@joshrotenberg
Copy link
Collaborator

@joshrotenberg joshrotenberg commented Oct 6, 2025

Summary

Add support package upload functionality using files-sdk 0.3.1 with secure, persistent storage for Files.com API keys.

Implements features from #379 (support package epic):

  • Package optimization (20-30% size reduction via log truncation)
  • Direct upload to Files.com
  • Secure API key management with OS keyring storage

Implementation Details

Secure Storage (Default)

The secure-storage feature is now enabled by default. API keys are stored in platform-native keychains:

  • macOS: Keychain
  • Windows: Credential Manager
  • Linux: Secret Service (GNOME Keyring, KWallet)

Configuration (Hybrid Approach)

Supports both global and per-profile API key storage:

# Global key
files_api_key = "keyring:files-api-key"

# Per-profile override
[profiles.prod]
files_api_key = "keyring:prod-files-key"

[profiles.dev]
files_api_key = "your-plaintext-key"

API Key Resolution Priority

  1. REDIS_ENTERPRISE_FILES_API_KEY environment variable
  2. Profile-specific files_api_key in config
  3. Global files_api_key in config
  4. System keyring (direct CLI storage)
  5. REDIS_FILES_API_KEY environment variable (fallback)

CLI Key Management

# Store in keyring
redisctl files-key set <key> --use-keyring

# Store in config (global or per-profile)
redisctl files-key set <key> --global
redisctl files-key set <key> --profile prod

# View and remove keys
redisctl files-key get [--profile <name>]
redisctl files-key remove --keyring|--global|--profile <name>

Package Optimization

The --optimize flag reduces support package size by 20-30% through:

  • Log file truncation (default: 1000 lines, configurable via --log-lines)
  • Nested gzip removal
  • Redundant file cleanup
# Optimize package
redisctl enterprise support-package cluster --optimize

# Show optimization details
redisctl enterprise support-package cluster --optimize --optimize-verbose

# Optimize and upload in one command
redisctl enterprise support-package cluster --optimize --upload --no-save

Upload Capability

# Upload with environment variable
export REDIS_ENTERPRISE_FILES_API_KEY="your-key"
redisctl enterprise support-package cluster --upload

# Upload without saving locally
redisctl enterprise support-package cluster --upload --no-save

# Database-specific package
redisctl enterprise support-package database 1 --upload

Comparison with spfetch

Feature parity with Redis's existing spfetch/rflat tool:

Feature spfetch redisctl
Support package download Yes Yes
Upload to Files.com Yes Yes
No-save option Yes Yes
Secure key storage Encrypted vault OS keyring
JSON output Yes Yes
Custom paths Yes Yes

Security improvements:

  • Native OS keyring integration vs custom encrypted vault
  • Hybrid config support (global + per-profile)
  • Explicit priority chain with clear resolution

Technical Changes

Dependencies

  • files-sdk: upgraded to 0.3.1 from crates.io
  • keyring: enabled platform-native features (apple-native, windows-native, linux-native)
  • secure-storage: changed from optional to default feature

New Files

  • crates/redisctl/src/commands/files_key.rs - Key management commands
  • crates/redisctl/src/commands/enterprise/support_package/optimizer.rs - Package optimization
  • crates/redisctl/src/commands/enterprise/support_package/upload.rs - Upload functionality

Config Schema

pub struct Config {
    pub files_api_key: Option<String>,  // Global key
    // ...
}

pub struct Profile {
    pub files_api_key: Option<String>,  // Per-profile override
    // ...
}

Testing

  • All 800+ tests passing
  • cargo fmt --all -- --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • Backward compatible (all new fields are optional)

Documentation

Updated:

  • README with support package quick start
  • mdbook docs with optimization and upload sections
  • CLAUDE.md with writing style guidelines

Use Cases

Individual Developer

redisctl files-key set <key> --use-keyring
redisctl enterprise support-package cluster --upload

CI/CD Pipeline

export REDIS_ENTERPRISE_FILES_API_KEY=${SECRET_FILES_KEY}
redisctl enterprise support-package cluster --upload --no-save

Multiple Files.com Accounts

[profiles.team-a]
deployment_type = "enterprise"
files_api_key = "keyring:team-a-files-key"

[profiles.team-b]
deployment_type = "enterprise"
files_api_key = "keyring:team-b-files-key"

Breaking Changes

None. All changes are backward compatible.

Closes #379

joshrotenberg and others added 3 commits October 6, 2025 15:22
- Update files-sdk dependency from local path to crates.io version 0.3.1
- Add support package upload functionality to Files.com
- Implement --upload and --no-save flags for support package commands
- Support cluster, database, and node support package uploads
- Add environment variable support for Files.com API key
- All existing functionality preserved and tests passing
This commit adds secure, persistent storage for Files.com API keys used
for support package uploads, addressing the critical need for users who
receive static keys from Redis Support.

- Made secure-storage feature part of default build
- Keys stored in OS keyring (macOS Keychain, Windows Credential Manager, Linux Secret Service)
- Eliminates need for plaintext API keys in environment variables

- Global files_api_key in config (applies to all profiles)
- Per-profile files_api_key override for flexibility
- Supports keyring: prefix for secure reference (e.g., files_api_key = "keyring:my-key")

1. REDIS_ENTERPRISE_FILES_API_KEY environment variable (CI/CD)
2. Profile-specific files_api_key in config
3. Global files_api_key in config
4. System keyring (direct CLI storage)
5. REDIS_FILES_API_KEY environment variable (fallback)

- redisctl files-key set <key> --use-keyring     # Secure (recommended)
- redisctl files-key set <key> --global          # Config file
- redisctl files-key set <key> --profile <name>  # Per-profile
- redisctl files-key get [--profile <name>]      # View current key
- redisctl files-key remove [--keyring|--global|--profile <name>]

Global key:
  files_api_key = "keyring:files-api-key"

Per-profile:
  [profiles.prod]
  files_api_key = "keyring:prod-files-key"

- Update Cargo.toml: secure-storage now in default features
- Add Config fields: global files_api_key + per-profile override
- Enhance upload.rs: full priority chain with config support
- Add files_key.rs: comprehensive key management handlers
- Add CLI commands: FilesKeyCommands enum with set/get/remove
- Update main.rs: routing and Profile initialization
- Fix clippy: collapsible if, needless return, test fixtures

- All builds pass with default features
- cargo fmt and clippy clean
- Config backward compatible (files_api_key is optional)

Closes #<issue> (if applicable)
Co-authored-by: Human <user@example.com>
Enable apple-native, windows-native, and linux-native features for the
keyring crate to use actual platform credential stores instead of mock
fallback. Without these features, keyring claims success but doesn't
persist to the system keychain/credential manager.

Tested on macOS with Files.com API key storage and retrieval working
correctly with support package uploads.
@joshrotenberg joshrotenberg force-pushed the feat/support-package-upload branch from ae1b468 to 5a8a1a5 Compare October 6, 2025 22:23
Add comprehensive documentation for new support package features:
- Package optimization with --optimize flag (20-30% size reduction)
- Direct upload to Files.com with --upload flag
- Secure API key management with files-key commands
- Update README with support package quick start
- Add writing style guidelines to CLAUDE.md to prevent emojis and marketing language
@joshrotenberg joshrotenberg merged commit d3a29d0 into main Oct 6, 2025
26 checks passed
@joshrotenberg joshrotenberg deleted the feat/support-package-upload branch October 6, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Package Complete Implementation Tracking (Epic)

2 participants