Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0be882b8a4 | ||
|
|
0769fd1fd3 | ||
|
|
ab1e14b986 | ||
|
|
5aea44f11c | ||
|
|
832a8045d5 | ||
|
|
d25e6e6483 | ||
|
|
f309f16c7b | ||
|
|
1a0f6815ca | ||
|
|
76cfd9a091 | ||
|
|
4e808c6ff9 | ||
|
|
9974da1abe | ||
|
|
e414eaccec | ||
|
|
6f1ad4c20e | ||
|
|
b7030307ef | ||
|
|
9ab0660b14 | ||
|
|
56f688e8aa | ||
|
|
ba24332367 | ||
|
|
5fd0ca4be7 | ||
|
|
d7ed80f5f2 | ||
|
|
e5f7c9edf2 | ||
|
|
0dd6e10b6c | ||
|
|
60a95a7c4c | ||
|
|
2cc04faf19 | ||
|
|
b335d9c73a | ||
|
|
89981da556 | ||
|
|
caa7430508 | ||
|
|
32fa047fe7 | ||
|
|
b29cc0879b |
@@ -1,24 +1,25 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build-master:
|
||||
environment:
|
||||
DOKKU_VERSION: master
|
||||
machine:
|
||||
docker_layer_caching: false
|
||||
image: ubuntu-1604:201903-01
|
||||
version: 2.1
|
||||
|
||||
commands:
|
||||
build:
|
||||
description: "run the build"
|
||||
parameters:
|
||||
python_version:
|
||||
type: string
|
||||
default: "3.7.0"
|
||||
steps:
|
||||
- checkout
|
||||
- run: pyenv global 3.7.0
|
||||
- run: pyenv global << parameters.python_version >>
|
||||
- run: make setup
|
||||
- run: sudo sysctl -w vm.max_map_count=262144
|
||||
- run:
|
||||
command: |
|
||||
make generate;
|
||||
if [[ $(git diff) ]]; then
|
||||
echo "Please run `make generate`";
|
||||
git status --short;
|
||||
git diff;
|
||||
exit 1;
|
||||
make generate
|
||||
if ! git diff --quiet README.md; then
|
||||
echo "Please run `make generate`"
|
||||
git status --short
|
||||
git --no-pager diff README.md
|
||||
exit 1
|
||||
fi
|
||||
- run: make test
|
||||
- store_artifacts:
|
||||
@@ -30,35 +31,26 @@ jobs:
|
||||
- store_test_results:
|
||||
path: tmp/test-results
|
||||
|
||||
build-version:
|
||||
environment:
|
||||
DOKKU_VERSION: v0.19.0
|
||||
executors:
|
||||
machine:
|
||||
machine:
|
||||
docker_layer_caching: false
|
||||
image: ubuntu-1604:201903-01
|
||||
|
||||
jobs:
|
||||
build-master:
|
||||
environment:
|
||||
DOKKU_VERSION: master
|
||||
executor: machine
|
||||
steps:
|
||||
- checkout
|
||||
- run: pyenv global 3.7.0
|
||||
- run: make setup
|
||||
- run: sudo sysctl -w vm.max_map_count=262144
|
||||
- run:
|
||||
command: |
|
||||
make generate;
|
||||
if [[ $(git diff) ]]; then
|
||||
echo "Please run `make generate`";
|
||||
git status --short;
|
||||
git diff;
|
||||
exit 1;
|
||||
fi
|
||||
- run: make test
|
||||
- store_artifacts:
|
||||
path: build
|
||||
destination: build
|
||||
- store_artifacts:
|
||||
path: tmp/test-results
|
||||
destination: test-results
|
||||
- store_test_results:
|
||||
path: tmp/test-results
|
||||
- build
|
||||
|
||||
build-version:
|
||||
environment:
|
||||
DOKKU_VERSION: v0.19.0
|
||||
executor: machine
|
||||
steps:
|
||||
- build
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
1
Dockerfile
Normal file
1
Dockerfile
Normal file
@@ -0,0 +1 @@
|
||||
FROM postgres:11.6
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (C) 2018 Jose Diaz-Gonzalez
|
||||
Copyright (C) 2020 Jose Diaz-Gonzalez
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
79
README.md
79
README.md
@@ -1,4 +1,4 @@
|
||||
# dokku postgres [](https://travis-ci.org/dokku/dokku-postgres) [](https://webchat.freenode.net/?channels=dokku)
|
||||
# dokku postgres [](https://circleci.com/gh/dokku/dokku-postgres/tree/master) [](https://webchat.freenode.net/?channels=dokku)
|
||||
|
||||
Official postgres plugin for dokku. Currently defaults to installing [postgres 11.6](https://hub.docker.com/_/postgres/).
|
||||
|
||||
@@ -63,16 +63,24 @@ Help for any commands can be displayed by specifying the command as an argument
|
||||
dokku postgres:create <service> [--create-flags...]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-p|--password PASSWORD`: override the user-level service password
|
||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||
|
||||
Create a postgres service named lolipop:
|
||||
|
||||
```shell
|
||||
dokku postgres:create lolipop
|
||||
```
|
||||
|
||||
You can also specify the image and image version to use for the service. It *must* be compatible with the ${plugin_image} image.
|
||||
You can also specify the image and image version to use for the service. It *must* be compatible with the postgres image.
|
||||
|
||||
```shell
|
||||
export DATABASE_IMAGE="${PLUGIN_IMAGE}"
|
||||
export DATABASE_IMAGE="postgres"
|
||||
export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}"
|
||||
dokku postgres:create lolipop
|
||||
```
|
||||
@@ -91,6 +99,19 @@ dokku postgres:create lolipop
|
||||
dokku postgres:info <service> [--single-info-flag]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `--config-dir`: show the service configuration directory
|
||||
- `--data-dir`: show the service data directory
|
||||
- `--dsn`: show the service DSN
|
||||
- `--exposed-ports`: show service exposed ports
|
||||
- `--id`: show the service container id
|
||||
- `--internal-ip`: show the service internal ip
|
||||
- `--links`: show the service app links
|
||||
- `--service-root`: show the service root directory
|
||||
- `--status`: show the service running status
|
||||
- `--version`: show the service image version
|
||||
|
||||
Get connection information as follows:
|
||||
|
||||
```shell
|
||||
@@ -132,6 +153,10 @@ dokku postgres:list
|
||||
dokku postgres:logs <service> [-t|--tail]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-t|--tail`: do not stop when end of the logs are reached and wait for additional output
|
||||
|
||||
You can tail logs for a particular service:
|
||||
|
||||
```shell
|
||||
@@ -151,6 +176,11 @@ dokku postgres:logs lolipop --tail
|
||||
dokku postgres:link <service> <app> [--link-flags...]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-a|--alias "BLUE_DATABASE"`: an alternative alias to use for linking to an app via environment variable
|
||||
- `-q|--querystring "pool=5"`: ampersand delimited querystring arguments to append to the service link
|
||||
|
||||
A postgres service can be linked to a container. This will use native docker links via the docker-options plugin. Here we link it to our 'playground' app.
|
||||
|
||||
> NOTE: this will restart your app
|
||||
@@ -182,14 +212,14 @@ The host exposed here only works internally in docker containers. If you want yo
|
||||
dokku postgres:link other_service playground
|
||||
```
|
||||
|
||||
It is possible to change the protocol for database_url by setting the environment variable database_database_scheme on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding.
|
||||
It is possible to change the protocol for `DATABASE_URL` by setting the environment variable `POSTGRES_DATABASE_SCHEME` on the app. Doing so will after linking will cause the plugin to think the service is not linked, and we advise you to unlink before proceeding.
|
||||
|
||||
```shell
|
||||
dokku config:set playground DATABASE_DATABASE_SCHEME=postgres2
|
||||
dokku config:set playground POSTGRES_DATABASE_SCHEME=postgres2
|
||||
dokku postgres:link lolipop playground
|
||||
```
|
||||
|
||||
This will cause database_url to be set as:
|
||||
This will cause `DATABASE_URL` to be set as:
|
||||
|
||||
```
|
||||
postgres2://lolipop:SOME_PASSWORD@dokku-postgres-lolipop:5432/lolipop
|
||||
@@ -253,10 +283,10 @@ dokku postgres:enter lolipop touch /tmp/test
|
||||
dokku postgres:expose <service> <ports...>
|
||||
```
|
||||
|
||||
Expose the service on the service's normal ports, allowing access to it from the public interface (0. 0. 0. 0):
|
||||
Expose the service on the service's normal ports, allowing access to it from the public interface (`0.0.0.0`):
|
||||
|
||||
```shell
|
||||
dokku postgres:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
|
||||
dokku postgres:expose lolipop 5432
|
||||
```
|
||||
|
||||
### unexpose a previously exposed postgres service
|
||||
@@ -266,7 +296,7 @@ dokku postgres:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
|
||||
dokku postgres:unexpose <service>
|
||||
```
|
||||
|
||||
Unexpose the service, removing access to it from the public interface (0. 0. 0. 0):
|
||||
Unexpose the service, removing access to it from the public interface (`0.0.0.0`):
|
||||
|
||||
```shell
|
||||
dokku postgres:unexpose lolipop
|
||||
@@ -293,7 +323,7 @@ You can promote the new service to be the primary one:
|
||||
dokku postgres:promote other_service playground
|
||||
```
|
||||
|
||||
This will replace database_url with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example:
|
||||
This will replace `DATABASE_URL` with the url from other_service and generate another environment variable to hold the previous value if necessary. You could end up with the following for example:
|
||||
|
||||
```
|
||||
DATABASE_URL=postgres://other_service:ANOTHER_PASSWORD@dokku-postgres-other-service:5432/other_service
|
||||
@@ -347,6 +377,13 @@ dokku postgres:restart lolipop
|
||||
dokku postgres:upgrade <service> [--upgrade-flags...]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-R|--restart-apps "true"`: whether to force an app restart
|
||||
|
||||
You can upgrade an existing service to a new image or image-version:
|
||||
|
||||
```shell
|
||||
@@ -377,6 +414,14 @@ dokku postgres:app-links playground
|
||||
dokku postgres:clone <service> <new-service> [--clone-flags...]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-C|--custom-env "USER=alpha;HOST=beta"`: semi-colon delimited environment variables to start the service with
|
||||
- `-i|--image IMAGE`: the image name to start the service with
|
||||
- `-I|--image-version IMAGE_VERSION`: the image version to start the service with
|
||||
- `-p|--password PASSWORD`: override the user-level service password
|
||||
- `-r|--root-password PASSWORD`: override the root-level service password
|
||||
|
||||
You can clone an existing service to a new one:
|
||||
|
||||
```shell
|
||||
@@ -517,7 +562,11 @@ dokku postgres:backup-deauth lolipop
|
||||
dokku postgres:backup <service> <bucket-name> [--use-iam]
|
||||
```
|
||||
|
||||
Backup the 'lolipop' service to the 'my-s3-bucket' bucket on aws:
|
||||
flags:
|
||||
|
||||
- `-u|--use-iam`: use the IAM profile associated with the current server
|
||||
|
||||
Backup the 'lolipop' service to the 'my-s3-bucket' bucket on ``AWS`:`
|
||||
|
||||
```shell
|
||||
dokku postgres:backup lolipop my-s3-bucket --use-iam
|
||||
@@ -530,7 +579,7 @@ dokku postgres:backup lolipop my-s3-bucket --use-iam
|
||||
dokku postgres:backup-set-encryption <service> <passphrase>
|
||||
```
|
||||
|
||||
Set a gpg passphrase for backups:
|
||||
Set the GPG-compatible passphrase for encrypting backups for backups:
|
||||
|
||||
```shell
|
||||
dokku postgres:backup-set-encryption lolipop
|
||||
@@ -543,7 +592,7 @@ dokku postgres:backup-set-encryption lolipop
|
||||
dokku postgres:backup-unset-encryption <service>
|
||||
```
|
||||
|
||||
Unset a gpg encryption key for backups:
|
||||
Unset the `GPG` encryption passphrase for backups:
|
||||
|
||||
```shell
|
||||
dokku postgres:backup-unset-encryption lolipop
|
||||
@@ -556,6 +605,10 @@ dokku postgres:backup-unset-encryption lolipop
|
||||
dokku postgres:backup-schedule <service> <schedule> <bucket-name> [--use-iam]
|
||||
```
|
||||
|
||||
flags:
|
||||
|
||||
- `-u|--use-iam`: use the IAM profile associated with the current server
|
||||
|
||||
Schedule a backup:
|
||||
|
||||
> 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am
|
||||
|
||||
246
bin/generate
246
bin/generate
@@ -5,50 +5,84 @@ import os
|
||||
import re
|
||||
|
||||
|
||||
def compile(service, version, alias, scheme, ports, unimplemented, dokku_version):
|
||||
return "\n\n".join([
|
||||
def compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, dokku_version):
|
||||
prefix = "\n\n".join([
|
||||
header(service),
|
||||
description(service, version),
|
||||
description(service, image, version),
|
||||
])
|
||||
|
||||
if len(sponsors) > 0:
|
||||
prefix += "\n\n"
|
||||
prefix += sponsors_section(service, sponsors)
|
||||
|
||||
return (
|
||||
"\n\n".join(
|
||||
[
|
||||
prefix,
|
||||
requirements_section(dokku_version),
|
||||
installation_section(service, dokku_version),
|
||||
commands_section(service, alias, scheme, ports, unimplemented),
|
||||
usage_section(service, alias, scheme, ports, unimplemented),
|
||||
]).replace("\n\n\n\n\n", "\n").replace("\n\n\n\n", "\n").replace("\n\n\n", "\n\n")
|
||||
commands_section(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_section(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
]
|
||||
)
|
||||
.replace("\n\n\n\n\n", "\n")
|
||||
.replace("\n\n\n\n", "\n")
|
||||
.replace("\n\n\n", "\n\n")
|
||||
)
|
||||
|
||||
|
||||
def header(service):
|
||||
return " ".join([
|
||||
return " ".join(
|
||||
[
|
||||
f"# dokku {service}",
|
||||
f"[](https://travis-ci.org/dokku/dokku-{service})",
|
||||
f"[](https://webchat.freenode.net/?channels=dokku)",
|
||||
])
|
||||
f'[](https://circleci.com/gh/dokku/dokku-{service}/tree/master)',
|
||||
f'[](https://webchat.freenode.net/?channels=dokku)',
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def description(service, version):
|
||||
return f"Official {service} plugin for dokku. Currently defaults to installing [{service} {version}](https://hub.docker.com/_/{service}/)."
|
||||
def description(service, full_image, version):
|
||||
base = "_"
|
||||
image = full_image
|
||||
if "/" in full_image:
|
||||
base = "r/" + full_image.split("/")[0]
|
||||
image = full_image.split("/")[1]
|
||||
|
||||
return f"Official {service} plugin for dokku. Currently defaults to installing [{full_image} {version}](https://hub.docker.com/{base}/{image}/)."
|
||||
|
||||
|
||||
def sponsors_section(service, sponsors):
|
||||
if len(sponsors) == 0:
|
||||
return ""
|
||||
|
||||
sponsor_data = ["## Sponsors", "", f"The {service} plugin was generously sponsored by the following:", ""]
|
||||
sponsor_data.extend([f"- [{s}](https://github.com/{s})" for s in sponsors])
|
||||
|
||||
return "\n".join(
|
||||
sponsor_data
|
||||
)
|
||||
|
||||
|
||||
def requirements_section(dokku_version):
|
||||
return "\n".join([
|
||||
"## Requirements",
|
||||
"",
|
||||
f"- dokku {dokku_version}",
|
||||
"- docker 1.8.x",
|
||||
])
|
||||
return "\n".join(
|
||||
["## Requirements", "", f"- dokku {dokku_version}", "- docker 1.8.x",]
|
||||
)
|
||||
|
||||
|
||||
def installation_section(service, dokku_version):
|
||||
return "\n".join([
|
||||
return "\n".join(
|
||||
[
|
||||
"## Installation",
|
||||
"",
|
||||
"```shell",
|
||||
f"# on {dokku_version}",
|
||||
f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}",
|
||||
"```",
|
||||
])
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def commands_section(service, alias, scheme, ports, unimplemented):
|
||||
def commands_section(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
content = [
|
||||
"## Commands",
|
||||
"",
|
||||
@@ -63,7 +97,7 @@ def commands_section(service, alias, scheme, ports, unimplemented):
|
||||
for filename in subcommands:
|
||||
if filename in unimplemented:
|
||||
continue
|
||||
data = command_data(filename, service, alias, scheme, ports)
|
||||
data = command_data(filename, service, variable, alias, image, scheme, ports)
|
||||
description = data["description"]
|
||||
arguments = data["arguments_string"]
|
||||
|
||||
@@ -81,28 +115,42 @@ def commands_section(service, alias, scheme, ports, unimplemented):
|
||||
return "\n".join(content)
|
||||
|
||||
|
||||
def usage_section(service, alias, scheme, ports, unimplemented):
|
||||
return "\n\n".join([
|
||||
def usage_section(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
return "\n\n".join(
|
||||
[
|
||||
"## Usage",
|
||||
f"Help for any commands can be displayed by specifying the command as an argument to {service}:help. Please consult the `{service}:help` command for any undocumented commands.",
|
||||
usage_intro(service, alias, scheme, ports, unimplemented),
|
||||
usage_lifecycle(service, alias, scheme, ports, unimplemented),
|
||||
usage_automation(service, alias, scheme, ports, unimplemented),
|
||||
usage_data_management(service, alias, scheme, ports, unimplemented),
|
||||
usage_backup(service, alias, scheme, ports, unimplemented),
|
||||
usage_docker_pull(service, alias, scheme, ports, unimplemented),
|
||||
])
|
||||
usage_intro(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_automation(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_data_management(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_backup(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def usage_intro(service, alias, scheme, ports, unimplemented):
|
||||
def usage_intro(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
commands = ["create", "info", "list", "logs", "link", "unlink"]
|
||||
content = ["### Basic Usage"]
|
||||
|
||||
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
|
||||
return fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
)
|
||||
|
||||
|
||||
def usage_lifecycle(service, alias, scheme, ports, unimplemented):
|
||||
commands = ["connect", "enter", "expose", "unexpose", "promote", "start", "stop", "restart", "upgrade"]
|
||||
def usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
commands = [
|
||||
"connect",
|
||||
"enter",
|
||||
"expose",
|
||||
"unexpose",
|
||||
"promote",
|
||||
"start",
|
||||
"stop",
|
||||
"restart",
|
||||
"upgrade",
|
||||
]
|
||||
content = [
|
||||
"### Service Lifecycle",
|
||||
"",
|
||||
@@ -110,10 +158,12 @@ def usage_lifecycle(service, alias, scheme, ports, unimplemented):
|
||||
"",
|
||||
]
|
||||
|
||||
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
|
||||
return fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
)
|
||||
|
||||
|
||||
def usage_automation(service, alias, scheme, ports, unimplemented):
|
||||
def usage_automation(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
commands = ["app-links", "clone", "exists", "linked", "links"]
|
||||
content = [
|
||||
"### Service Automation",
|
||||
@@ -122,10 +172,12 @@ def usage_automation(service, alias, scheme, ports, unimplemented):
|
||||
"",
|
||||
]
|
||||
|
||||
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
|
||||
return fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
)
|
||||
|
||||
|
||||
def usage_data_management(service, alias, scheme, ports, unimplemented):
|
||||
def usage_data_management(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
commands = ["import", "export"]
|
||||
content = [
|
||||
"### Data Management",
|
||||
@@ -134,11 +186,22 @@ def usage_data_management(service, alias, scheme, ports, unimplemented):
|
||||
"",
|
||||
]
|
||||
|
||||
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
|
||||
return fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
)
|
||||
|
||||
|
||||
def usage_backup(service, alias, scheme, ports, unimplemented):
|
||||
commands = ["backup-auth", "backup-deauth", "backup", "backup-set-encryption", "backup-unset-encryption", "backup-schedule", "backup-schedule-cat", "backup-unschedule",]
|
||||
def usage_backup(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
commands = [
|
||||
"backup-auth",
|
||||
"backup-deauth",
|
||||
"backup",
|
||||
"backup-set-encryption",
|
||||
"backup-unset-encryption",
|
||||
"backup-schedule",
|
||||
"backup-schedule-cat",
|
||||
"backup-unschedule",
|
||||
]
|
||||
content = [
|
||||
"### Backups",
|
||||
"",
|
||||
@@ -150,24 +213,30 @@ def usage_backup(service, alias, scheme, ports, unimplemented):
|
||||
"",
|
||||
]
|
||||
|
||||
return fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content)
|
||||
return fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
)
|
||||
|
||||
|
||||
def usage_docker_pull(service, alias, scheme, ports, unimplemented):
|
||||
def usage_docker_pull(service, variable, alias, image, scheme, ports, unimplemented):
|
||||
service_prefix = service.upper()
|
||||
return "\n".join([
|
||||
return "\n".join(
|
||||
[
|
||||
"### Disabling `docker pull` calls",
|
||||
"",
|
||||
f"If you wish to disable the `docker pull` calls that the plugin triggers, you may set the `{service_prefix}_DISABLE_PULL` environment variable to `true`. Once disabled, you will need to pull the service image you wish to deploy as shown in the `stderr` output.",
|
||||
"",
|
||||
"Please ensure the proper images are in place when `docker pull` is disabled.",
|
||||
])
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def fetch_commands_content(service, alias, scheme, ports, unimplemented, commands, content):
|
||||
def fetch_commands_content(
|
||||
service, variable, alias, image, scheme, ports, unimplemented, commands, content
|
||||
):
|
||||
i = 0
|
||||
for command in commands:
|
||||
output = command_help(command, service, alias, scheme, ports, unimplemented)
|
||||
output = command_help(command, service, variable, alias, image, scheme, ports, unimplemented)
|
||||
if output == "":
|
||||
continue
|
||||
content.append(output)
|
||||
@@ -205,11 +274,11 @@ def parse_args(line):
|
||||
return " ".join(arguments)
|
||||
|
||||
|
||||
def command_help(command, service, alias, scheme, ports, unimplemented):
|
||||
def command_help(command, service, variable, alias, image, scheme, ports, unimplemented):
|
||||
if command in unimplemented:
|
||||
return ""
|
||||
|
||||
data = command_data(command, service, alias, scheme, ports)
|
||||
data = command_data(command, service, variable, alias, image, scheme, ports)
|
||||
content = [
|
||||
f"### {data['description']}",
|
||||
"",
|
||||
@@ -226,12 +295,12 @@ def command_help(command, service, alias, scheme, ports, unimplemented):
|
||||
# for argument in data["arguments"]:
|
||||
# content.append(f"- {argument}")
|
||||
|
||||
# if len(data["flags"]) > 0:
|
||||
# content.append("")
|
||||
# content.append("flags:")
|
||||
# content.append("")
|
||||
# for flag in data["flags"]:
|
||||
# content.append(f"- {flag}")
|
||||
if len(data["flags"]) > 0:
|
||||
content.append("")
|
||||
content.append("flags:")
|
||||
content.append("")
|
||||
for flag in data["flags"]:
|
||||
content.append(f"- {flag}")
|
||||
|
||||
if len(data["examples"]) > 0:
|
||||
content.append("")
|
||||
@@ -240,7 +309,7 @@ def command_help(command, service, alias, scheme, ports, unimplemented):
|
||||
return "\n" + "\n".join(content)
|
||||
|
||||
|
||||
def command_data(command, service, alias, scheme, ports):
|
||||
def command_data(command, service, variable, alias, image, scheme, ports):
|
||||
description = None
|
||||
arguments = []
|
||||
arguments_string = ""
|
||||
@@ -252,9 +321,12 @@ def command_data(command, service, alias, scheme, ports):
|
||||
line = line.replace("$PLUGIN_SERVICE", service)
|
||||
line = line.replace("$PLUGIN_COMMAND_PREFIX", service)
|
||||
line = line.replace("${PLUGIN_COMMAND_PREFIX}", service)
|
||||
line = line.replace("${PLUGIN_VARIABLE}", variable)
|
||||
line = line.replace("${PLUGIN_DEFAULT_ALIAS}", alias)
|
||||
line = line.replace("${PLUGIN_IMAGE}", image)
|
||||
line = line.replace("${PLUGIN_SCHEME}", scheme)
|
||||
line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0])
|
||||
line = line.replace("${PLUGIN_DATASTORE_PORTS[@]}", " ".join(ports))
|
||||
|
||||
if "declare desc" in line:
|
||||
description = re.search('"(.+)"', line).group(1)
|
||||
@@ -350,10 +422,35 @@ def command_data(command, service, alias, scheme, ports):
|
||||
|
||||
def process_sentence(sentence_lines):
|
||||
sentence_lines = " ".join(sentence_lines)
|
||||
sentences = ". ".join(i.strip().capitalize() for i in sentence_lines.split(".")).strip()
|
||||
sentences = ". ".join(
|
||||
upperfirst(i.strip()) for i in sentence_lines.split(".")
|
||||
).strip()
|
||||
if not sentences.endswith(".") and not sentences.endswith(":"):
|
||||
sentences += ":"
|
||||
return sentences
|
||||
|
||||
text = []
|
||||
for sentence in sentences.split("."):
|
||||
parts = []
|
||||
for word in sentence.strip().split(" "):
|
||||
if word.isupper() and len(word) > 1:
|
||||
for ending in [':', '.']:
|
||||
if word.endswith(ending):
|
||||
word = '`{0}`{1}'.format(word[:-1], ending)
|
||||
else:
|
||||
word = '`{0}`'.format(word)
|
||||
parts.append(word)
|
||||
text.append(" ".join(parts))
|
||||
|
||||
text = ". ".join(text)
|
||||
|
||||
# some cleanup
|
||||
text = text.replace("(0. 0. 0. 0)", "(`0.0.0.0`)")
|
||||
|
||||
return text
|
||||
|
||||
|
||||
def upperfirst(x):
|
||||
return x[:1].upper() + x[1:]
|
||||
|
||||
|
||||
def process_blockquote(blockquote_lines):
|
||||
@@ -373,30 +470,47 @@ def process_codeblock(codeblock_lines):
|
||||
def main():
|
||||
service = None
|
||||
version = None
|
||||
variable = None
|
||||
image = None
|
||||
alias = None
|
||||
unimplemented = []
|
||||
|
||||
with open("Dockerfile") as f:
|
||||
for line in f.readlines():
|
||||
if "FROM " in line:
|
||||
image, version = line.split(" ")[1].split(":")
|
||||
image = image.strip()
|
||||
version = version.strip()
|
||||
|
||||
with open("config") as f:
|
||||
for line in f.readlines():
|
||||
if "IMAGE_VERSION=${" in line:
|
||||
version = re.search('"(.+)"', line).group(1)
|
||||
if "PLUGIN_COMMAND_PREFIX=" in line:
|
||||
service = re.search('"(.+)"', line).group(1)
|
||||
if "PLUGIN_DEFAULT_ALIAS=" in line:
|
||||
alias = re.search('"(.+)"', line).group(1)
|
||||
if "PLUGIN_VARIABLE=" in line:
|
||||
variable = re.search('"(.+)"', line).group(1)
|
||||
if "PLUGIN_SCHEME=" in line:
|
||||
scheme = re.search('"(.+)"', line).group(1)
|
||||
if "PLUGIN_DATASTORE_PORTS=" in line:
|
||||
ports = re.search('\((.+)\)', line).group(1).split(" ")
|
||||
ports = re.search("\((.+)\)", line).group(1).split(" ")
|
||||
if "PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=" in line:
|
||||
match = re.search('\((.+)\)', line)
|
||||
match = re.search("\((.+)\)", line)
|
||||
if match is not None:
|
||||
unimplemented = [s.strip('"') for s in match.group(1).split(" ")]
|
||||
|
||||
text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+")
|
||||
sponsors = []
|
||||
with open("plugin.toml") as f:
|
||||
for line in f.readlines():
|
||||
if line.startswith("sponsors"):
|
||||
sponsors = re.search("\[([\"\w\s,_-]+)\]", line).group(1)
|
||||
sponsors = [s.strip("\"") for s in sponsors.split(",")]
|
||||
|
||||
text = compile(service, version, variable, alias, image, scheme, ports, sponsors, unimplemented, "0.12.x+")
|
||||
|
||||
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||
readme_file = os.path.join(base_path, 'README.md')
|
||||
with open(readme_file, 'w') as f:
|
||||
readme_file = os.path.join(base_path, "README.md")
|
||||
with open(readme_file, "w") as f:
|
||||
f.write(text)
|
||||
|
||||
|
||||
|
||||
@@ -188,18 +188,18 @@ service_backup() {
|
||||
dokku_log_fail "Provide AWS credentials or use the --use-iam flag"
|
||||
fi
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||
BACKUP_TMPDIR=$(mktemp -d --tmpdir)
|
||||
trap 'rm -rf "$BACKUP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||
|
||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
||||
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running"
|
||||
|
||||
(service_export "$SERVICE" >"${TMPDIR}/export")
|
||||
(service_export "$SERVICE" >"${BACKUP_TMPDIR}/export")
|
||||
|
||||
# Build parameter list for s3backup tool
|
||||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BUCKET_NAME=$BUCKET_NAME"
|
||||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BACKUP_NAME=${PLUGIN_COMMAND_PREFIX}-${SERVICE}"
|
||||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -v ${TMPDIR}:/backup"
|
||||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -v ${BACKUP_TMPDIR}:/backup"
|
||||
|
||||
if [[ -f "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" ]]; then
|
||||
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e AWS_DEFAULT_REGION=$(cat "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION")"
|
||||
@@ -383,7 +383,7 @@ service_info() {
|
||||
local flag key valid_flags
|
||||
|
||||
local flag_map=(
|
||||
"--config-dir: ${SERVICE_ROOT}/config"
|
||||
"--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
|
||||
"--data-dir: ${SERVICE_ROOT}/data"
|
||||
"--dsn: ${SERVICE_URL}"
|
||||
"--exposed-ports: $(service_exposed_ports "$SERVICE")"
|
||||
@@ -453,6 +453,7 @@ service_link() {
|
||||
fi
|
||||
|
||||
[[ -n $LINK ]] && dokku_log_fail "Already linked as $LINK"
|
||||
plugn trigger service-action pre-link "$SERVICE" "$APP"
|
||||
touch "$LINKS_FILE"
|
||||
echo "$APP" >>"$LINKS_FILE"
|
||||
sort "$LINKS_FILE" -u -o "$LINKS_FILE"
|
||||
@@ -465,7 +466,9 @@ service_link() {
|
||||
dokku docker-options:add "$APP" build,deploy,run "--link $SERVICE_NAME:$SERVICE_DNS_HOSTNAME"
|
||||
fi
|
||||
[[ -n "$SERVICE_QUERYSTRING" ]] && SERVICE_URL="${SERVICE_URL}?${SERVICE_QUERYSTRING}"
|
||||
plugn trigger service-action post-link "$SERVICE" "$APP"
|
||||
config_set "$APP" "${ALIAS}_URL=$SERVICE_URL"
|
||||
plugn trigger service-action post-link-complete "$SERVICE" "$APP"
|
||||
}
|
||||
|
||||
service_linked_apps() {
|
||||
@@ -771,6 +774,7 @@ service_unlink() {
|
||||
local SERVICE_DNS_HOSTNAME=$(service_dns_hostname "$SERVICE")
|
||||
local LINK=($(echo "$EXISTING_CONFIG" | grep "$SERVICE_URL" | cut -d: -f1)) || true
|
||||
|
||||
plugn trigger service-action pre-unlink "$SERVICE" "$APP"
|
||||
remove_from_links_file "$SERVICE" "$APP"
|
||||
|
||||
if declare -f -F add_passed_docker_option >/dev/null; then
|
||||
@@ -782,7 +786,9 @@ service_unlink() {
|
||||
fi
|
||||
|
||||
[[ -z ${LINK[*]} ]] && dokku_log_fail "Not linked to app $APP"
|
||||
plugn trigger service-action post-unlink "$SERVICE" "$APP"
|
||||
config_unset "$APP" "${LINK[*]}"
|
||||
plugn trigger service-action post-unlink-complete "$SERVICE" "$APP"
|
||||
}
|
||||
|
||||
service_version() {
|
||||
|
||||
6
config
6
config
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
export POSTGRES_IMAGE=${POSTGRES_IMAGE:="postgres"}
|
||||
export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="11.6"}
|
||||
_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
export POSTGRES_IMAGE=${POSTGRES_IMAGE:="$(awk -F '[ :]' '{print $2}' "${_DIR}/Dockerfile")"}
|
||||
export POSTGRES_IMAGE_VERSION=${POSTGRES_IMAGE_VERSION:="$(awk -F '[ :]' '{print $3}' "${_DIR}/Dockerfile")"}
|
||||
export POSTGRES_ROOT=${POSTGRES_ROOT:="$DOKKU_LIB_ROOT/services/postgres"}
|
||||
export POSTGRES_HOST_ROOT=${POSTGRES_HOST_ROOT:=$POSTGRES_ROOT}
|
||||
|
||||
@@ -21,6 +22,7 @@ export PLUGIN_SCHEME="postgres"
|
||||
export PLUGIN_SERVICE="Postgres"
|
||||
export PLUGIN_VARIABLE="POSTGRES"
|
||||
export PLUGIN_BASE_PATH="$PLUGIN_PATH"
|
||||
export PLUGIN_CONFIG_SUFFIX="data"
|
||||
if [[ -n $DOKKU_API_VERSION ]]; then
|
||||
export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH"
|
||||
fi
|
||||
|
||||
@@ -40,6 +40,7 @@ service_create() {
|
||||
docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
|
||||
fi
|
||||
|
||||
plugn trigger service-action pre-create "$SERVICE"
|
||||
mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory"
|
||||
mkdir -p "$SERVICE_ROOT/data" || dokku_log_fail "Unable to create service data directory"
|
||||
touch "$LINKS_FILE"
|
||||
@@ -60,7 +61,9 @@ service_create() {
|
||||
fi
|
||||
|
||||
write_database_name "$SERVICE"
|
||||
plugn trigger service-action post-create "$SERVICE"
|
||||
service_create_container "$SERVICE"
|
||||
plugn trigger service-action post-create-complete "$SERVICE"
|
||||
}
|
||||
|
||||
service_create_container() {
|
||||
|
||||
@@ -76,10 +76,10 @@ fn-help-contents() {
|
||||
|
||||
fn-help-contents-subcommand() {
|
||||
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
|
||||
local TMPDIR=$(mktemp -d)
|
||||
local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean"
|
||||
local HELP_TMPDIR=$(mktemp -d --tmpdir)
|
||||
local UNCLEAN_FILE="${HELP_TMPDIR}/cmd-unclean" CLEAN_FILE="${HELP_TMPDIR}/cmd-clean"
|
||||
local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL
|
||||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||
trap 'rm -rf "$HELP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||
|
||||
rm -rf "$UNCLEAN_FILE" "$CLEAN_FILE"
|
||||
cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" >"$UNCLEAN_FILE"
|
||||
@@ -164,8 +164,8 @@ fn-help-list-example() {
|
||||
# shellcheck disable=SC2034
|
||||
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
|
||||
cat <<help_list
|
||||
NAME, VERSION, STATUS, EXPOSED PORTS, LINKS
|
||||
service-name, $PLUGIN_COMMAND_PREFIX:$PLUGIN_IMAGE_VERSION, running, -, app-name
|
||||
$PLUGIN_SERVICE services
|
||||
service-name
|
||||
help_list
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[plugin]
|
||||
description = "dokku postgres service plugin"
|
||||
version = "1.11.2"
|
||||
version = "1.12.0"
|
||||
[plugin.config]
|
||||
|
||||
@@ -6,7 +6,7 @@ source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-set-encryption-cmd() {
|
||||
#E set a GPG passphrase for backups
|
||||
#E set the GPG-compatible passphrase for encrypting backups for backups
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lolipop
|
||||
#A service, service to run command against
|
||||
#A passphrase, a GPG-compatible passphrase
|
||||
|
||||
@@ -6,7 +6,7 @@ source "$PLUGIN_BASE_PATH/common/functions"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||
|
||||
service-backup-unset-encryption-cmd() {
|
||||
#E unset a GPG encryption key for backups
|
||||
#E unset the GPG encryption passphrase for backups
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:backup-unset-encryption lolipop
|
||||
#A service, service to run command against
|
||||
declare desc="unsets encryption for future backups of the $PLUGIN_SERVICE service"
|
||||
|
||||
@@ -41,13 +41,15 @@ service-destroy-cmd() {
|
||||
fi
|
||||
|
||||
dokku_log_info2_quiet "Deleting $SERVICE"
|
||||
plugn trigger service-action pre-delete "$SERVICE"
|
||||
service_backup_unschedule "$SERVICE"
|
||||
service_container_rm "$SERVICE"
|
||||
|
||||
dokku_log_verbose_quiet "Removing data"
|
||||
docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data
|
||||
docker run --rm -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/config" "$PLUGIN_BUSYBOX_IMAGE" chmod 777 -R /config /data
|
||||
rm -rf "$SERVICE_ROOT"
|
||||
|
||||
plugn trigger service-action post-delete "$SERVICE"
|
||||
dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE"
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ service-link-cmd() {
|
||||
#E use the 'expose' subcommand. another service can be linked to your app:
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:link other_service playground
|
||||
#E it is possible to change the protocol for ${PLUGIN_DEFAULT_ALIAS}_URL by setting the
|
||||
#E environment variable ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME on the app. doing so will
|
||||
#E environment variable ${PLUGIN_VARIABLE}_DATABASE_SCHEME on the app. doing so will
|
||||
#E after linking will cause the plugin to think the service is not
|
||||
#E linked, and we advise you to unlink before proceeding.
|
||||
#E dokku config:set playground ${PLUGIN_DEFAULT_ALIAS}_DATABASE_SCHEME=${PLUGIN_SCHEME}2
|
||||
#E dokku config:set playground ${PLUGIN_VARIABLE}_DATABASE_SCHEME=${PLUGIN_SCHEME}2
|
||||
#E dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground
|
||||
#E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as:
|
||||
#E
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
dokku apps:create my_app
|
||||
dokku apps:create my-app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app >&2
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:hook:pre-delete) removes app from links file when destroying app" {
|
||||
[[ -n $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]]
|
||||
dokku --force apps:destroy my_app
|
||||
dokku --force apps:destroy my-app
|
||||
[[ -z $(< "$PLUGIN_DATA_ROOT/l/LINKS") ]]
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ load test_helper
|
||||
setup() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" m
|
||||
dokku apps:create my_app
|
||||
dokku apps:create my-app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" m
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||
dokku --force apps:destroy my_app
|
||||
dokku --force apps:destroy my-app
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) error when the service does not exist" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" not_existing_service my-app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||
@@ -47,73 +47,73 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) error when the service is already linked to app" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_contains "${lines[*]}" "Already linked as DATABASE_URL"
|
||||
assert_failure
|
||||
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) exports DATABASE_URL to app" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
url=$(dokku config:get my_app DATABASE_URL)
|
||||
url=$(dokku config:get my-app DATABASE_URL)
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
assert_contains "$url" "postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) generates an alternate config url when DATABASE_URL already in use" {
|
||||
dokku config:set my_app DATABASE_URL=postgres://user:pass@host:5432/db
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
run dokku config my_app
|
||||
dokku config:set my-app DATABASE_URL=postgres://user:pass@host:5432/db
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
run dokku config my-app
|
||||
assert_contains "${lines[*]}" "DOKKU_POSTGRES_AQUA_URL"
|
||||
assert_success
|
||||
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" m my_app
|
||||
run dokku config my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" m my-app
|
||||
run dokku config my-app
|
||||
assert_contains "${lines[*]}" "DOKKU_POSTGRES_BLACK_URL"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" m my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" m my-app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) links to app with docker-options" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
run dokku docker-options:report my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
run dokku docker-options:report my-app
|
||||
assert_contains "${lines[*]}" "--link dokku.postgres.l:dokku-postgres-l"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) uses apps POSTGRES_DATABASE_SCHEME variable" {
|
||||
dokku config:set my_app POSTGRES_DATABASE_SCHEME=postgres2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
url=$(dokku config:get my_app DATABASE_URL)
|
||||
dokku config:set my-app POSTGRES_DATABASE_SCHEME=postgres2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
url=$(dokku config:get my-app DATABASE_URL)
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
assert_contains "$url" "postgres2://postgres:$password@dokku-postgres-l:5432/l"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) adds a querystring" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --querystring "pool=5"
|
||||
url=$(dokku config:get my_app DATABASE_URL)
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --querystring "pool=5"
|
||||
url=$(dokku config:get my-app DATABASE_URL)
|
||||
assert_contains "$url" "?pool=5"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:link) uses a specified config url when alias is specified" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS"
|
||||
url=$(dokku config:get my_app ALIAS_URL)
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app --alias "ALIAS"
|
||||
url=$(dokku config:get my-app ALIAS_URL)
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
assert_contains "$url" "postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
assert_success
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
dokku apps:create my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
|
||||
dokku apps:create my-app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||
dokku --force apps:destroy my_app
|
||||
dokku --force apps:destroy my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) error when there are no arguments" {
|
||||
@@ -29,34 +29,34 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) error when the service does not exist" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:promote" not_existing_service my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:promote" not_existing_service my-app
|
||||
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) error when the service is already promoted" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app
|
||||
assert_contains "${lines[*]}" "already promoted as DATABASE_URL"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) changes DATABASE_URL" {
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
dokku config:set my_app "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
|
||||
url=$(dokku config:get my_app DATABASE_URL)
|
||||
dokku config:set my-app "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app
|
||||
url=$(dokku config:get my-app DATABASE_URL)
|
||||
assert_equal "$url" "postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" {
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
dokku config:set my_app "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
|
||||
run dokku config my_app
|
||||
dokku config:set my-app "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app
|
||||
run dokku config my-app
|
||||
assert_contains "${lines[*]}" "DOKKU_POSTGRES_"
|
||||
}
|
||||
@test "($PLUGIN_COMMAND_PREFIX:promote) uses POSTGRES_DATABASE_SCHEME variable" {
|
||||
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
|
||||
dokku config:set my_app "POSTGRES_DATABASE_SCHEME=postgres2" "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres2://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
|
||||
url=$(dokku config:get my_app DATABASE_URL)
|
||||
dokku config:set my-app "POSTGRES_DATABASE_SCHEME=postgres2" "DATABASE_URL=postgres://u:p@host:5432/db" "DOKKU_POSTGRES_BLUE_URL=postgres2://postgres:$password@dokku-postgres-l:5432/l"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my-app
|
||||
url=$(dokku config:get my-app DATABASE_URL)
|
||||
assert_contains "$url" "postgres2://postgres:$password@dokku-postgres-l:5432/l"
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
load test_helper
|
||||
|
||||
setup() {
|
||||
dokku apps:create my_app
|
||||
dokku apps:create my-app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" l
|
||||
}
|
||||
|
||||
teardown() {
|
||||
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" l
|
||||
dokku --force apps:destroy my_app
|
||||
dokku --force apps:destroy my-app
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when there are no arguments" {
|
||||
@@ -27,27 +27,27 @@ teardown() {
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when the service does not exist" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" not_existing_service my_app
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" not_existing_service my-app
|
||||
assert_contains "${lines[*]}" "service not_existing_service does not exist"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:unlink) error when service not linked to app" {
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
assert_contains "${lines[*]}" "Not linked to app my_app"
|
||||
run dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
assert_contains "${lines[*]}" "Not linked to app my-app"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:unlink) removes link from docker-options" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
|
||||
check_value="Docker options build: Docker options deploy: --restart=on-failure:10 Docker options run:"
|
||||
options=$(dokku --quiet docker-options:report my_app | xargs)
|
||||
options=$(dokku --quiet docker-options:report my-app | xargs)
|
||||
assert_equal "$options" "$check_value"
|
||||
}
|
||||
|
||||
@test "($PLUGIN_COMMAND_PREFIX:unlink) unsets config url from app" {
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
|
||||
config=$(dokku config:get my_app DATABASE_URL || true)
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:link" l my-app >&2
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my-app
|
||||
config=$(dokku config:get my-app DATABASE_URL || true)
|
||||
assert_equal "$config" ""
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ echo "Dokku version $DOKKU_VERSION"
|
||||
|
||||
export DOKKU_LIB_ROOT="/var/lib/dokku"
|
||||
export DOKKU_PLUGINS_ROOT="$DOKKU_LIB_ROOT/plugins/available"
|
||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config"
|
||||
pushd "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" >/dev/null
|
||||
source "config"
|
||||
popd >/dev/null
|
||||
sudo rm -rf "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX"
|
||||
sudo mkdir -p "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/subcommands" "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX/scripts"
|
||||
sudo find ./ -maxdepth 1 -type f -exec cp '{}' "$DOKKU_PLUGINS_ROOT/$PLUGIN_COMMAND_PREFIX" \;
|
||||
|
||||
Reference in New Issue
Block a user