dokku/dokku-mongo

Allow dashes in names

Closed this issue · 2 comments

Currently, if you try to create a database with dashes in its name, it fails with:
Please specify a valid name for the service. Valid characters are: [A-Za-z0-9_]+

If you name a database based off of an application name, which allows dashes since dashes are allowed in URLs, this fails. Can dashes be added back?

This was added in #117. As services generally provision their database (or collection, or whatever the datastore calls it) with the name of the service, folks were allowed to create services with characters that would otherwise break the system. The allowed list of characters always depends, and in some cases can even include special characters if you quote them properly (not all libraries do this).

Rather than special case the MongoDB plugin and allowing dashes, I'm going to keep the valid character list the same across all datastore plugins. Fewer special cases means less reasoning about what is and isn't okay across the datastore plugins.

As an aside, application names can also include periods - since they can match a valid hostname - but those aren't valid characters for MongoDB collections, so the argument for this sort of change doesn't always hold true :(

Fair enough. Thanks for the explanation.