@cf-plugins/cf-targets-plugin
v2.1.1
Published
Cloud Foundry CLI plugin for managing multiple API targets with easy switching and saving
Maintainers
Readme
CF Targets Plugin
Easily manage multiple Cloud Foundry API targets with seamless switching and saving.
This plugin simplifies working with multiple CF environments by allowing you to save, switch, and manage different API targets effortlessly. Perfect for developers working across development, staging, and production environments.
✨ Features
- Save Multiple Targets: Store unlimited CF API targets with custom names
- Quick Switching: Switch between environments with a single command
- Smart Diff Display: See exactly what changes when switching targets
- Cross-Platform: Works on Linux, macOS, and Windows (Intel & ARM)
- Secure: Redacts sensitive tokens in diff output
- Easy Installation: One-command npm installation with automatic CF CLI registration
🚀 Quick Start
1. Install the Plugin
npm install -g @cf-plugins/cf-targets-plugin2. Save Your First Target
cf api https://api.your-dev-environment.com
cf login
cf save-target development3. Save Additional Targets
cf api https://api.your-prod-environment.com
cf login
cf save-target production4. Switch Between Targets
cf set-target development
cf set-target productionThat's it! You're now managing multiple CF environments like a pro.
📖 Usage Examples
Save Current Target
# Save with a custom name
cf save-target my-dev-env
# Update existing target (with confirmation)
cf save-target production -fSwitch Targets
# Switch to saved target
cf set-target production
# Force switch (discards unsaved changes)
cf set-target development -fList All Targets
cf targetsOutput:
development
production (current)
stagingDelete Unused Targets
cf delete-target old-environment📋 Commands Reference
| Command | Usage | Description |
|---------|-------|-------------|
| targets | cf targets | List all saved targets |
| save-target | cf save-target [-f] [NAME] | Save current target |
| set-target | cf set-target [-f] NAME | Switch to saved target |
| delete-target | cf delete-target NAME | Delete saved target |
Command Options
-f, --force: Override confirmations and force the operation
🔧 Installation Options
Option 1: NPM (Recommended)
npm install -g @cf-plugins/cf-targets-pluginThe plugin automatically registers with CF CLI during installation.
Option 2: Manual Binary Installation
- Download binary from Releases
- Make executable:
chmod +x cf-targets-plugin-* - Install:
cf install-plugin /path/to/binary -f
Option 3: Build from Source
git clone https://github.com/Amit-A2Z/cf-targets-plugin.git
cd cf-targets-plugin
make build
cf install-plugin cf-targets-plugin -f🛠 Troubleshooting
Plugin Not Showing in cf plugins
# Check if plugin is installed
cf plugins | grep cf-targets
# If not found, manually register
cf install-plugin ~/.nvm/versions/node/*/lib/node_modules/@cf-plugins/cf-targets-plugin/bin/cf-targets-plugin -f
# Verify installation
cf pluginsPermission Denied Errors
# Make binary executable
chmod +x ~/.nvm/versions/node/*/lib/node_modules/@cf-plugins/cf-targets-plugin/bin/cf-targets-pluginCF CLI Not Found During Installation
- Install CF CLI: https://docs.cloudfoundry.org/cf-cli/install-go-cli.html
- Reinstall plugin:
npm install -g @cf-plugins/cf-targets-plugin
🏗 Building from Source
Requirements
- Go 1.25 or later
- Cloud Foundry CLI
Build Commands
# Build for current platform
make build
# Build for all platforms
make release-all
# Install locally
make install🌍 Supported Platforms
| Platform | Architecture | Status | |----------|-------------|---------| | Linux | AMD64 | ✅ Supported | | Linux | ARM64 | ✅ Supported | | macOS | Intel (AMD64) | ✅ Supported | | macOS | Apple Silicon (ARM64) | ✅ Supported | | Windows | AMD64 | ✅ Supported | | Windows | ARM64 | ✅ Supported |
🤝 Contributing
Contributions are welcome! Please feel free to submit issues and pull requests.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Note: This software is provided "AS IS" without warranty of any kind. Use at your own discretion.
Need help? Check out the Issues page or create a new issue for support.
