From 45deffe50ea5823bd59c1d3ef412a4aac7c93402 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Wed, 20 May 2015 14:32:23 -0700 Subject: [PATCH] go-ipfs-config: S3 datastore support To test it, set up an S3 bucket (in an AWS region that is not US Standard, for read-after-write consistency), run `ipfs init`, then edit `~/.ipfs/config` to say "Datastore": { "Type": "s3", "Region": "us-west-1", "Bucket": "mahbukkit", "ACL": "private" }, with the right values. Set `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` in the environment and you should be able to run `ipfs add` and `ipfs cat` and see the bucket be populated. No automated tests exist, unfortunately. S3 is thorny to simulate. License: MIT Signed-off-by: Tommi Virtanen --- config/datastore.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/config/datastore.go b/config/datastore.go index 6749a4c39..89ded36f1 100644 --- a/config/datastore.go +++ b/config/datastore.go @@ -1,5 +1,9 @@ package config +import ( + "encoding/json" +) + // DefaultDataStoreDirectory is the directory to store all the local IPFS data. const DefaultDataStoreDirectory = "datastore" @@ -10,6 +14,22 @@ type Datastore struct { StorageMax string // in B, kB, kiB, MB, ... StorageGCWatermark int64 // in percentage to multiply on StorageMax GCPeriod string // in ns, us, ms, s, m, h + + Params *json.RawMessage +} + +func (d *Datastore) ParamData() []byte { + if d.Params == nil { + return nil + } + + return []byte(*d.Params) +} + +type S3Datastore struct { + Region string `json:"region"` + Bucket string `json:"bucket"` + ACL string `json:"acl"` } // DataStorePath returns the default data store path given a configuration root