Skip to content

Commit

Permalink
Surround regexps with ^ and $
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfonso Acosta committed Jul 14, 2015
1 parent d91beb9 commit eef3104
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion prog/weaveproxy/main.go
Expand Up @@ -51,7 +51,7 @@ func main() {
mflag.BoolVar(&justVersion, []string{"#version", "-version"}, false, "print version and exit")
mflag.StringVar(&logLevel, []string{"-log-level"}, "info", "logging level (debug, info, warning, error)")
ListVar(&c.ListenAddrs, []string{"H"}, defaultListenAddrs, "addresses on which to listen")
mflag.StringVar(&c.Hostname, []string{"-hostname"}, "/(.*)/$1/", "Regexp substitution to apply on container names (e.g. '/aws-[0-9]+-(.*)/my-app-$1/')")
mflag.StringVar(&c.Hostname, []string{"-hostname"}, "/^(.*)$/$1/", "Regexp substitution to apply on container names (e.g. '/^aws-[0-9]+-(.*)$/my-app-$1/')")
mflag.BoolVar(&c.NoDefaultIPAM, []string{"#-no-default-ipam", "-no-default-ipalloc"}, false, "do not automatically allocate addresses for containers without a WEAVE_CIDR")
mflag.BoolVar(&c.NoRewriteHosts, []string{"no-rewrite-hosts"}, false, "do not automatically rewrite /etc/hosts. Use if you need the docker IP to remain in /etc/hosts")
mflag.StringVar(&c.TLSConfig.CACert, []string{"#tlscacert", "-tlscacert"}, "", "Trust certs signed only by this CA")
Expand Down
4 changes: 2 additions & 2 deletions site/proxy.md
Expand Up @@ -140,9 +140,9 @@ For those situations, the proxy provides a
`/containerNamePattern/hostnameReplacement/` is a regular expression
substitution command.

For instance, if we launch the proxy using `--hostname='/aws-[0-9]+-(.*)/my-app-$1/'`
For instance, if we launch the proxy using `--hostname='/^aws-[0-9]+-(.*)$/my-app-$1/'`

host1$ weave launch-router && weave launch-dns && weave launch-proxy --hostname='/aws-[0-9]+-(.*)/my-app-$1/'
host1$ weave launch-router && weave launch-dns && weave launch-proxy --hostname='/^aws-[0-9]+-(.*)$/my-app-$1/'
host1$ eval "$(weave env)"

then, running a container named `aws-12798186823-foo` will lead to weaveDNS registering
Expand Down
2 changes: 1 addition & 1 deletion test/680_proxy_hostname_derivation.sh
Expand Up @@ -19,7 +19,7 @@ start_container() {
start_suite "Hostname derivation through container name substitutions"

weave_on $HOST1 launch-dns 10.2.254.1/24
weave_on $HOST1 launch-proxy --hostname '/[^-]+-(?P<appname>[^-]*)-[^-]+/$appname/'
weave_on $HOST1 launch-proxy --hostname '/^[^-]+-(?P<appname>[^-]*)-[^-]+$/$appname/'

start_container -e WEAVE_CIDR=$C1/24 --name=$CNAME1
start_container -e WEAVE_CIDR=$C2/24 --name=$CNAME2
Expand Down

0 comments on commit eef3104

Please sign in to comment.