Add External Config Helper Support for Enhanced Credential Management #441
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements external config helper functionality for the Rancher CLI, enabling integration with external credential management systems, password managers, and CI/CD pipelines.
Motivation
Users and organizations often need to integrate the Rancher CLI with their existing credential management infrastructure rather than storing sensitive credentials in local files. This feature addresses that need by providing a pluggable config helper system, similar to Hashicorp Vault credential helper or AWS CLI credential helper.
What's Changed
Core Features
--config-helper
withRANCHER_CONFIG_HELPER
environment variable supportget
/store
command interface with JSON config exchangeImplementation Details
config.LoadWithHelper()
function for external helper supportConfig.Write()
method with automatic helper detectionloadConfig()
incmd/common.go
to respect helper settingsUse Cases Enabled
Testing
Comprehensive Test Coverage
Test Results
All tests pass including:
TestLoadWithHelper
- External helper loading scenariosTestConfigWrite
- Config persistence with helpersTestHelperProtocol
- Command protocol verificationTestConfigHelperIntegration
- End-to-end integration testsBreaking Changes
None. This is a fully backward-compatible addition.
Usage Examples
Basic Usage
Example Helper Script
Files Changed
main.go
: Added--config-helper
CLI flagcmd/common.go
: ModifiedloadConfig()
for helper supportconfig/config.go
: Added helper loading/writing functionalityconfig/config_test.go
: Comprehensive test suitecmd/common_test.go
: Integration testsREADME.md
: Complete documentation with examplesDocumentation
The README now includes a dedicated "External Config Helper Support" section with:
Type: Feature
Breaking Changes: None
Documentation: Updated README with comprehensive guide
Testing: Full test coverage with integration tests