Compare commits

...

24 Commits

Author SHA1 Message Date
Jose Diaz-Gonzalez
90ab3a1191 Release 1.13.0 2021-02-02 21:50:08 -05:00
Jose Diaz-Gonzalez
23681960bf Merge pull request #157 from gyfis/patch-1
Don't fill $SERVICE as username in REDIS_URL
2021-02-02 21:49:47 -05:00
Jose Diaz-Gonzalez
b8b97f0cb4 Release 1.12.6 2021-01-17 21:16:36 -05:00
Jose Diaz-Gonzalez
70c98338b0 fix: do not shadow TMPDIR variable
This enables usage of the plugin with libpam-tmpdir.

Refs dokku/dokku#3149
2021-01-17 21:02:28 -05:00
Tomas Hromada
872ed9c540 Merge branch 'patch-1' of https://github.com/gyfis/dokku-redis into patch-1 2020-11-22 09:00:53 +01:00
Tomas Hromada
c85770a873 💄 README.md from bin/generate 2020-11-22 09:00:44 +01:00
Tomáš Hromada
facd80f5bc 💄 Remove last empty line from README 2020-11-22 08:13:04 +01:00
Tomas Hromada
bc5985881a purge mentions of the faux-username from the codebase 2020-11-21 21:17:55 +01:00
Tomáš Hromada
4170c0b993 Don't fill $SERVICE as username in service_url()
The URL generated by this plugin is invalid, but since Redis on versions 5 and lower didn't have a notion of usernames, it pretty much went unnoticed. 

Let's fix this by not setting the $SERVICE as the username in the service_url returned by this plugin.

I believe that clients ignore the username (otherwise the Redis connection wouldn't go through), so this should be a non-breaking change.

Fixes #155
2020-11-21 20:53:49 +01:00
Jose Diaz-Gonzalez
ca69e6f79d fix: correct image link 2020-09-27 12:38:54 -04:00
Jose Diaz-Gonzalez
ca6b3b8815 Merge pull request #151 from dokku/configurable-config
fix: allow config directory to be configurable
2020-05-16 12:57:10 -04:00
Jose Diaz-Gonzalez
e43904641b fix: allow config directory to be configurable
For postgres, the config directory doesn't actually exist, so adding this configurability allows the plugin's info command to report correctly.
2020-05-16 02:49:34 -04:00
Jose Diaz-Gonzalez
6d19569e82 Release 1.12.5 2020-05-15 00:59:58 -04:00
Jose Diaz-Gonzalez
01a1668867 fix: respect the TMPDIR environment variable
Refs dokku/dokku-redis#143
2020-05-15 00:57:21 -04:00
Jose Diaz-Gonzalez
f2c531bb5e Release 1.12.4 2020-05-15 00:54:38 -04:00
Jose Diaz-Gonzalez
2fd7152866 docs: correct help output
Refs dokku/dokku-postgres#197
2020-05-15 00:40:25 -04:00
Jose Diaz-Gonzalez
f9d5735c6c docs: correct casing/quoting on sentences 2020-05-15 00:34:38 -04:00
Jose Diaz-Gonzalez
6497135ae8 chore: run black 2020-05-14 23:57:49 -04:00
Jose Diaz-Gonzalez
adc1b724d3 docs: document all flags in readme 2020-05-14 23:37:57 -04:00
Jose Diaz-Gonzalez
b421d681af docs: make the gpg passphrase a bit more clear 2020-05-14 23:33:01 -04:00
Jose Diaz-Gonzalez
1e43387487 Release 1.12.3 2020-05-14 23:00:57 -04:00
Jose Diaz-Gonzalez
7a003dea68 chore: update copyright date 2020-05-14 22:57:39 -04:00
Jose Diaz-Gonzalez
0aefafed16 docs: switch build shield to circleci 2020-04-05 20:41:00 -04:00
Jose Diaz-Gonzalez
2f72b26396 tests: use circleci 2.1 2020-04-05 20:40:20 -04:00
17 changed files with 342 additions and 186 deletions

View File

@@ -1,24 +1,25 @@
version: 2 version: 2.1
jobs:
build-master: commands:
environment: build:
DOKKU_VERSION: master description: "run the build"
machine: parameters:
docker_layer_caching: false python_version:
image: ubuntu-1604:201903-01 type: string
default: "3.7.0"
steps: steps:
- checkout - checkout
- run: pyenv global 3.7.0 - run: pyenv global << parameters.python_version >>
- run: make setup - run: make setup
- run: sudo sysctl -w vm.max_map_count=262144 - run: sudo sysctl -w vm.max_map_count=262144
- run: - run:
command: | command: |
make generate; make generate
if [[ $(git diff) ]]; then if ! git diff --quiet README.md; then
echo "Please run `make generate`"; echo "Please run `make generate`"
git status --short; git status --short
git diff; git --no-pager diff README.md
exit 1; exit 1
fi fi
- run: make test - run: make test
- store_artifacts: - store_artifacts:
@@ -30,35 +31,26 @@ jobs:
- store_test_results: - store_test_results:
path: tmp/test-results path: tmp/test-results
build-version: executors:
environment: machine:
DOKKU_VERSION: v0.19.0
machine: machine:
docker_layer_caching: false docker_layer_caching: false
image: ubuntu-1604:201903-01 image: ubuntu-1604:201903-01
jobs:
build-master:
environment:
DOKKU_VERSION: master
executor: machine
steps: steps:
- checkout - build
- run: pyenv global 3.7.0
- run: make setup build-version:
- run: sudo sysctl -w vm.max_map_count=262144 environment:
- run: DOKKU_VERSION: v0.19.0
command: | executor: machine
make generate; steps:
if [[ $(git diff) ]]; then - build
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
workflows: workflows:
version: 2 version: 2

View File

@@ -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: 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:

View File

@@ -1,4 +1,4 @@
# dokku redis [![Build Status](https://img.shields.io/travis/dokku/dokku-redis.svg?branch=master "Build Status")](https://travis-ci.org/dokku/dokku-redis) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) # dokku redis [![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-redis.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-redis/tree/master) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)
Official redis plugin for dokku. Currently defaults to installing [redis 5.0.7](https://hub.docker.com/_/redis/). Official redis plugin for dokku. Currently defaults to installing [redis 5.0.7](https://hub.docker.com/_/redis/).
@@ -63,16 +63,24 @@ Help for any commands can be displayed by specifying the command as an argument
dokku redis:create <service> [--create-flags...] dokku redis: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 redis service named lolipop: Create a redis service named lolipop:
```shell ```shell
dokku redis:create lolipop dokku redis: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 redis image.
```shell ```shell
export REDIS_IMAGE="${PLUGIN_IMAGE}" export REDIS_IMAGE="redis"
export REDIS_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}" export REDIS_IMAGE_VERSION="${PLUGIN_IMAGE_VERSION}"
dokku redis:create lolipop dokku redis:create lolipop
``` ```
@@ -91,6 +99,19 @@ dokku redis:create lolipop
dokku redis:info <service> [--single-info-flag] dokku redis: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 redis:list
dokku redis:logs <service> [-t|--tail] dokku redis: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,6 +176,11 @@ dokku redis:logs lolipop --tail
dokku redis:link <service> <app> [--link-flags...] dokku redis: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 redis 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. A redis 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
@@ -173,7 +203,7 @@ DOKKU_REDIS_LOLIPOP_PORT_6379_TCP_ADDR=172.17.0.1
The following will be set on the linked application by default: The following will be set on the linked application by default:
``` ```
REDIS_URL=redis://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop REDIS_URL=redis://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app: The host exposed here only works internally in docker containers. If you want your container to be reachable from outside, you should use the 'expose' subcommand. Another service can be linked to your app:
@@ -182,17 +212,17 @@ The host exposed here only works internally in docker containers. If you want yo
dokku redis:link other_service playground dokku redis:link other_service playground
``` ```
It is possible to change the protocol for redis_url by setting the environment variable redis_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 `REDIS_URL` by setting the environment variable `REDIS_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 REDIS_DATABASE_SCHEME=redis2 dokku config:set playground REDIS_DATABASE_SCHEME=redis2
dokku redis:link lolipop playground dokku redis:link lolipop playground
``` ```
This will cause redis_url to be set as: This will cause `REDIS_URL` to be set as:
``` ```
redis2://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop redis2://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
### unlink the redis service from the app ### unlink the redis service from the app
@@ -253,10 +283,10 @@ dokku redis:enter lolipop touch /tmp/test
dokku redis:expose <service> <ports...> dokku redis: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 redis:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]} dokku redis:expose lolipop 6379
``` ```
### unexpose a previously exposed redis service ### unexpose a previously exposed redis service
@@ -266,7 +296,7 @@ dokku redis:expose lolipop ${PLUGIN_DATASTORE_PORTS[@]}
dokku redis:unexpose <service> dokku redis: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 redis:unexpose lolipop dokku redis:unexpose lolipop
@@ -282,7 +312,7 @@ dokku redis:promote <service> <app>
If you have a redis service linked to an app and try to link another redis service another link environment variable will be generated automatically: If you have a redis service linked to an app and try to link another redis service another link environment variable will be generated automatically:
``` ```
DOKKU_REDIS_BLUE_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service DOKKU_REDIS_BLUE_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
``` ```
You can promote the new service to be the primary one: You can promote the new service to be the primary one:
@@ -293,12 +323,12 @@ You can promote the new service to be the primary one:
dokku redis:promote other_service playground dokku redis:promote other_service playground
``` ```
This will replace redis_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 `REDIS_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:
``` ```
REDIS_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service REDIS_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
DOKKU_REDIS_BLUE_URL=redis://other_service:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service DOKKU_REDIS_BLUE_URL=redis://:ANOTHER_PASSWORD@dokku-redis-other-service:6379/other_service
DOKKU_REDIS_SILVER_URL=redis://lolipop:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop DOKKU_REDIS_SILVER_URL=redis://:SOME_PASSWORD@dokku-redis-lolipop:6379/lolipop
``` ```
### start a previously stopped redis service ### start a previously stopped redis service
@@ -347,6 +377,13 @@ dokku redis:restart lolipop
dokku redis:upgrade <service> [--upgrade-flags...] dokku redis: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
@@ -377,6 +414,14 @@ dokku redis:app-links playground
dokku redis:clone <service> <new-service> [--clone-flags...] dokku redis: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
@@ -517,7 +562,11 @@ dokku redis:backup-deauth lolipop
dokku redis:backup <service> <bucket-name> [--use-iam] dokku redis: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 redis:backup lolipop my-s3-bucket --use-iam dokku redis:backup lolipop my-s3-bucket --use-iam
@@ -530,7 +579,7 @@ dokku redis:backup lolipop my-s3-bucket --use-iam
dokku redis:backup-set-encryption <service> <passphrase> dokku redis:backup-set-encryption <service> <passphrase>
``` ```
Set a gpg passphrase for backups: Set the GPG-compatible passphrase for encrypting backups for backups:
```shell ```shell
dokku redis:backup-set-encryption lolipop dokku redis:backup-set-encryption lolipop
@@ -543,7 +592,7 @@ dokku redis:backup-set-encryption lolipop
dokku redis:backup-unset-encryption <service> dokku redis:backup-unset-encryption <service>
``` ```
Unset a gpg encryption key for backups: Unset the `GPG` encryption passphrase for backups:
```shell ```shell
dokku redis:backup-unset-encryption lolipop dokku redis:backup-unset-encryption lolipop
@@ -556,6 +605,10 @@ dokku redis:backup-unset-encryption lolipop
dokku redis:backup-schedule <service> <schedule> <bucket-name> [--use-iam] dokku redis: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

View File

@@ -5,50 +5,84 @@ 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, sponsors, unimplemented, dokku_version):
return "\n\n".join([ prefix = "\n\n".join([
header(service), 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), requirements_section(dokku_version),
installation_section(service, dokku_version), installation_section(service, dokku_version),
commands_section(service, alias, scheme, ports, unimplemented), commands_section(service, variable, alias, image, scheme, ports, unimplemented),
usage_section(service, alias, 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") ]
)
.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"# dokku {service}",
f"[![Build Status](https://img.shields.io/travis/dokku/dokku-{service}.svg?branch=master \"Build Status\")](https://travis-ci.org/dokku/dokku-{service})", f'[![Build Status](https://img.shields.io/circleci/project/github/dokku/dokku-{service}.svg?branch=master&style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku-{service}/tree/master)',
f"[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg \"IRC Freenode\")](https://webchat.freenode.net/?channels=dokku)", f'[![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku)',
]) ]
)
def description(service, version): def description(service, full_image, version):
return f"Official {service} plugin for dokku. Currently defaults to installing [{service} {version}](https://hub.docker.com/_/{service}/)." 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): 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", "```shell",
f"# on {dokku_version}", f"# on {dokku_version}",
f"sudo dokku plugin:install https://github.com/dokku/dokku-{service}.git {service}", 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 +97,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 +115,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", "## 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.", 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_intro(service, variable, alias, image, scheme, ports, unimplemented),
usage_lifecycle(service, alias, scheme, ports, unimplemented), usage_lifecycle(service, variable, alias, image, scheme, ports, unimplemented),
usage_automation(service, alias, scheme, ports, unimplemented), usage_automation(service, variable, alias, image, scheme, ports, unimplemented),
usage_data_management(service, alias, scheme, ports, unimplemented), usage_data_management(service, variable, alias, image, scheme, ports, unimplemented),
usage_backup(service, alias, scheme, ports, unimplemented), usage_backup(service, variable, alias, image, scheme, ports, unimplemented),
usage_docker_pull(service, alias, 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 +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"] commands = ["app-links", "clone", "exists", "linked", "links"]
content = [ content = [
"### Service Automation", "### 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"] commands = ["import", "export"]
content = [ content = [
"### Data Management", "### 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): 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 +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() 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 +274,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 +295,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 +309,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 +321,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 +422,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 +470,43 @@ 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+") 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__))) 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)

View File

@@ -188,18 +188,18 @@ 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) BACKUP_TMPDIR=$(mktemp -d --tmpdir)
trap 'rm -rf "$TMPDIR" > /dev/null' RETURN INT TERM EXIT trap 'rm -rf "$BACKUP_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"
is_container_status "$ID" "Running" || dokku_log_fail "Service container is not running" 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 # Build parameter list for s3backup tool
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BUCKET_NAME=$BUCKET_NAME" BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BUCKET_NAME=$BUCKET_NAME"
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e BACKUP_NAME=${PLUGIN_COMMAND_PREFIX}-${SERVICE}" 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 if [[ -f "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION" ]]; then
BACKUP_PARAMETERS="$BACKUP_PARAMETERS -e AWS_DEFAULT_REGION=$(cat "$SERVICE_BACKUP_ROOT/AWS_DEFAULT_REGION")" 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 key valid_flags
local flag_map=( local flag_map=(
"--config-dir: ${SERVICE_ROOT}/config" "--config-dir: ${SERVICE_ROOT}/${PLUGIN_CONFIG_SUFFIX}"
"--data-dir: ${SERVICE_ROOT}/data" "--data-dir: ${SERVICE_ROOT}/data"
"--dsn: ${SERVICE_URL}" "--dsn: ${SERVICE_URL}"
"--exposed-ports: $(service_exposed_ports "$SERVICE")" "--exposed-ports: $(service_exposed_ports "$SERVICE")"

1
config
View File

@@ -21,6 +21,7 @@ export PLUGIN_SCHEME="redis"
export PLUGIN_SERVICE="Redis" export PLUGIN_SERVICE="Redis"
export PLUGIN_VARIABLE="REDIS" export PLUGIN_VARIABLE="REDIS"
export PLUGIN_BASE_PATH="$PLUGIN_PATH" export PLUGIN_BASE_PATH="$PLUGIN_PATH"
export PLUGIN_CONFIG_SUFFIX="config"
if [[ -n $DOKKU_API_VERSION ]]; then if [[ -n $DOKKU_API_VERSION ]]; then
export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH" export PLUGIN_BASE_PATH="$PLUGIN_ENABLED_PATH"
fi fi

View File

@@ -42,13 +42,13 @@ service_create() {
mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory" 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" mkdir -p "$SERVICE_ROOT/data" || dokku_log_fail "Unable to create service data directory"
mkdir -p "$SERVICE_ROOT/config" || dokku_log_fail "Unable to create service config directory" mkdir -p "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX" || dokku_log_fail "Unable to create service config directory"
touch "$LINKS_FILE" touch "$LINKS_FILE"
if [[ -z $REDIS_CONFIG_PATH ]]; then if [[ -z $REDIS_CONFIG_PATH ]]; then
curl -sSL "https://raw.githubusercontent.com/antirez/redis/${PLUGIN_IMAGE_VERSION:0:3}/redis.conf" >"$SERVICE_ROOT/config/redis.conf" || dokku_log_fail "Unable to download the default redis.conf to the config directory" curl -sSL "https://raw.githubusercontent.com/antirez/redis/${PLUGIN_IMAGE_VERSION:0:3}/redis.conf" >"$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/redis.conf" || dokku_log_fail "Unable to download the default redis.conf to the config directory"
else else
cp "$REDIS_CONFIG_PATH" "$SERVICE_ROOT/config/redis.conf" || dokku_log_fail "Unable to copy the ${REDIS_CONFIG_PATH} to the config directory" cp "$REDIS_CONFIG_PATH" "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/redis.conf" || dokku_log_fail "Unable to copy the ${REDIS_CONFIG_PATH} to the config directory"
fi fi
PASSWORD=$(openssl rand -hex 32) PASSWORD=$(openssl rand -hex 32)
if [[ -n "$SERVICE_PASSWORD" ]]; then if [[ -n "$SERVICE_PASSWORD" ]]; then
@@ -57,7 +57,7 @@ service_create() {
fi fi
echo "$PASSWORD" >"$SERVICE_ROOT/PASSWORD" echo "$PASSWORD" >"$SERVICE_ROOT/PASSWORD"
chmod 640 "$SERVICE_ROOT/PASSWORD" chmod 640 "$SERVICE_ROOT/PASSWORD"
sed -i.bak "s/# requirepass.*/requirepass ${PASSWORD}/" "$SERVICE_ROOT/config/redis.conf" && rm "$SERVICE_ROOT/config/redis.conf.bak" sed -i.bak "s/# requirepass.*/requirepass ${PASSWORD}/" "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/redis.conf" && rm "$SERVICE_ROOT/$PLUGIN_CONFIG_SUFFIX/redis.conf.bak"
[[ -n "$SERVICE_CUSTOM_ENV" ]] && REDIS_CUSTOM_ENV="$SERVICE_CUSTOM_ENV" [[ -n "$SERVICE_CUSTOM_ENV" ]] && REDIS_CUSTOM_ENV="$SERVICE_CUSTOM_ENV"
if [[ -n $REDIS_CUSTOM_ENV ]]; then if [[ -n $REDIS_CUSTOM_ENV ]]; then
@@ -76,7 +76,7 @@ service_create_container() {
local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE" local SERVICE_HOST_ROOT="$PLUGIN_DATA_HOST_ROOT/$SERVICE"
local SERVICE_NAME="$(get_service_name "$SERVICE")" local SERVICE_NAME="$(get_service_name "$SERVICE")"
ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/config:/usr/local/etc/redis" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=redis "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" redis-server /usr/local/etc/redis/redis.conf --bind 0.0.0.0) ID=$(docker run --name "$SERVICE_NAME" -v "$SERVICE_HOST_ROOT/data:/data" -v "$SERVICE_HOST_ROOT/$PLUGIN_CONFIG_SUFFIX:/usr/local/etc/redis" --env-file="$SERVICE_ROOT/ENV" -d --restart always --label dokku=service --label dokku.service=redis "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" redis-server /usr/local/etc/redis/redis.conf --bind 0.0.0.0)
echo "$ID" >"$SERVICE_ROOT/ID" echo "$ID" >"$SERVICE_ROOT/ID"
dokku_log_verbose_quiet "Waiting for container to be ready" dokku_log_verbose_quiet "Waiting for container to be ready"
@@ -155,5 +155,5 @@ service_url() {
local SERVICE="$1" local SERVICE="$1"
local PASSWORD="$(service_password "$SERVICE")" local PASSWORD="$(service_password "$SERVICE")"
local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")" local SERVICE_DNS_HOSTNAME="$(service_dns_hostname "$SERVICE")"
echo "$PLUGIN_SCHEME://$SERVICE:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}" echo "$PLUGIN_SCHEME://:$PASSWORD@$SERVICE_DNS_HOSTNAME:${PLUGIN_DATASTORE_PORTS[0]}"
} }

View File

@@ -76,10 +76,10 @@ 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 HELP_TMPDIR=$(mktemp -d --tmpdir)
local UNCLEAN_FILE="${TMPDIR}/cmd-unclean" CLEAN_FILE="${TMPDIR}/cmd-clean" local UNCLEAN_FILE="${HELP_TMPDIR}/cmd-unclean" CLEAN_FILE="${HELP_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 "$HELP_TMPDIR" > /dev/null' RETURN INT TERM EXIT
rm -rf "$UNCLEAN_FILE" "$CLEAN_FILE" rm -rf "$UNCLEAN_FILE" "$CLEAN_FILE"
cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" >"$UNCLEAN_FILE" cat "$SUBCOMMAND_ROOT/$SUBCOMMAND" >"$UNCLEAN_FILE"
@@ -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
} }

View File

@@ -1,4 +1,4 @@
[plugin] [plugin]
description = "dokku redis service plugin" description = "dokku redis service plugin"
version = "1.12.2" version = "1.13.0"
[plugin.config] [plugin.config]

View File

@@ -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

View File

@@ -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"

View File

@@ -45,7 +45,7 @@ service-destroy-cmd() {
service_container_rm "$SERVICE" service_container_rm "$SERVICE"
dokku_log_verbose_quiet "Removing data" 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" rm -rf "$SERVICE_ROOT"
dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE" dokku_log_info2 "$PLUGIN_SERVICE container deleted: $SERVICE"

View File

@@ -23,21 +23,21 @@ service-link-cmd() {
#E #E
#E the following will be set on the linked application by default: #E the following will be set on the linked application by default:
#E #E
#E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#E #E
#E the host exposed here only works internally in docker containers. #E the host exposed here only works internally in docker containers.
#E if you want your container to be reachable from outside, you should #E if you want your container to be reachable from outside, you should
#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
#E ${PLUGIN_SCHEME}2://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E ${PLUGIN_SCHEME}2://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#A service, service to run command against #A service, service to run command against
#A app, app to run command against #A app, app to run command against
#F -a|--alias "BLUE_DATABASE", an alternative alias to use for linking to an app via environment variable #F -a|--alias "BLUE_DATABASE", an alternative alias to use for linking to an app via environment variable

View File

@@ -9,7 +9,7 @@ service-promote-cmd() {
#E if you have a $PLUGIN_COMMAND_PREFIX service linked to an app and try to link another $PLUGIN_COMMAND_PREFIX service #E if you have a $PLUGIN_COMMAND_PREFIX service linked to an app and try to link another $PLUGIN_COMMAND_PREFIX service
#E another link environment variable will be generated automatically: #E another link environment variable will be generated automatically:
#E #E
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E #E
#E you can promote the new service to be the primary one #E you can promote the new service to be the primary one
#E > NOTE: this will restart your app #E > NOTE: this will restart your app
@@ -18,9 +18,9 @@ service-promote-cmd() {
#E another environment variable to hold the previous value if necessary. #E another environment variable to hold the previous value if necessary.
#E you could end up with the following for example: #E you could end up with the following for example:
#E #E
#E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E ${PLUGIN_DEFAULT_ALIAS}_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://other_service:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_BLUE_URL=${PLUGIN_SCHEME}://:ANOTHER_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-other-service:${PLUGIN_DATASTORE_PORTS[0]}/other_service
#E DOKKU_${PLUGIN_DEFAULT_ALIAS}_SILVER_URL=${PLUGIN_SCHEME}://lolipop:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop #E DOKKU_${PLUGIN_DEFAULT_ALIAS}_SILVER_URL=${PLUGIN_SCHEME}://:SOME_PASSWORD@dokku-${PLUGIN_COMMAND_PREFIX}-lolipop:${PLUGIN_DATASTORE_PORTS[0]}/lolipop
#A service, service to run command against #A service, service to run command against
#A app, app to run command against #A app, app to run command against
declare desc="promote service <service> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>" declare desc="promote service <service> as ${PLUGIN_DEFAULT_ALIAS}_URL in <app>"

View File

@@ -22,21 +22,21 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:info) success" { @test "($PLUGIN_COMMAND_PREFIX:info) success" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l run dokku "$PLUGIN_COMMAND_PREFIX:info" l
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "${lines[*]}" "redis://l:$password@dokku-redis-l:6379" assert_contains "${lines[*]}" "redis://:$password@dokku-redis-l:6379"
} }
@test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" { @test "($PLUGIN_COMMAND_PREFIX:info) replaces underscores by dash in hostname" {
dokku "$PLUGIN_COMMAND_PREFIX:create" test_with_underscores dokku "$PLUGIN_COMMAND_PREFIX:create" test_with_underscores
run dokku "$PLUGIN_COMMAND_PREFIX:info" test_with_underscores run dokku "$PLUGIN_COMMAND_PREFIX:info" test_with_underscores
password="$(sudo cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/test_with_underscores/PASSWORD")"
assert_contains "${lines[*]}" "redis://test_with_underscores:$password@dokku-redis-test-with-underscores:6379" assert_contains "${lines[*]}" "redis://:$password@dokku-redis-test-with-underscores:6379"
dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores dokku --force "$PLUGIN_COMMAND_PREFIX:destroy" test_with_underscores
} }
@test "($PLUGIN_COMMAND_PREFIX:info) success with flag" { @test "($PLUGIN_COMMAND_PREFIX:info) success with flag" {
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn run dokku "$PLUGIN_COMMAND_PREFIX:info" l --dsn
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_output "redis://l:$password@dokku-redis-l:6379" assert_output "redis://:$password@dokku-redis-l:6379"
run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir run dokku "$PLUGIN_COMMAND_PREFIX:info" l --config-dir
assert_success assert_success

View File

@@ -63,7 +63,7 @@ teardown() {
echo "status: $status" echo "status: $status"
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }
@@ -96,7 +96,7 @@ teardown() {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis2://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis2://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }
@@ -113,7 +113,7 @@ teardown() {
dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS" dokku "$PLUGIN_COMMAND_PREFIX:link" l my_app --alias "ALIAS"
url=$(dokku config:get my_app ALIAS_URL) url=$(dokku config:get my_app ALIAS_URL)
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
assert_contains "$url" "redis://l:$password@dokku-redis-l:6379" assert_contains "$url" "redis://:$password@dokku-redis-l:6379"
assert_success assert_success
dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app dokku "$PLUGIN_COMMAND_PREFIX:unlink" l my_app
} }

View File

@@ -40,15 +40,15 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:promote) changes REDIS_URL" { @test "($PLUGIN_COMMAND_PREFIX:promote) changes REDIS_URL" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_URL=redis://u:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_URL=redis://:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
assert_equal "$url" "redis://l:$password@dokku-redis-l:6379" assert_equal "$url" "redis://:$password@dokku-redis-l:6379"
} }
@test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" { @test "($PLUGIN_COMMAND_PREFIX:promote) creates new config url when needed" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_URL=redis://u:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_URL=redis://:p@host:6379/db" "DOKKU_REDIS_BLUE_URL=redis://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
run dokku config my_app run dokku config my_app
assert_contains "${lines[*]}" "DOKKU_REDIS_" assert_contains "${lines[*]}" "DOKKU_REDIS_"
@@ -56,8 +56,8 @@ teardown() {
@test "($PLUGIN_COMMAND_PREFIX:promote) uses REDIS_DATABASE_SCHEME variable" { @test "($PLUGIN_COMMAND_PREFIX:promote) uses REDIS_DATABASE_SCHEME variable" {
password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")" password="$(sudo cat "$PLUGIN_DATA_ROOT/l/PASSWORD")"
dokku config:set my_app "REDIS_DATABASE_SCHEME=redis2" "REDIS_URL=redis://u:p@host:6379" "DOKKU_REDIS_BLUE_URL=redis2://l:$password@dokku-redis-l:6379" dokku config:set my_app "REDIS_DATABASE_SCHEME=redis2" "REDIS_URL=redis://:p@host:6379" "DOKKU_REDIS_BLUE_URL=redis2://:$password@dokku-redis-l:6379"
dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app dokku "$PLUGIN_COMMAND_PREFIX:promote" l my_app
url=$(dokku config:get my_app REDIS_URL) url=$(dokku config:get my_app REDIS_URL)
assert_equal "$url" "redis2://l:$password@dokku-redis-l:6379" assert_equal "$url" "redis2://:$password@dokku-redis-l:6379"
} }