-
Notifications
You must be signed in to change notification settings - Fork 44
feat(pgadmin): add new module for pgAdmin #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AJ0070
wants to merge
14
commits into
coder:main
Choose a base branch
from
AJ0070:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
93059b8
feat(pgadmin): add new module for pgAdmin
AJ0070 af16096
changed display name
AJ0070 6319e67
Removed unnecessary Document
AJ0070 0338bd7
served over the subdomain by default, and then fallback to localhost
AJ0070 8f19fd9
improved this based on review
AJ0070 db8df71
ran fmt on the change
AJ0070 9947034
added correct implementation of the review
AJ0070 f9b3359
incorporated the changes of forked repo
AJ0070 542f8ec
fix failure workflow
AJ0070 c8f4ba2
Merge branch 'main' into main
DevelopmentCats d8ed39f
fixed typo and removed changes from filebrowser
AJ0070 ce103bd
fixed filebrowser run.sh
AJ0070 dc1872b
derefrenced postgress logo and referenced pgadmin logo
AJ0070 7ea3735
changed logo
AJ0070 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
display_name: Jash | ||
bio: Coder user and contributor. | ||
github: AJ0070 | ||
avatar: ./.images/avatar.png | ||
status: community | ||
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
display_name: pgAdmin | ||
description: A module to add pgAdmin to your Coder workspace for easy access to PostgreSQL databases. | ||
icon: ../../../../.icons/postgres.svg | ||
maintainer_github: AJ0070 | ||
verified: false | ||
tags: [helper, database, postgres, pgadmin] | ||
--- | ||
|
||
# pgAdmin | ||
|
||
This module adds a pgAdmin app to your Coder workspace, providing a web-based interface for managing PostgreSQL databases. | ||
|
||
```tf | ||
module "pgadmin" { | ||
count = data.coder_workspace.me.start_count | ||
source = "[registry.coder.com/AJ0070/pgadmin/coder](https://registry.coder.com/AJ0070/pgadmin/coder)" | ||
version = "1.0.0" | ||
agent_id = coder_agent.example.id | ||
} | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { describe } from "bun:test"; | ||
import { runTerraformInit, testRequiredVariables } from "~test"; | ||
|
||
describe("pgadmin", async () => { | ||
await runTerraformInit(import.meta.dir); | ||
|
||
testRequiredVariables(import.meta.dir, { | ||
agent_id: "foo", | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
terraform { | ||
required_providers { | ||
coder = { | ||
source = "coder/coder" | ||
} | ||
} | ||
} | ||
|
||
variable "agent_id" { | ||
type = string | ||
description = "The agent to install pgAdmin on." | ||
} | ||
|
||
variable "port" { | ||
type = number | ||
description = "The port to run pgAdmin on." | ||
default = 5050 | ||
} | ||
|
||
variable "log_path" { | ||
type = string | ||
description = "The path to the log file." | ||
default = "/tmp/pgadmin.log" | ||
} | ||
|
||
resource "coder_app" "pgadmin" { | ||
agent_id = var.agent_id | ||
display_name = "pgAdmin" | ||
slug = "pgadmin" | ||
icon = "/icon/postgres.svg" | ||
url = "http://localhost:${var.port}" | ||
AJ0070 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
share = "owner" | ||
} | ||
|
||
resource "coder_script" "pgadmin" { | ||
agent_id = var.agent_id | ||
display_name = "Install pgAdmin" | ||
icon = "/icon/postgres.svg" | ||
run_on_start = true | ||
script = templatefile("${path.module}/run.sh", { | ||
PORT = var.port, | ||
LOG_PATH = var.log_path, | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env sh | ||
|
||
PORT=${PORT} | ||
LOG_PATH=${LOG_PATH} | ||
|
||
BOLD='\033[0;1m' | ||
|
||
printf "$${BOLD}Installing pgAdmin!\n" | ||
|
||
if ! command -v pip > /dev/null 2>&1; then | ||
echo "pip is not installed" | ||
echo "Please install pip in your Dockerfile/VM image before using this module" | ||
exit 1 | ||
fi | ||
|
||
if ! command -v pgadmin4 > /dev/null 2>&1; then | ||
pip install pgadmin4-web | ||
echo "pgAdmin has been installed\n\n" | ||
else | ||
echo "pgAdmin is already installed\n\n" | ||
fi | ||
|
||
echo "Starting pgAdmin in background..." | ||
echo "check logs at $${LOG_PATH}" | ||
pgadmin4 > $${LOG_PATH} 2>&1 & |
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.
Uh oh!
There was an error while loading. Please reload this page.