Skip to content

Commit 2632def

Browse files
Merge branch 'main' into feat/post-clone-script-for-git-clone-module
2 parents 1cd85f1 + ccdca6d commit 2632def

File tree

10 files changed

+575
-22
lines changed

10 files changed

+575
-22
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
run: bun install
2929
- name: Run TypeScript tests
3030
run: bun test
31+
- name: Run Terraform tests
32+
run: ./scripts/terraform_test_all.sh
3133
- name: Run Terraform Validate
3234
run: bun terraform-validate
3335
validate-style:

.icons/nexus-repository.svg

Lines changed: 5 additions & 0 deletions
Loading

CONTRIBUTING.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,23 @@ This script generates:
124124
- Accurate description and usage examples
125125
- Correct icon path (usually `../../../../.icons/your-icon.svg`)
126126
- Proper tags that describe your module
127-
3. **Create at least one `.tftest.hcl`** to test your module with `terraform test`
127+
3. **Create tests for your module:**
128+
- **Terraform tests**: Create a `*.tftest.hcl` file and test with `terraform test`
129+
- **TypeScript tests**: Create `main.test.ts` file if your module runs scripts or has business logic that Terraform tests can't cover
128130
4. **Add any scripts** or additional files your module needs
129131

130132
### 4. Test and Submit
131133

132134
```bash
133-
# Test your module (from the module directory)
135+
# Test your module
136+
cd registry/[namespace]/modules/[module-name]
137+
138+
# Required: Test Terraform functionality
134139
terraform init -upgrade
135140
terraform test -verbose
136141

137-
# Or run all tests in the repo
138-
./scripts/terraform_test_all.sh
142+
# Optional: Test TypeScript files if you have main.test.ts
143+
bun test main.test.ts
139144

140145
# Format code
141146
bun run fmt
@@ -343,8 +348,8 @@ coder templates push test-[template-name] -d .
343348
terraform init -upgrade
344349
terraform test -verbose
345350

346-
# Test all modules
347-
./scripts/terraform_test_all.sh
351+
# Optional: If you have TypeScript tests
352+
bun test main.test.ts
348353
```
349354

350355
### 3. Maintain Backward Compatibility
@@ -393,7 +398,9 @@ Example: `https://github.com/coder/registry/compare/main...your-branch?template=
393398
### Every Module Must Have
394399

395400
- `main.tf` - Terraform code
396-
- One or more `.tftest.hcl` files - Working tests with `terraform test`
401+
- **Tests**:
402+
- `*.tftest.hcl` files with `terraform test` (to test terraform specific logic)
403+
- `main.test.ts` file with `bun test` (to test business logic, i.e., `coder_script` to install a package.)
397404
- `README.md` - Documentation with frontmatter
398405

399406
### Every Template Must Have
@@ -493,7 +500,7 @@ When reporting bugs, include:
493500
2. **No tests** or broken tests
494501
3. **Hardcoded values** instead of variables
495502
4. **Breaking changes** without defaults
496-
5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`) before submitting
503+
5. **Not running** formatting (`bun run fmt`) and tests (`terraform test`, and `bun test main.test.ts` if applicable) before submitting
497504

498505
## For Maintainers
499506

examples/modules/MODULE_NAME.tftest.hcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ run "app_url_uses_port" {
1515
}
1616

1717
assert {
18-
condition = resource.coder_app.MODULE_NAME.url == "http://localhost:19999"
19-
error_message = "Expected MODULE_NAME app URL to include configured port"
18+
condition = resource.coder_app.module_name.url == "http://localhost:19999"
19+
error_message = "Expected module-name app URL to include configured port"
2020
}
2121
}

examples/modules/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ variable "agent_id" {
3535

3636
variable "log_path" {
3737
type = string
38-
description = "The path to log MODULE_NAME to."
39-
default = "/tmp/MODULE_NAME.log"
38+
description = "The path to the module log file."
39+
default = "/tmp/module_name.log"
4040
}
4141

4242
variable "port" {
4343
type = number
44-
description = "The port to run MODULE_NAME on."
44+
description = "The port to run the application on."
4545
default = 19999
4646
}
4747

@@ -59,9 +59,9 @@ variable "order" {
5959
# Add other variables here
6060

6161

62-
resource "coder_script" "MODULE_NAME" {
62+
resource "coder_script" "module_name" {
6363
agent_id = var.agent_id
64-
display_name = "MODULE_NAME"
64+
display_name = "Module Name"
6565
icon = local.icon_url
6666
script = templatefile("${path.module}/run.sh", {
6767
LOG_PATH : var.log_path,
@@ -70,10 +70,10 @@ resource "coder_script" "MODULE_NAME" {
7070
run_on_stop = false
7171
}
7272

73-
resource "coder_app" "MODULE_NAME" {
73+
resource "coder_app" "module_name" {
7474
agent_id = var.agent_id
75-
slug = "MODULE_NAME"
76-
display_name = "MODULE_NAME"
75+
slug = "module-name"
76+
display_name = "Module Name"
7777
url = "http://localhost:${var.port}"
7878
icon = local.icon_url
7979
subdomain = false
@@ -88,10 +88,10 @@ resource "coder_app" "MODULE_NAME" {
8888
}
8989
}
9090

91-
data "coder_parameter" "MODULE_NAME" {
92-
type = "list(string)"
93-
name = "MODULE_NAME"
94-
display_name = "MODULE_NAME"
91+
data "coder_parameter" "module_name" {
92+
type = "string"
93+
name = "module_name"
94+
display_name = "Module Name"
9595
icon = local.icon_url
9696
mutable = var.mutable
9797
default = local.options["Option 1"]["value"]

registry/mavrickrishi/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ participating in LFX CNCF programs, and helping the developer community grow.
1919
## Modules
2020

2121
- **aws-ami-snapshot**: Create and manage AMI snapshots for Coder workspaces with restore capabilities
22+
- [nexus-repository](./modules/nexus-repository/) - Configure package managers to use Sonatype Nexus Repository
2223
- [auto-start-dev-server](modules/auto-start-dev-server/README.md) - Automatically detect and start development servers for various project types
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
---
2+
display_name: Nexus Repository
3+
description: Configure package managers to use Sonatype Nexus Repository for Maven, npm, PyPI, and Docker registries.
4+
icon: ../../../../.icons/nexus-repository.svg
5+
verified: true
6+
tags: [integration, nexus-repository, maven, npm, pypi, docker]
7+
---
8+
9+
# Sonatype Nexus Repository
10+
11+
Configure package managers (Maven, npm, Go, PyPI, Docker) to use [Sonatype Nexus Repository](https://help.sonatype.com/en/sonatype-nexus-repository.html) with API token authentication. This module provides secure credential handling, multiple repository support per package manager, and flexible username configuration.
12+
13+
```tf
14+
module "nexus_repository" {
15+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
16+
version = "1.0.0"
17+
agent_id = coder_agent.example.id
18+
nexus_url = "https://nexus.example.com"
19+
nexus_password = var.nexus_api_token
20+
package_managers = {
21+
maven = ["maven-public", "maven-releases"]
22+
npm = ["npm-public", "@scoped:npm-private"]
23+
go = ["go-public", "go-private"]
24+
pypi = ["pypi-public", "pypi-private"]
25+
docker = ["docker-public", "docker-private"]
26+
}
27+
}
28+
```
29+
30+
## Requirements
31+
32+
- Nexus Repository Manager 3.x
33+
- Valid API token or user credentials
34+
- Package managers installed on the workspace (Maven, npm, Go, pip, Docker as needed)
35+
36+
> [!NOTE]
37+
> This module configures package managers but does not install them. You need to handle the installation of Maven, npm, Go, Python pip, and Docker yourself.
38+
39+
## Examples
40+
41+
### Configure Maven to use Nexus repositories
42+
43+
```tf
44+
module "nexus_repository" {
45+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
46+
version = "1.0.0"
47+
agent_id = coder_agent.example.id
48+
nexus_url = "https://nexus.example.com"
49+
nexus_password = var.nexus_api_token
50+
package_managers = {
51+
maven = ["maven-public", "maven-releases", "maven-snapshots"]
52+
}
53+
}
54+
```
55+
56+
### Configure npm with scoped packages
57+
58+
```tf
59+
module "nexus_repository" {
60+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
61+
version = "1.0.0"
62+
agent_id = coder_agent.example.id
63+
nexus_url = "https://nexus.example.com"
64+
nexus_password = var.nexus_api_token
65+
package_managers = {
66+
npm = ["npm-public", "@mycompany:npm-private"]
67+
}
68+
}
69+
```
70+
71+
### Configure Go module proxy
72+
73+
```tf
74+
module "nexus_repository" {
75+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
76+
version = "1.0.0"
77+
agent_id = coder_agent.example.id
78+
nexus_url = "https://nexus.example.com"
79+
nexus_password = var.nexus_api_token
80+
package_managers = {
81+
go = ["go-public", "go-private"]
82+
}
83+
}
84+
```
85+
86+
### Configure Python PyPI repositories
87+
88+
```tf
89+
module "nexus_repository" {
90+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
91+
version = "1.0.0"
92+
agent_id = coder_agent.example.id
93+
nexus_url = "https://nexus.example.com"
94+
nexus_password = var.nexus_api_token
95+
package_managers = {
96+
pypi = ["pypi-public", "pypi-private"]
97+
}
98+
}
99+
```
100+
101+
### Configure Docker registries
102+
103+
```tf
104+
module "nexus_repository" {
105+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
106+
version = "1.0.0"
107+
agent_id = coder_agent.example.id
108+
nexus_url = "https://nexus.example.com"
109+
nexus_password = var.nexus_api_token
110+
package_managers = {
111+
docker = ["docker-public", "docker-private"]
112+
}
113+
}
114+
```
115+
116+
### Use custom username
117+
118+
```tf
119+
module "nexus_repository" {
120+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
121+
version = "1.0.0"
122+
agent_id = coder_agent.example.id
123+
nexus_url = "https://nexus.example.com"
124+
nexus_username = "custom-user"
125+
nexus_password = var.nexus_api_token
126+
package_managers = {
127+
maven = ["maven-public"]
128+
}
129+
}
130+
```
131+
132+
### Complete configuration for all package managers
133+
134+
```tf
135+
module "nexus_repository" {
136+
source = "registry.coder.com/mavrickrishi/nexus-repository/coder"
137+
version = "1.0.0"
138+
agent_id = coder_agent.example.id
139+
nexus_url = "https://nexus.example.com"
140+
nexus_password = var.nexus_api_token
141+
package_managers = {
142+
maven = ["maven-public", "maven-releases"]
143+
npm = ["npm-public", "@company:npm-private"]
144+
go = ["go-public", "go-private"]
145+
pypi = ["pypi-public", "pypi-private"]
146+
docker = ["docker-public", "docker-private"]
147+
}
148+
}
149+
```

0 commit comments

Comments
 (0)