End of the // eradication.
or was that p eradication?
// is no longer given any special status. Names are
cleaned pretty much everywhere before being used,
multiple adjacent spashes are squashed into 1,
trailing slashes are removed. Thus starting
a name with // is now a mistake.
Change-Id: I2dc5917533352fd9d211a9d1ab184e5cf2f8b56f
diff --git a/lib/modules/core/proxy.go b/lib/modules/core/proxy.go
index 3cc63ea..3f83ece 100644
--- a/lib/modules/core/proxy.go
+++ b/lib/modules/core/proxy.go
@@ -40,7 +40,7 @@
return err
}
defer proxy.Shutdown()
- pname := naming.JoinAddressName(proxy.Endpoint().String(), "//")
+ pname := naming.JoinAddressName(proxy.Endpoint().String(), "")
fmt.Fprintf(stdout, "PROXY_ADDR=%s\n", proxy.Endpoint().String())
fmt.Fprintf(stdout, "PROXY_NAME=%s\n", pname)
r := rt.R()
diff --git a/runtimes/google/ipc/debug_test.go b/runtimes/google/ipc/debug_test.go
index 9e8b9c7..d5bce8a 100644
--- a/runtimes/google/ipc/debug_test.go
+++ b/runtimes/google/ipc/debug_test.go
@@ -99,8 +99,8 @@
{"__debug", "*", []string{"logs", "pprof", "stats", "vtrace"}},
}
for _, tc := range testcases {
- addr := naming.JoinAddressName(ep.String(), "//"+tc.name)
- call, err := client.StartCall(ctx, addr, ipc.GlobMethod, []interface{}{tc.pattern})
+ addr := naming.JoinAddressName(ep.String(), tc.name)
+ call, err := client.StartCall(ctx, addr, ipc.GlobMethod, []interface{}{tc.pattern}, options.NoResolve(true))
if err != nil {
t.Fatalf("client.StartCall failed: %v", err)
}
diff --git a/runtimes/google/ipc/server.go b/runtimes/google/ipc/server.go
index 3bc9da3..4c21aea 100644
--- a/runtimes/google/ipc/server.go
+++ b/runtimes/google/ipc/server.go
@@ -142,7 +142,7 @@
}
for _, n := range names {
address, suffix := naming.SplitAddressName(n)
- if suffix != "" && suffix != "//" {
+ if suffix != "" {
continue
}
if _, err := inaming.NewEndpoint(address); err == nil {
diff --git a/runtimes/google/naming/namespace/all_test.go b/runtimes/google/naming/namespace/all_test.go
index 1f7050a..4192a68 100644
--- a/runtimes/google/naming/namespace/all_test.go
+++ b/runtimes/google/naming/namespace/all_test.go
@@ -316,17 +316,14 @@
ns := r.Namespace()
ns.SetRoots(root.name)
- // Mount using a relative name starting with //.
- // This means don't walk out of the namespace's root mount table
- // even if there is already something mounted at mt2. Thus, the example
- // below will fail.
+ // /mt2 is not an endpoint. Thus, the example below will fail.
mt3Server := mts[mt3MP].name
- mt2a := "//mt2/a"
+ mt2a := "/mt2/a"
if err := ns.Mount(r.NewContext(), mt2a, mt3Server, ttl); verror.Is(err, naming.ErrNoSuchName.ID) {
boom(t, "Successfully mounted %s - expected an err %v, not %v", mt2a, naming.ErrNoSuchName, err)
}
- // Mount using the relative name not starting with //.
+ // Mount using the relative name.
// This means walk through mt2 if it already exists and mount within
// the lower level mount table, if the name doesn't exist we'll create
// a new name for it.
@@ -341,14 +338,11 @@
// The server for mt2a is mt3server from the second mount above.
testResolve(t, r, ns, mt2a, mt3Server)
- // Using a terminal or non-terminal name makes no difference if the
- // mount is directed to the root name server (since that's the root
- // for the namespace for this process) and the name exists within
- // that mount table. In both cases, the server will be added to the
- // set of mount table servers for that name.
+ // Add two more mounts. The // should be stripped off of the
+ // second.
for _, mp := range []struct{ name, server string }{
{"mt2", mts[mt4MP].name},
- {"//mt2", mts[mt5MP].name},
+ {"mt2//", mts[mt5MP].name},
} {
if err := ns.Mount(r.NewContext(), mp.name, mp.server, ttl, naming.ServesMountTableOpt(true)); err != nil {
boom(t, "Failed to Mount %s: %s", mp.name, err)
diff --git a/runtimes/google/naming/namespace/cache.go b/runtimes/google/naming/namespace/cache.go
index 8d5293f..af412bf 100644
--- a/runtimes/google/naming/namespace/cache.go
+++ b/runtimes/google/naming/namespace/cache.go
@@ -80,8 +80,8 @@
func (c *ttlCache) remember(prefix string, entry *naming.MountEntry) {
// Remove suffix. We only care about the name that gets us
// to the mounttable from the last mounttable.
- prefix = normalize(prefix)
- entry.Name = normalize(entry.Name)
+ prefix = naming.Clean(prefix)
+ entry.Name = naming.Clean(entry.Name)
prefix = naming.TrimSuffix(prefix, entry.Name)
// Copy the entry.
var ce naming.MountEntry
@@ -107,7 +107,7 @@
defer c.Unlock()
for key := range c.entries {
for _, n := range names {
- n = normalize(n)
+ n = naming.Clean(n)
if strings.HasPrefix(key, n) {
delete(c.entries, key)
break
@@ -120,7 +120,7 @@
// prefix, and suffix. If any of the associated servers is expired, don't return anything
// since that would reduce availability.
func (c *ttlCache) lookup(name string) (naming.MountEntry, error) {
- name = normalize(name)
+ name = naming.Clean(name)
c.Lock()
defer c.Unlock()
now := time.Now()
@@ -139,22 +139,14 @@
return naming.MountEntry{}, verror.Make(naming.ErrNoSuchName, nil, name)
}
-// backup moves the last element of the prefix to the suffix. "//" is preserved. Thus
-// a/b//c, -> a/b, //c
-// /a/b,c/d -> /a, b/c/d
-// /a,b/c/d -> ,/a/b/c/d
+// backup moves the last element of the prefix to the suffix.
func backup(prefix, suffix string) (string, string) {
for i := len(prefix) - 1; i > 0; i-- {
if prefix[i] != '/' {
continue
}
- if prefix[i-1] == '/' {
- suffix = naming.Join(prefix[i-1:], suffix)
- prefix = prefix[:i-1]
- } else {
- suffix = naming.Join(prefix[i+1:], suffix)
- prefix = prefix[:i]
- }
+ suffix = naming.Join(prefix[i+1:], suffix)
+ prefix = prefix[:i]
return prefix, suffix
}
return "", naming.Join(prefix, suffix)
diff --git a/runtimes/google/naming/namespace/glob.go b/runtimes/google/naming/namespace/glob.go
index 89fc217..632c0b8 100644
--- a/runtimes/google/naming/namespace/glob.go
+++ b/runtimes/google/naming/namespace/glob.go
@@ -44,11 +44,6 @@
if !server.ServesMountTable() {
return nil
}
- // TODO(p): soon to be unnecessary.
- _, n := naming.SplitAddressName(s.Server)
- if strings.HasPrefix(n, "//") {
- return nil
- }
}
// If this is restricted recursive and not a mount table, don't
@@ -137,11 +132,11 @@
// depth returns the directory depth of a given name.
func depth(name string) int {
- name = strings.Trim(name, "/")
+ name = strings.Trim(naming.Clean(name), "/")
if name == "" {
return 0
}
- return strings.Count(name, "/") - strings.Count(name, "//") + 1
+ return strings.Count(name, "/") + 1
}
func (ns *namespace) globLoop(ctx context.T, e *naming.MountEntry, prefix string, pattern *glob.Glob, reply chan naming.MountEntry) {
diff --git a/runtimes/google/naming/namespace/namespace.go b/runtimes/google/naming/namespace/namespace.go
index 7458858..26cc469 100644
--- a/runtimes/google/naming/namespace/namespace.go
+++ b/runtimes/google/naming/namespace/namespace.go
@@ -1,7 +1,6 @@
package namespace
import (
- "strings"
"sync"
"time"
@@ -97,7 +96,7 @@
// rootName 'roots' a name: if name is not a rooted name, it prepends the root
// mounttable's OA.
func (ns *namespace) rootName(name string) []string {
- name = normalize(name)
+ name = naming.Clean(name)
if address, _ := naming.SplitAddressName(name); len(address) == 0 {
var ret []string
ns.RLock()
@@ -112,7 +111,7 @@
// rootMountEntry 'roots' a name creating a mount entry for the name.
func (ns *namespace) rootMountEntry(name string) (*naming.MountEntry, bool) {
- name = normalize(name)
+ name = naming.Clean(name)
e := new(naming.MountEntry)
expiration := time.Now().Add(time.Hour) // plenty of time for a call
address, suffix := naming.SplitAddressName(name)
@@ -181,21 +180,3 @@
}
return nil
}
-
-// normalize removes any single trailing slash and compresses
-// multiple consecutive slashes to one.
-// TODO(p): Transitionally it also removes a leading double
-// slash that used to mean something but doesn't any more.
-// I should remove that in a week or so when we've killed off
-// all code inserting this double slash.
-func normalize(name string) string {
- // Eradicate leading double slash (for now). Eventually we
- // should get ris of this.
- name = strings.TrimPrefix(name, "//")
- // Eradicate duplicate slashes and trailing slashes. We
- // could use path.Clean but it has other side effects.
- for strings.Contains(name, "//") {
- name = strings.Replace(name, "//", "/", -1)
- }
- return strings.TrimSuffix(name, "/")
-}
diff --git a/services/mgmt/application/impl/impl_test.go b/services/mgmt/application/impl/impl_test.go
index 4938be2..845c5ee 100644
--- a/services/mgmt/application/impl/impl_test.go
+++ b/services/mgmt/application/impl/impl_test.go
@@ -51,9 +51,9 @@
}
// Create client stubs for talking to the server.
- stub := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search"))
- stubV1 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search/v1"))
- stubV2 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "//search/v2"))
+ stub := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "search"))
+ stubV1 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "search/v1"))
+ stubV2 := repository.ApplicationClient(naming.JoinAddressName(endpoint.String(), "search/v2"))
// Create example envelopes.
envelopeV1 := application.Envelope{
diff --git a/services/mgmt/binary/impl/impl_test.go b/services/mgmt/binary/impl/impl_test.go
index 886674c..a835440 100644
--- a/services/mgmt/binary/impl/impl_test.go
+++ b/services/mgmt/binary/impl/impl_test.go
@@ -132,7 +132,7 @@
if err := server.ServeDispatcher(dontPublishName, dispatcher); err != nil {
t.Fatalf("Serve(%q) failed: %v", dontPublishName, err)
}
- name := naming.JoinAddressName(endpoint.String(), "//test")
+ name := naming.JoinAddressName(endpoint.String(), "test")
binary := repository.BinaryClient(name)
return binary, fmt.Sprintf("http://%s/test", listener.Addr()), func() {
// Shutdown the binary repository server.
diff --git a/services/mgmt/lib/binary/impl_test.go b/services/mgmt/lib/binary/impl_test.go
index 8da8032..3f79d89 100644
--- a/services/mgmt/lib/binary/impl_test.go
+++ b/services/mgmt/lib/binary/impl_test.go
@@ -54,7 +54,7 @@
if err := server.ServeDispatcher(suffix, dispatcher); err != nil {
t.Fatalf("Serve(%v, %v) failed: %v", suffix, dispatcher, err)
}
- von := naming.JoinAddressName(endpoint.String(), "//test")
+ von := naming.JoinAddressName(endpoint.String(), "test")
return von, func() {
if err := os.Remove(path); err != nil {
t.Fatalf("Remove(%v) failed: %v", path, err)
diff --git a/services/mgmt/logreader/impl/logfile_invoker_test.go b/services/mgmt/logreader/impl/logfile_invoker_test.go
index eb0be9c..5d48e15 100644
--- a/services/mgmt/logreader/impl/logfile_invoker_test.go
+++ b/services/mgmt/logreader/impl/logfile_invoker_test.go
@@ -92,14 +92,14 @@
}
// Try to access a file that doesn't exist.
- lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//doesntexist"))
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "doesntexist"))
_, err = lf.Size(runtime.NewContext())
if expected := verror.NoExist; !verror.Is(err, expected) {
t.Errorf("unexpected error value, got %v, want: %v", err, expected)
}
// Try to access a file that does exist.
- lf = logreader.LogFileClient(naming.JoinAddressName(endpoint, "//"+testFile))
+ lf = logreader.LogFileClient(naming.JoinAddressName(endpoint, testFile))
_, err = lf.Size(runtime.NewContext())
if err != nil {
t.Errorf("Size failed: %v", err)
@@ -174,7 +174,7 @@
"Fix it later",
}
- lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, "//"+testFile))
+ lf := logreader.LogFileClient(naming.JoinAddressName(endpoint, testFile))
_, err = lf.Size(runtime.NewContext())
if err != nil {
t.Errorf("Size failed: %v", err)
diff --git a/services/mgmt/profile/impl/impl_test.go b/services/mgmt/profile/impl/impl_test.go
index 19a6d75..8d0a9e7 100644
--- a/services/mgmt/profile/impl/impl_test.go
+++ b/services/mgmt/profile/impl/impl_test.go
@@ -65,7 +65,7 @@
t.Logf("Profile repository at %v", endpoint)
// Create client stubs for talking to the server.
- stub := repository.ProfileClient(naming.JoinAddressName(endpoint.String(), "//linux/base"))
+ stub := repository.ProfileClient(naming.JoinAddressName(endpoint.String(), "linux/base"))
// Put
if err := stub.Put(ctx, spec); err != nil {
diff --git a/services/mgmt/stats/impl/stats_invoker_test.go b/services/mgmt/stats/impl/stats_invoker_test.go
index 8967cc3..3c33306 100644
--- a/services/mgmt/stats/impl/stats_invoker_test.go
+++ b/services/mgmt/stats/impl/stats_invoker_test.go
@@ -151,7 +151,7 @@
// Test Value()
{
- c := stats.StatsClient(naming.JoinAddressName(endpoint, "//testing/foo/bar"))
+ c := stats.StatsClient(naming.JoinAddressName(endpoint, "testing/foo/bar"))
value, err := c.Value(rt.R().NewContext())
if err != nil {
t.Errorf("unexpected error: %v", err)
@@ -163,7 +163,7 @@
// Test Value() with Histogram
{
- c := stats.StatsClient(naming.JoinAddressName(endpoint, "//testing/hist/foo"))
+ c := stats.StatsClient(naming.JoinAddressName(endpoint, "testing/hist/foo"))
value, err := c.Value(rt.R().NewContext())
if err != nil {
t.Errorf("unexpected error: %v", err)
diff --git a/services/mounttable/lib/mounttable.go b/services/mounttable/lib/mounttable.go
index 7f9b692..e7cfbf1 100644
--- a/services/mounttable/lib/mounttable.go
+++ b/services/mounttable/lib/mounttable.go
@@ -180,18 +180,6 @@
return nil
}
-func slashSlashJoin(elems []string) string {
- // TODO(p): once doubleslash is gone, revisit this. It is just preserving the
- // original double slash.
- if len(elems) == 2 && len(elems[0]) == 0 && len(elems[1]) == 0 {
- return "//"
- }
- if len(elems) > 0 && len(elems[0]) == 0 {
- return "/" + strings.Join(elems, "/")
- }
- return strings.Join(elems, "/")
-}
-
// Authorize verifies that the client has access to the requested node.
// Checks the acls on all nodes in the path starting at the root.
func (ms *mountContext) Authorize(context security.Context) error {
@@ -226,7 +214,7 @@
}
return nil, ms.name, verror.Make(naming.ErrNoSuchName, context, ms.name)
}
- return n.mount.servers.copyToSlice(), slashSlashJoin(elems), nil
+ return n.mount.servers.copyToSlice(), strings.Join(elems, "/"), nil
}
// ResolveStepX returns the next server in a resolution in the form of a MountEntry. The name
@@ -251,7 +239,7 @@
return
}
entry.Servers = n.mount.servers.copyToSlice()
- entry.Name = slashSlashJoin(elems)
+ entry.Name = strings.Join(elems, "/")
entry.MT = n.mount.mt
return
}
@@ -453,7 +441,7 @@
}
servers := n.mount.servers.copyToSlice()
for i, s := range servers {
- servers[i].Server = naming.Join(s.Server, slashSlashJoin(elems))
+ servers[i].Server = naming.Join(s.Server, strings.Join(elems, "/"))
}
stream.SendStream().Send(naming.VDLMountEntry{Name: "", Servers: servers})
}
diff --git a/services/mounttable/lib/mounttable_test.go b/services/mounttable/lib/mounttable_test.go
index db3aa20..7ec967c 100644
--- a/services/mounttable/lib/mounttable_test.go
+++ b/services/mounttable/lib/mounttable_test.go
@@ -225,7 +225,7 @@
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/the/rain"), "the rain", true, rootRT)
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/in/spain"), "in spain", true, rootRT)
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/falls"), "falls mainly on the plain", true, rootRT)
- checkContents(t, naming.JoinAddressName(mtAddr, "mounttable//stuff/falls"), "falls mainly on the plain", false, rootRT)
+ checkContents(t, naming.JoinAddressName(mtAddr, "mounttable//stuff/falls"), "falls mainly on the plain", true, rootRT)
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/nonexistant"), "falls mainly on the plain", false, rootRT)
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/the/rain"), "the rain", true, bobRT)
checkContents(t, naming.JoinAddressName(mtAddr, "mounttable/stuff/the/rain"), "the rain", false, aliceRT)
diff --git a/services/mounttable/mounttabled/mounttable.go b/services/mounttable/mounttabled/mounttable.go
index 0ef7b3b..7234a09 100644
--- a/services/mounttable/mounttabled/mounttable.go
+++ b/services/mounttable/mounttabled/mounttable.go
@@ -77,7 +77,7 @@
vlog.Errorf("NewNeighborhoodServer failed: %v", err)
os.Exit(1)
}
- if err := nhServer.ServeDispatcher(naming.JoinAddressName(myObjectName, "//nh"), nh); err != nil {
+ if err := nhServer.ServeDispatcher(naming.JoinAddressName(myObjectName, "nh"), nh); err != nil {
vlog.Errorf("nhServer.ServeDispatcher failed to register neighborhood: %v", err)
os.Exit(1)
}
diff --git a/services/proxy/proxyd/main.go b/services/proxy/proxyd/main.go
index ebf8a8a..be03702 100644
--- a/services/proxy/proxyd/main.go
+++ b/services/proxy/proxyd/main.go
@@ -47,7 +47,7 @@
publisher := publisher.New(r.NewContext(), r.Namespace(), time.Minute)
defer publisher.WaitForStop()
defer publisher.Stop()
- publisher.AddServer(naming.JoinAddressName(proxy.Endpoint().String(), "//"), false)
+ publisher.AddServer(naming.JoinAddressName(proxy.Endpoint().String(), ""), false)
publisher.AddName(*name)
}
diff --git a/tools/application/impl_test.go b/tools/application/impl_test.go
index ffe8c66..502fb9c 100644
--- a/tools/application/impl_test.go
+++ b/tools/application/impl_test.go
@@ -108,7 +108,7 @@
cmd := root()
var stdout, stderr bytes.Buffer
cmd.Init(nil, &stdout, &stderr)
- appName := naming.JoinAddressName(endpoint.String(), "//myapp/1")
+ appName := naming.JoinAddressName(endpoint.String(), "myapp/1")
profile := "myprofile"
// Test the 'Match' command.
diff --git a/tools/binary/impl_test.go b/tools/binary/impl_test.go
index 073e8f3..16031b6 100644
--- a/tools/binary/impl_test.go
+++ b/tools/binary/impl_test.go
@@ -119,7 +119,7 @@
cmd.Init(nil, &stdout, &stderr)
// Test the 'delete' command.
- if err := cmd.Execute([]string{"delete", naming.JoinAddressName(endpoint.String(), "//exists")}); err != nil {
+ if err := cmd.Execute([]string{"delete", naming.JoinAddressName(endpoint.String(), "exists")}); err != nil {
t.Fatalf("%v", err)
}
if expected, got := "Binary deleted successfully", strings.TrimSpace(stdout.String()); got != expected {
@@ -135,7 +135,7 @@
defer os.Remove(dir)
file := path.Join(dir, "testfile")
defer os.Remove(file)
- if err := cmd.Execute([]string{"download", naming.JoinAddressName(endpoint.String(), "//exists"), file}); err != nil {
+ if err := cmd.Execute([]string{"download", naming.JoinAddressName(endpoint.String(), "exists"), file}); err != nil {
t.Fatalf("%v", err)
}
if expected, got := "Binary downloaded to file "+file, strings.TrimSpace(stdout.String()); got != expected {
@@ -151,7 +151,7 @@
stdout.Reset()
// Test the 'upload' command.
- if err := cmd.Execute([]string{"upload", naming.JoinAddressName(endpoint.String(), "//exists"), file}); err != nil {
+ if err := cmd.Execute([]string{"upload", naming.JoinAddressName(endpoint.String(), "exists"), file}); err != nil {
t.Fatalf("%v", err)
}
}
diff --git a/tools/naming/simulator/ambiguity.scr b/tools/naming/simulator/ambiguity.scr
index df47997..533b34b 100644
--- a/tools/naming/simulator/ambiguity.scr
+++ b/tools/naming/simulator/ambiguity.scr
@@ -17,7 +17,7 @@
#
# "s1/a", ["/s2/b"(mountpoint)]
# "s1/a", ["/s3/c"(mountpoint)]
-# "s1/a", ["/s4//"(mountpoint)]
+# "s1/a", ["/s4"(mountpoint)]
set localaddr="--veyron.tcp.address=127.0.0.1:0"
diff --git a/tools/profile/impl_test.go b/tools/profile/impl_test.go
index a739a15..e24fb92 100644
--- a/tools/profile/impl_test.go
+++ b/tools/profile/impl_test.go
@@ -118,7 +118,7 @@
cmd := root()
var stdout, stderr bytes.Buffer
cmd.Init(nil, &stdout, &stderr)
- exists := naming.JoinAddressName(endpoint.String(), "//exists")
+ exists := naming.JoinAddressName(endpoint.String(), "exists")
// Test the 'label' command.
if err := cmd.Execute([]string{"label", exists}); err != nil {
diff --git a/tools/vrpc/impl_test.go b/tools/vrpc/impl_test.go
index 29954dd..49e94e1 100644
--- a/tools/vrpc/impl_test.go
+++ b/tools/vrpc/impl_test.go
@@ -184,7 +184,7 @@
var stdout, stderr bytes.Buffer
cmd.Init(nil, &stdout, &stderr)
- name := naming.JoinAddressName(endpoint.String(), "//")
+ name := naming.JoinAddressName(endpoint.String(), "")
// Test the 'describe' command.
if err := cmd.Execute([]string{"describe", name}); err != nil {
t.Errorf("%v", err)