[proxy] More flexible container name -> hostname derivation

Provides to new two new flags: `--hostname-match <regexp>`
and `--hostname-replacement <replacement>`. When launching a container, its name
matched against regular expression `<regexp>`. Then, based on that match,
`<replacement>` will be used to generate a hostname, which will ultimately be
handed over to weaveDNS for registration.

The substitution is implemented with
https://golang.org/pkg/regexp/#Regexp.ReplaceAllString . Thus, references to
regexp substitution groups should be prepended with a dollar sign.

For instance, if we provide `--hostname-match '^aws-[0-9]+-(.*)$'` and
`--hostname-replacement 'my-app-$1'`, running a container named
`aws-12798186823-foo` through WeaveProxy will lead to WeaveDNS registering
`my-app-foo`.

Closes #1018
This commit is contained in:
Alfonso Acosta committed 2015-07-14 14:41:44 +00:00
1 parent bbacaa42b8
commit 4f82dc97fd
6 files changed
+92 -15

No files matched your search

+1
View File
@@ -37,6 +37,7 @@ weave launch-router [--password <password>] [--nickname <nickname>]
weave launch-dns [<addr>]
weave launch-proxy [-H <endpoint>] [--with-dns | --without-dns]
[--no-default-ipalloc] [--no-rewrite-hosts]
[[--hostname-match <regexp>] [--hostname-replacement <replacement>]]
weave connect [--replace] [<peer> ...]
weave forget <peer> ...
weave run [--with-dns | --without-dns] [<addr> ...]