Address p.r. feedback
License: MIT Signed-off-by: Kevin Atkinson <k@kevina.org>
Kevin Atkinson committed
Jul 14, 2017 at 15:44 UTC
1f8723d01d7694e1a9cfccf28815c2034493af55
4 files changed
+8
-7
repo/config/init.go
+1
-1
@@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
76
return conf, nil
77
}
78
79
-// DatastoreConfig is an internal function exported to aid in testing.
79
+// DefaultDatastoreConfig is an internal function exported to aid in testing.
80
func DefaultDatastoreConfig() Datastore {
81
return Datastore{
82
StorageMax: "10GB",
repo/fsrepo/config_test.go
+1
-1
@@ -87,7 +87,7 @@ func TestDefaultDatastoreConfig(t *testing.T) {
87
t.Fatal(err)
88
}
89
90
- 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"}`
90
+ expected := `{"mounts":[{"mountpoint":"/blocks","path":"blocks","shardFunc":"/repo/flatfs/shard/v1/next-to-last/2","type":"flatfs"},{"mountpoint":"/","path":"datastore","type":"levelds"}],"type":"mount"}`
91
if dsc.DiskSpec().String() != expected {
92
t.Errorf("expected '%s' got '%s' as DiskId", expected, dsc.DiskSpec().String())
93
}
repo/fsrepo/datastores.go
+2
-1
@@ -126,7 +126,7 @@ func (c *mountDatastoreConfig) DiskSpec() DiskSpec {
126
if c == nil {
127
c = make(map[string]interface{})
128
}
129
- c["mountpoint"] = m.prefix
129
+ c["mountpoint"] = m.prefix.String()
130
mounts[i] = c
131
}
132
cfg["mounts"] = mounts
@@ -247,6 +247,7 @@ type memDatastoreConfig struct {
247
cfg map[string]interface{}
248
}
249
250
+// MemDatastoreConfig returns a memory DatastoreConfig from a spec
251
func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
252
return &memDatastoreConfig{params}, nil
253
}
repo/fsrepo/fsrepo.go
+4
-4
@@ -62,6 +62,8 @@ func (err NoRepoError) Error() string {
62
const apiFile = "api"
63
const swarmKeyFile = "swarm.key"
64
65
+const specFn = "datastore_spec"
66
+
67
var (
68
69
// packageLock must be held to while performing any operation that modifies an
@@ -245,7 +247,7 @@ func initConfig(path string, conf *config.Config) error {
247
}
248
249
func initSpec(path string, conf map[string]interface{}) error {
248
- fn, err := config.Path(path, SpecFn)
250
+ fn, err := config.Path(path, specFn)
251
if err != nil {
252
return err
253
}
@@ -415,10 +417,8 @@ func (r *FSRepo) openDatastore() error {
417
return nil
418
}
419
418
-var SpecFn = "datastore_spec"
419
-
420
func (r *FSRepo) readSpec() (string, error) {
421
- fn, err := config.Path(r.path, SpecFn)
421
+ fn, err := config.Path(r.path, specFn)
422
if err != nil {
423
return "", err
424
}