Commit 1f8723d0 authored by Kevin Atkinson's avatar Kevin Atkinson Committed by Jeromy

Address p.r. feedback

License: MIT
Signed-off-by: default avatarKevin Atkinson <k@kevina.org>
parent 6438fc74
...@@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) { ...@@ -76,7 +76,7 @@ func Init(out io.Writer, nBitsForKeypair int) (*Config, error) {
return conf, nil 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 { func DefaultDatastoreConfig() Datastore {
return Datastore{ return Datastore{
StorageMax: "10GB", StorageMax: "10GB",
......
...@@ -87,7 +87,7 @@ func TestDefaultDatastoreConfig(t *testing.T) { ...@@ -87,7 +87,7 @@ func TestDefaultDatastoreConfig(t *testing.T) {
t.Fatal(err) 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 { if dsc.DiskSpec().String() != expected {
t.Errorf("expected '%s' got '%s' as DiskId", expected, dsc.DiskSpec().String()) t.Errorf("expected '%s' got '%s' as DiskId", expected, dsc.DiskSpec().String())
} }
......
...@@ -126,7 +126,7 @@ func (c *mountDatastoreConfig) DiskSpec() DiskSpec { ...@@ -126,7 +126,7 @@ func (c *mountDatastoreConfig) DiskSpec() DiskSpec {
if c == nil { if c == nil {
c = make(map[string]interface{}) c = make(map[string]interface{})
} }
c["mountpoint"] = m.prefix c["mountpoint"] = m.prefix.String()
mounts[i] = c mounts[i] = c
} }
cfg["mounts"] = mounts cfg["mounts"] = mounts
...@@ -247,6 +247,7 @@ type memDatastoreConfig struct { ...@@ -247,6 +247,7 @@ type memDatastoreConfig struct {
cfg map[string]interface{} cfg map[string]interface{}
} }
// MemDatastoreConfig returns a memory DatastoreConfig from a spec
func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) { func MemDatastoreConfig(params map[string]interface{}) (DatastoreConfig, error) {
return &memDatastoreConfig{params}, nil return &memDatastoreConfig{params}, nil
} }
......
...@@ -62,6 +62,8 @@ func (err NoRepoError) Error() string { ...@@ -62,6 +62,8 @@ func (err NoRepoError) Error() string {
const apiFile = "api" const apiFile = "api"
const swarmKeyFile = "swarm.key" const swarmKeyFile = "swarm.key"
const specFn = "datastore_spec"
var ( var (
// packageLock must be held to while performing any operation that modifies an // packageLock must be held to while performing any operation that modifies an
...@@ -245,7 +247,7 @@ func initConfig(path string, conf *config.Config) error { ...@@ -245,7 +247,7 @@ func initConfig(path string, conf *config.Config) error {
} }
func initSpec(path string, conf map[string]interface{}) 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 { if err != nil {
return err return err
} }
...@@ -415,10 +417,8 @@ func (r *FSRepo) openDatastore() error { ...@@ -415,10 +417,8 @@ func (r *FSRepo) openDatastore() error {
return nil return nil
} }
var SpecFn = "datastore_spec"
func (r *FSRepo) readSpec() (string, error) { func (r *FSRepo) readSpec() (string, error) {
fn, err := config.Path(r.path, SpecFn) fn, err := config.Path(r.path, specFn)
if err != nil { if err != nil {
return "", err return "", err
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment