From 1f8723d01d7694e1a9cfccf28815c2034493af55 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 14 Jul 2017 15:44:48 -0400 Subject: [PATCH] Address p.r. feedback License: MIT Signed-off-by: Kevin Atkinson --- repo/config/init.go | 2 +- repo/fsrepo/config_test.go | 2 +- repo/fsrepo/datastores.go | 3 ++- repo/fsrepo/fsrepo.go | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/repo/config/init.go b/repo/config/init.go index e0470c71d..80923355e 100644 --- a/repo/config/init.go +++ b/repo/config/init.go @@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { return conf, nil } -// DatastoreConfig is an internal function exported to aid in testing. +// DefaultDatastoreConfig is an internal function exported to aid in testing. func DefaultDatastoreConfig() Datastore { return Datastore{ StorageMax: "10GB", diff --git a/repo/fsrepo/config_test.go b/repo/fsrepo/config_test.go index 79fda4c85..de557516b 100644 --- a/repo/fsrepo/config_test.go +++ b/repo/fsrepo/config_test.go @@ -87,7 +87,7 @@ func TestDefaultDatastoreConfig(t *testing.T) { t.Fatal(err) } - expected := `{"mounts":[{"mountpoint":{"string":"/blocks"},"path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":{"string":"/"},"path":"datastore","type":"levelds"}],"type":"mount"}` + expected := `{"mounts":[{"mountpoint":"/blocks","path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"}` if dsc.DiskSpec().String() != expected { t.Errorf("expected '%s' got '%s' as DiskId", expected, dsc.DiskSpec().String()) } diff --git a/repo/fsrepo/datastores.go b/repo/fsrepo/datastores.go index e84f75636..15f203686 100644 --- a/repo/fsrepo/datastores.go +++ b/repo/fsrepo/datastores.go @@ -126,7 +126,7 @@ func (c *mountDatastoreConfig) DiskSpec() DiskSpec { if c == nil { c = make(map[string]interface{}) } - c["mountpoint"] = m.prefix + c["mountpoint"] = m.prefix.String() mounts[i] = c } cfg["mounts"] = mounts @@ -247,6 +247,7 @@ type memDatastoreConfig struct { cfg map[string]interface{} } +// MemDatastoreConfig returns a memory DatastoreConfig from a spec func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) { return &memDatastoreConfig{params}, nil } diff --git a/repo/fsrepo/fsrepo.go b/repo/fsrepo/fsrepo.go index b81052118..0eaa8049c 100644 --- a/repo/fsrepo/fsrepo.go +++ b/repo/fsrepo/fsrepo.go @@ -62,6 +62,8 @@ func (err NoRepoError) Error() string { const apiFile = "api" const swarmKeyFile = "swarm.key" +const specFn = "datastore_spec" + var ( // packageLock must be held to while performing any operation that modifies an @@ -245,7 +247,7 @@ func initConfig(path string, conf *config.Config) error { } func initSpec(path string, conf map[string]interface{}) error { - fn, err := config.Path(path, SpecFn) + fn, err := config.Path(path, specFn) if err != nil { return err } @@ -415,10 +417,8 @@ func (r *FSRepo) openDatastore() error { return nil } -var SpecFn = "datastore_spec" - func (r *FSRepo) readSpec() (string, error) { - fn, err := config.Path(r.path, SpecFn) + fn, err := config.Path(r.path, specFn) if err != nil { return "", err }