Skip to content

Commit 93059b8

Browse files
committed
feat(pgadmin): add new module for pgAdmin
1 parent 0a3c9b0 commit 93059b8

File tree

7 files changed

+107
-0
lines changed

7 files changed

+107
-0
lines changed

registry/AJ0070/.images/avtar.jpeg

63.6 KB
Loading

registry/AJ0070/New Text Document.txt

Whitespace-only changes.

registry/AJ0070/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
display_name: Ajithpalotte
3+
bio: Coder user and contributor.
4+
github: AJ0070
5+
avatar: ./.images/avatar.png
6+
status: community
7+
---
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
display_name: pgAdmin
3+
description: A module to add pgAdmin to your Coder workspace for easy access to PostgreSQL databases.
4+
icon: ../../../../.icons/postgres.svg
5+
maintainer_github: AJ0070
6+
verified: false
7+
tags: [helper, database, postgres, pgadmin]
8+
---
9+
10+
# pgAdmin
11+
12+
This module adds a pgAdmin app to your Coder workspace, providing a web-based interface for managing PostgreSQL databases.
13+
14+
```tf
15+
module "pgadmin" {
16+
count = data.coder_workspace.me.start_count
17+
source = "[registry.coder.com/AJ0070/pgadmin/coder](https://registry.coder.com/AJ0070/pgadmin/coder)"
18+
version = "1.0.0"
19+
agent_id = coder_agent.example.id
20+
}
21+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { describe } from "bun:test";
2+
import { runTerraformInit, testRequiredVariables } from "~test";
3+
4+
describe("pgadmin", async () => {
5+
await runTerraformInit(import.meta.dir);
6+
7+
testRequiredVariables(import.meta.dir, {
8+
agent_id: "foo",
9+
});
10+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
terraform {
2+
required_providers {
3+
coder = {
4+
source = "coder/coder"
5+
}
6+
}
7+
}
8+
9+
variable "agent_id" {
10+
type = string
11+
description = "The agent to install pgAdmin on."
12+
}
13+
14+
variable "port" {
15+
type = number
16+
description = "The port to run pgAdmin on."
17+
default = 5050
18+
}
19+
20+
variable "log_path" {
21+
type = string
22+
description = "The path to the log file."
23+
default = "/tmp/pgadmin.log"
24+
}
25+
26+
resource "coder_app" "pgadmin" {
27+
agent_id = var.agent_id
28+
display_name = "pgAdmin"
29+
slug = "pgadmin"
30+
icon = "/icon/postgres.svg"
31+
url = "http://localhost:${var.port}"
32+
share = "owner"
33+
}
34+
35+
resource "coder_script" "pgadmin" {
36+
agent_id = var.agent_id
37+
display_name = "Install pgAdmin"
38+
icon = "/icon/postgres.svg"
39+
run_on_start = true
40+
script = templatefile("${path.module}/run.sh", {
41+
PORT = var.port,
42+
LOG_PATH = var.log_path,
43+
})
44+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env sh
2+
3+
PORT=${PORT}
4+
LOG_PATH=${LOG_PATH}
5+
6+
BOLD='\033[0;1m'
7+
8+
printf "$${BOLD}Installing pgAdmin!\n"
9+
10+
if ! command -v pip > /dev/null 2>&1; then
11+
echo "pip is not installed"
12+
echo "Please install pip in your Dockerfile/VM image before using this module"
13+
exit 1
14+
fi
15+
16+
if ! command -v pgadmin4 > /dev/null 2>&1; then
17+
pip install pgadmin4-web
18+
echo "pgAdmin has been installed\n\n"
19+
else
20+
echo "pgAdmin is already installed\n\n"
21+
fi
22+
23+
echo "Starting pgAdmin in background..."
24+
echo "check logs at $${LOG_PATH}"
25+
pgadmin4 > $${LOG_PATH} 2>&1 &

0 commit comments

Comments
 (0)