Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba24332367 | ||
|
|
5fd0ca4be7 | ||
|
|
d7ed80f5f2 | ||
|
|
e5f7c9edf2 | ||
|
|
0dd6e10b6c | ||
|
|
60a95a7c4c | ||
|
|
2cc04faf19 | ||
|
|
b335d9c73a |
93
README.md
93
README.md
@@ -63,21 +63,29 @@ Help for any commands can be displayed by specifying the command as an argument
|
|||||||
dokku postgres:create <service> [--create-flags...]
|
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:
|
Create a postgres service named lolipop:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:create lolipop
|
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
|
```shell
|
||||||
export DATABASE_IMAGE="${PLUGIN_IMAGE}"
|
export DATABASE_IMAGE="postgres"
|
||||||
export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}"
|
export DATABASE_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}"
|
||||||
dokku postgres:create lolipop
|
dokku postgres:create lolipop
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also specify custom environment variables to start the postgres service in semi-colon separated form.
|
You can also specify custom environment variables to start the postgres service in semi-colon separated form.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta"
|
export DATABASE_CUSTOM_ENV="USER=alpha;HOST=beta"
|
||||||
@@ -91,6 +99,19 @@ dokku postgres:create lolipop
|
|||||||
dokku postgres:info <service> [--single-info-flag]
|
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:
|
Get connection information as follows:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -132,6 +153,10 @@ dokku postgres:list
|
|||||||
dokku postgres:logs <service> [-t|--tail]
|
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:
|
You can tail logs for a particular service:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -151,7 +176,12 @@ dokku postgres:logs lolipop --tail
|
|||||||
dokku postgres:link <service> <app> [--link-flags...]
|
dokku postgres:link <service> <app> [--link-flags...]
|
||||||
```
|
```
|
||||||
|
|
||||||
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.
|
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
|
> 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
|
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
|
```shell
|
||||||
dokku config:set playground DATABASE_DATABASE_SCHEME=postgres2
|
dokku config:set playground POSTGRES_DATABASE_SCHEME=postgres2
|
||||||
dokku postgres:link lolipop playground
|
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
|
postgres2://lolipop:SOME_PASSWORD@dokku-postgres-lolipop:5432/lolipop
|
||||||
@@ -234,13 +264,13 @@ dokku postgres:connect lolipop
|
|||||||
dokku postgres:enter <service>
|
dokku postgres:enter <service>
|
||||||
```
|
```
|
||||||
|
|
||||||
A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk.
|
A bash prompt can be opened against a running service. Filesystem changes will not be saved to disk.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:enter lolipop
|
dokku postgres:enter lolipop
|
||||||
```
|
```
|
||||||
|
|
||||||
You may also run a command directly against the service. Filesystem changes will not be saved to disk.
|
You may also run a command directly against the service. Filesystem changes will not be saved to disk.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:enter lolipop touch /tmp/test
|
dokku postgres:enter lolipop touch /tmp/test
|
||||||
@@ -253,10 +283,10 @@ dokku postgres:enter lolipop touch /tmp/test
|
|||||||
dokku postgres:expose <service> <ports...>
|
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
|
```shell
|
||||||
dokku postgres:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
|
dokku postgres:expose lolipop 5432
|
||||||
```
|
```
|
||||||
|
|
||||||
### unexpose a previously exposed postgres service
|
### unexpose a previously exposed postgres service
|
||||||
@@ -266,7 +296,7 @@ dokku postgres:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
|
|||||||
dokku postgres:unexpose <service>
|
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
|
```shell
|
||||||
dokku postgres:unexpose lolipop
|
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
|
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
|
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...]
|
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:
|
You can upgrade an existing service to a new image or image-version:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -364,7 +401,7 @@ Service scripting can be executed using the following commands:
|
|||||||
dokku postgres:app-links <app>
|
dokku postgres:app-links <app>
|
||||||
```
|
```
|
||||||
|
|
||||||
List all postgres services that are linked to the 'playground' app.
|
List all postgres services that are linked to the 'playground' app.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:app-links playground
|
dokku postgres:app-links playground
|
||||||
@@ -377,6 +414,14 @@ dokku postgres:app-links playground
|
|||||||
dokku postgres:clone <service> <new-service> [--clone-flags...]
|
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:
|
You can clone an existing service to a new one:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -390,7 +435,7 @@ dokku postgres:clone lolipop lolipop-2
|
|||||||
dokku postgres:exists <service>
|
dokku postgres:exists <service>
|
||||||
```
|
```
|
||||||
|
|
||||||
Here we check if the lolipop postgres service exists.
|
Here we check if the lolipop postgres service exists.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:exists lolipop
|
dokku postgres:exists lolipop
|
||||||
@@ -403,7 +448,7 @@ dokku postgres:exists lolipop
|
|||||||
dokku postgres:linked <service> <app>
|
dokku postgres:linked <service> <app>
|
||||||
```
|
```
|
||||||
|
|
||||||
Here we check if the lolipop postgres service is linked to the 'playground' app.
|
Here we check if the lolipop postgres service is linked to the 'playground' app.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:linked lolipop playground
|
dokku postgres:linked lolipop playground
|
||||||
@@ -416,7 +461,7 @@ dokku postgres:linked lolipop playground
|
|||||||
dokku postgres:links <service>
|
dokku postgres:links <service>
|
||||||
```
|
```
|
||||||
|
|
||||||
List all apps linked to the 'lolipop' postgres service.
|
List all apps linked to the 'lolipop' postgres service.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:links lolipop
|
dokku postgres:links lolipop
|
||||||
@@ -517,7 +562,11 @@ dokku postgres:backup-deauth lolipop
|
|||||||
dokku postgres:backup <service> <bucket-name> [--use-iam]
|
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
|
```shell
|
||||||
dokku postgres:backup lolipop my-s3-bucket --use-iam
|
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>
|
dokku postgres:backup-set-encryption <service> <passphrase>
|
||||||
```
|
```
|
||||||
|
|
||||||
Set a gpg passphrase for backups:
|
Set the GPG-compatible passphrase for encrypting backups for backups:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:backup-set-encryption lolipop
|
dokku postgres:backup-set-encryption lolipop
|
||||||
@@ -543,7 +592,7 @@ dokku postgres:backup-set-encryption lolipop
|
|||||||
dokku postgres:backup-unset-encryption <service>
|
dokku postgres:backup-unset-encryption <service>
|
||||||
```
|
```
|
||||||
|
|
||||||
Unset a gpg encryption key for backups:
|
Unset the `GPG` encryption passphrase for backups:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
dokku postgres:backup-unset-encryption lolipop
|
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]
|
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 a backup:
|
||||||
|
|
||||||
> 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am
|
> 'schedule' is a crontab expression, eg. "0 3 * * *" for each day at 3am
|
||||||
|
|||||||
235
bin/generate
235
bin/generate
@@ -5,23 +5,32 @@ import os
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def compile(service, version, alias, scheme, ports, unimplemented, dokku_version):
|
def compile(service, version, variable, alias, image, scheme, ports, unimplemented, dokku_version):
|
||||||
return "\n\n".join([
|
return (
|
||||||
header(service),
|
"\n\n".join(
|
||||||
description(service, version),
|
[
|
||||||
requirements_section(dokku_version),
|
header(service),
|
||||||
installation_section(service, dokku_version),
|
description(service, version),
|
||||||
commands_section(service, alias, scheme, ports, unimplemented),
|
requirements_section(dokku_version),
|
||||||
usage_section(service, alias, scheme, ports, unimplemented),
|
installation_section(service, dokku_version),
|
||||||
]).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):
|
def header(service):
|
||||||
return " ".join([
|
return " ".join(
|
||||||
f"# dokku {service}",
|
[
|
||||||
f"[](https://circleci.com/gh/dokku/dokku-{service}/tree/master)",
|
f"# 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):
|
def description(service, version):
|
||||||
@@ -29,26 +38,25 @@ def description(service, version):
|
|||||||
|
|
||||||
|
|
||||||
def requirements_section(dokku_version):
|
def requirements_section(dokku_version):
|
||||||
return "\n".join([
|
return "\n".join(
|
||||||
"## Requirements",
|
["## Requirements", "", f"- dokku {dokku_version}", "- docker 1.8.x",]
|
||||||
"",
|
)
|
||||||
f"- dokku {dokku_version}",
|
|
||||||
"- docker 1.8.x",
|
|
||||||
])
|
|
||||||
|
|
||||||
|
|
||||||
def installation_section(service, dokku_version):
|
def installation_section(service, dokku_version):
|
||||||
return "\n".join([
|
return "\n".join(
|
||||||
"## Installation",
|
[
|
||||||
"",
|
"## Installation",
|
||||||
"```shell",
|
"",
|
||||||
f"# on {dokku_version}",
|
"```shell",
|
||||||
f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}",
|
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 = [
|
content = [
|
||||||
"## Commands",
|
"## Commands",
|
||||||
"",
|
"",
|
||||||
@@ -63,7 +71,7 @@ def commands_section(service, alias, scheme, ports, unimplemented):
|
|||||||
for filename in subcommands:
|
for filename in subcommands:
|
||||||
if filename in unimplemented:
|
if filename in unimplemented:
|
||||||
continue
|
continue
|
||||||
data = command_data(filename, service, alias, scheme, ports)
|
data = command_data(filename, service, variable, alias, image, scheme, ports)
|
||||||
description = data["description"]
|
description = data["description"]
|
||||||
arguments = data["arguments_string"]
|
arguments = data["arguments_string"]
|
||||||
|
|
||||||
@@ -81,28 +89,42 @@ def commands_section(service, alias, scheme, ports, unimplemented):
|
|||||||
return "\n".join(content)
|
return "\n".join(content)
|
||||||
|
|
||||||
|
|
||||||
def usage_section(service, alias, scheme, ports, unimplemented):
|
def usage_section(service, variable, alias, image, scheme, ports, unimplemented):
|
||||||
return "\n\n".join([
|
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",
|
||||||
usage_intro(service, alias, scheme, ports, unimplemented),
|
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_lifecycle(service, alias, scheme, ports, unimplemented),
|
usage_intro(service, variable, alias, image, scheme, ports, unimplemented),
|
||||||
usage_automation(service, alias, scheme, ports, unimplemented),
|
usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented),
|
||||||
usage_data_management(service, alias, scheme, ports, unimplemented),
|
usage_automation(service, variable, alias, image, scheme, ports, unimplemented),
|
||||||
usage_backup(service, alias, scheme, ports, unimplemented),
|
usage_data_management(service, variable, alias, image, scheme, ports, unimplemented),
|
||||||
usage_docker_pull(service, alias, 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"]
|
commands = ["create", "info", "list", "logs", "link", "unlink"]
|
||||||
content = ["### Basic Usage"]
|
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):
|
def usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented):
|
||||||
commands = ["connect", "enter", "expose", "unexpose", "promote", "start", "stop", "restart", "upgrade"]
|
commands = [
|
||||||
|
"connect",
|
||||||
|
"enter",
|
||||||
|
"expose",
|
||||||
|
"unexpose",
|
||||||
|
"promote",
|
||||||
|
"start",
|
||||||
|
"stop",
|
||||||
|
"restart",
|
||||||
|
"upgrade",
|
||||||
|
]
|
||||||
content = [
|
content = [
|
||||||
"### Service Lifecycle",
|
"### Service Lifecycle",
|
||||||
"",
|
"",
|
||||||
@@ -110,10 +132,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"]
|
commands = ["app-links", "clone", "exists", "linked", "links"]
|
||||||
content = [
|
content = [
|
||||||
"### Service Automation",
|
"### Service Automation",
|
||||||
@@ -122,10 +146,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"]
|
commands = ["import", "export"]
|
||||||
content = [
|
content = [
|
||||||
"### Data Management",
|
"### Data Management",
|
||||||
@@ -134,11 +160,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):
|
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",]
|
commands = [
|
||||||
|
"backup-auth",
|
||||||
|
"backup-deauth",
|
||||||
|
"backup",
|
||||||
|
"backup-set-encryption",
|
||||||
|
"backup-unset-encryption",
|
||||||
|
"backup-schedule",
|
||||||
|
"backup-schedule-cat",
|
||||||
|
"backup-unschedule",
|
||||||
|
]
|
||||||
content = [
|
content = [
|
||||||
"### Backups",
|
"### Backups",
|
||||||
"",
|
"",
|
||||||
@@ -150,24 +187,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()
|
service_prefix = service.upper()
|
||||||
return "\n".join([
|
return "\n".join(
|
||||||
"### Disabling `docker pull` calls",
|
[
|
||||||
"",
|
"### 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.",
|
"",
|
||||||
"",
|
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.",
|
"",
|
||||||
])
|
"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
|
i = 0
|
||||||
for command in commands:
|
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 == "":
|
if output == "":
|
||||||
continue
|
continue
|
||||||
content.append(output)
|
content.append(output)
|
||||||
@@ -205,11 +248,11 @@ def parse_args(line):
|
|||||||
return " ".join(arguments)
|
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:
|
if command in unimplemented:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
data = command_data(command, service, alias, scheme, ports)
|
data = command_data(command, service, variable, alias, image, scheme, ports)
|
||||||
content = [
|
content = [
|
||||||
f"### {data['description']}",
|
f"### {data['description']}",
|
||||||
"",
|
"",
|
||||||
@@ -226,12 +269,12 @@ def command_help(command, service, alias, scheme, ports, unimplemented):
|
|||||||
# for argument in data["arguments"]:
|
# for argument in data["arguments"]:
|
||||||
# content.append(f"- {argument}")
|
# content.append(f"- {argument}")
|
||||||
|
|
||||||
# if len(data["flags"]) > 0:
|
if len(data["flags"]) > 0:
|
||||||
# content.append("")
|
content.append("")
|
||||||
# content.append("flags:")
|
content.append("flags:")
|
||||||
# content.append("")
|
content.append("")
|
||||||
# for flag in data["flags"]:
|
for flag in data["flags"]:
|
||||||
# content.append(f"- {flag}")
|
content.append(f"- {flag}")
|
||||||
|
|
||||||
if len(data["examples"]) > 0:
|
if len(data["examples"]) > 0:
|
||||||
content.append("")
|
content.append("")
|
||||||
@@ -240,7 +283,7 @@ def command_help(command, service, alias, scheme, ports, unimplemented):
|
|||||||
return "\n" + "\n".join(content)
|
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
|
description = None
|
||||||
arguments = []
|
arguments = []
|
||||||
arguments_string = ""
|
arguments_string = ""
|
||||||
@@ -252,9 +295,12 @@ def command_data(command, service, alias, scheme, ports):
|
|||||||
line = line.replace("$PLUGIN_SERVICE", service)
|
line = line.replace("$PLUGIN_SERVICE", service)
|
||||||
line = line.replace("$PLUGIN_COMMAND_PREFIX", service)
|
line = line.replace("$PLUGIN_COMMAND_PREFIX", 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_DEFAULT_ALIAS}", alias)
|
||||||
|
line = line.replace("${PLUGIN_IMAGE}", image)
|
||||||
line = line.replace("${PLUGIN_SCHEME}", scheme)
|
line = line.replace("${PLUGIN_SCHEME}", scheme)
|
||||||
line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0])
|
line = line.replace("${PLUGIN_DATASTORE_PORTS[0]}", ports[0])
|
||||||
|
line = line.replace("${PLUGIN_DATASTORE_PORTS[@]}", " ".join(ports))
|
||||||
|
|
||||||
if "declare desc" in line:
|
if "declare desc" in line:
|
||||||
description = re.search('"(.+)"', line).group(1)
|
description = re.search('"(.+)"', line).group(1)
|
||||||
@@ -350,10 +396,35 @@ def command_data(command, service, alias, scheme, ports):
|
|||||||
|
|
||||||
def process_sentence(sentence_lines):
|
def process_sentence(sentence_lines):
|
||||||
sentence_lines = " ".join(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(":"):
|
if not sentences.endswith(".") and not sentences.endswith(":"):
|
||||||
sentences += ":"
|
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):
|
def process_blockquote(blockquote_lines):
|
||||||
@@ -373,30 +444,36 @@ def process_codeblock(codeblock_lines):
|
|||||||
def main():
|
def main():
|
||||||
service = None
|
service = None
|
||||||
version = None
|
version = None
|
||||||
|
variable = None
|
||||||
|
image = None
|
||||||
alias = None
|
alias = None
|
||||||
unimplemented = []
|
unimplemented = []
|
||||||
with open("config") as f:
|
with open("config") as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
if "IMAGE_VERSION=${" in line:
|
if "IMAGE_VERSION=${" in line:
|
||||||
version = re.search('"(.+)"', line).group(1)
|
version = re.search('"(.+)"', line).group(1)
|
||||||
|
if "_IMAGE=${" in line:
|
||||||
|
image = re.search('"(.+)"', line).group(1)
|
||||||
if "PLUGIN_COMMAND_PREFIX=" in line:
|
if "PLUGIN_COMMAND_PREFIX=" in line:
|
||||||
service = re.search('"(.+)"', line).group(1)
|
service = re.search('"(.+)"', line).group(1)
|
||||||
if "PLUGIN_DEFAULT_ALIAS=" in line:
|
if "PLUGIN_DEFAULT_ALIAS=" in line:
|
||||||
alias = re.search('"(.+)"', line).group(1)
|
alias = re.search('"(.+)"', line).group(1)
|
||||||
|
if "PLUGIN_VARIABLE=" in line:
|
||||||
|
variable = re.search('"(.+)"', line).group(1)
|
||||||
if "PLUGIN_SCHEME=" in line:
|
if "PLUGIN_SCHEME=" in line:
|
||||||
scheme = re.search('"(.+)"', line).group(1)
|
scheme = re.search('"(.+)"', line).group(1)
|
||||||
if "PLUGIN_DATASTORE_PORTS=" in line:
|
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:
|
if "PLUGIN_UNIMPLEMENTED_SUBCOMMANDS=" in line:
|
||||||
match = re.search('\((.+)\)', line)
|
match = re.search("\((.+)\)", line)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
unimplemented = [s.strip('"') for s in match.group(1).split(" ")]
|
unimplemented = [s.strip('"') for s in match.group(1).split(" ")]
|
||||||
|
|
||||||
text = compile(service, version, alias, scheme, ports, unimplemented, "0.12.x+")
|
text = compile(service, version, variable, alias, image, scheme, ports, unimplemented, "0.12.x+")
|
||||||
|
|
||||||
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
base_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
||||||
readme_file = os.path.join(base_path, 'README.md')
|
readme_file = os.path.join(base_path, "README.md")
|
||||||
with open(readme_file, 'w') as f:
|
with open(readme_file, "w") as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ service_backup() {
|
|||||||
dokku_log_fail "Provide AWS credentials or use the --use-iam flag"
|
dokku_log_fail "Provide AWS credentials or use the --use-iam flag"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TMPDIR=$(mktemp -d)
|
TMPDIR=$(mktemp -d --tmpdir)
|
||||||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||||
|
|
||||||
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
docker inspect "$ID" &>/dev/null || dokku_log_fail "Service container does not exist"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ fn-help-contents() {
|
|||||||
|
|
||||||
fn-help-contents-subcommand() {
|
fn-help-contents-subcommand() {
|
||||||
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
|
declare SUBCOMMAND="$1" FULL_OUTPUT="$2"
|
||||||
local TMPDIR=$(mktemp -d)
|
local TMPDIR=$(mktemp -d --tmpdir)
|
||||||
local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean"
|
local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean"
|
||||||
local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL
|
local BOLD CMD_OUTPUT CYAN EXAMPLE LIGHT_GRAY NORMAL
|
||||||
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT
|
||||||
@@ -164,8 +164,8 @@ fn-help-list-example() {
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
|
declare desc="return $PLUGIN_COMMAND_PREFIX plugin help content"
|
||||||
cat <<help_list
|
cat <<help_list
|
||||||
NAME, VERSION, STATUS, EXPOSED PORTS, LINKS
|
$PLUGIN_SERVICE services
|
||||||
service-name, $PLUGIN_COMMAND_PREFIX:$PLUGIN_IMAGE_VERSION, running, -, app-name
|
service-name
|
||||||
help_list
|
help_list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[plugin]
|
[plugin]
|
||||||
description = "dokku postgres service plugin"
|
description = "dokku postgres service plugin"
|
||||||
version = "1.11.3"
|
version = "1.11.5"
|
||||||
[plugin.config]
|
[plugin.config]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ source "$PLUGIN_BASE_PATH/common/functions"
|
|||||||
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
|
||||||
service-backup-set-encryption-cmd() {
|
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
|
#E dokku $PLUGIN_COMMAND_PREFIX:backup-set-encryption lolipop
|
||||||
#A service, service to run command against
|
#A service, service to run command against
|
||||||
#A passphrase, a GPG-compatible passphrase
|
#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"
|
source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions"
|
||||||
|
|
||||||
service-backup-unset-encryption-cmd() {
|
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
|
#E dokku $PLUGIN_COMMAND_PREFIX:backup-unset-encryption lolipop
|
||||||
#A service, service to run command against
|
#A service, service to run command against
|
||||||
declare desc="unsets encryption for future backups of the $PLUGIN_SERVICE service"
|
declare desc="unsets encryption for future backups of the $PLUGIN_SERVICE service"
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ service-link-cmd() {
|
|||||||
#E use the 'expose' subcommand. another service can be linked to your app:
|
#E use the 'expose' subcommand. another service can be linked to your app:
|
||||||
#E dokku $PLUGIN_COMMAND_PREFIX:link other_service playground
|
#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 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 after linking will cause the plugin to think the service is not
|
||||||
#E linked, and we advise you to unlink before proceeding.
|
#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 dokku $PLUGIN_COMMAND_PREFIX:link lolipop playground
|
||||||
#E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as:
|
#E this will cause ${PLUGIN_DEFAULT_ALIAS}_URL to be set as:
|
||||||
#E
|
#E
|
||||||
|
|||||||
Reference in New Issue
Block a user