Rishi Mondal
|
ce039f64df
|
Add Sonatype Nexus repository integration module (#262)
# Add Sonatype Nexus Repository Integration Module
## Summary
Implements a Coder module for Sonatype Nexus Repository Manager
integration that automatically configures Maven, npm, PyPI, and Docker
registries for development workspaces.
## Demo Video & Screenshots
https://github.com/user-attachments/assets/2c51f229-d34d-483b-a0e9-f4e0d79332c2

## Features
- ✅ **Maven Support**: Automatic `settings.xml` configuration
- ✅ **npm Support**: Automatic `.npmrc` configuration with scoped
packages
- ✅ **PyPI Support**: Automatic `pip.conf` configuration
- ✅ **Docker Support**: Registry authentication setup
- ✅ **Flexible Configuration**: Support for multiple repositories per
package manager
- ✅ **Secure Credentials**: API token and password support
- ✅ **Username Options**: Configurable username field (username or
email)
## Nexus Repository Manager Requirements
### Version Requirements
**Yes, this module requires Nexus Repository Manager Pro version** for
full functionality, though basic features work with the Community
Edition (OSS).
### Supported Authentication Methods
This module supports **4 authentication methods**:
1. **User Token Authentication** (Recommended - Pro only)
- Enhanced security with two-part tokens
- Ideal for CI/CD and automated environments
- Requires `nx-usertoken-current` privilege
2. **API Token Authentication** (Pro only)
- Single-use access tokens via REST API
- Programmatic token generation and management
3. **Basic Authentication** (OSS & Pro)
- Standard HTTP Basic Auth with username/password
- Works with both OSS and Pro versions
4. **Base64 Encoded Credentials** (OSS & Pro)
- Base64 encoded `username:password` format
- Compatible with npm and other package managers
### Testing Instructions
#### Prerequisites
- Nexus Repository Manager instance (OSS or Pro)
- Admin access to configure repositories
- Test repositories for each package manager you want to test
#### Setup Test Environment
1. **Create Test Repositories** in your Nexus instance:
- Maven: `maven-public`, `maven-releases`
- npm: `npm-public`, `@company:npm-private`
- PyPI: `pypi-public`, `pypi-private`
- Docker: `docker-public`, `docker-private`
2. **Configure Authentication**:
- For Pro: Generate user tokens via UI (User menu → User Token)
- For OSS: Use username/password or base64 encoded credentials
- Set up appropriate permissions for test repositories
3. **Test the Module**:
```hcl
module "nexus" {
source = "registry.coder.com/mavrickrishi/nexus/coder"
version = "1.0.0"
agent_id = coder_agent.main.id
nexus_url = "https://your-nexus-instance.com"
nexus_password = var.nexus_api_token # or password
package_managers = {
maven = ["maven-public", "maven-releases"]
npm = ["npm-public", "@company:npm-private"]
pypi = ["pypi-public", "pypi-private"]
docker = ["docker-public", "docker-private"]
}
}
```
4. **Verify Configuration**:
- Check generated config files in workspace
- Test package installation from configured repositories
- Verify authentication works for each package manager
#### EC2 Deployment Testing
Tested by deploying on EC2 instance with:
- Ubuntu 22.04 LTS
- Nexus Repository Manager Pro
- All package managers (Maven, npm, PyPI, Docker)
- Both token and basic authentication methods
## Usage Example
```hcl
module "nexus" {
source = "registry.coder.com/mavrickrishi/nexus/coder"
version = "1.0.0"
agent_id = coder_agent.main.id
nexus_url = "https://nexus.company.com"
nexus_password = var.nexus_api_token
package_managers = {
maven = ["maven-public", "maven-releases"]
npm = ["npm-public", "@company:npm-private"]
pypi = ["pypi-public", "pypi-private"]
docker = ["docker-public", "docker-private"]
}
}
```
## Testing
- ✅ 11 comprehensive tests covering all functionality
- ✅ Variable validation tests
- ✅ Package manager configuration tests
- ✅ Error handling tests
- ✅ All tests passing
- ✅ EC2 deployment tested
## Files Added
- `registry/mavrickrishi/modules/nexus/main.tf` - Main module
configuration
- `registry/mavrickrishi/modules/nexus/README.md` - Complete
documentation
- `registry/mavrickrishi/modules/nexus/main.test.ts` - Test suite
## Checklist
- [x] Module follows existing patterns and conventions
- [x] Comprehensive test coverage (11 tests)
- [x] Complete documentation with examples
- [x] Input validation and error handling
- [x] Secure credential handling
- [x] All tests passing
- [x] Demo video included
- [x] Screenshots added
- [x] Testing instructions provided
- [x] Authentication methods documented
- [x] EC2 deployment tested
Closes #202
/claim #202
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Atif Ali <me@matifali.dev>
Co-authored-by: DevCats <christofer@coder.com>
Co-authored-by: DevCats <chris@dualriver.com>
|
2025-10-09 07:31:43 -05:00 |
|