@@ -42,26 +42,38 @@ func (p *DDBPlugin) DatastoreConfigParser() fsrepo.ConfigFromMap {
4242 accessKey , _ := m ["accessKey" ].(string )
4343 secretKey , _ := m ["secretKey" ].(string )
4444 region , _ := m ["region" ].(string )
45+ providersTable , _ := m ["providersTable" ].(string )
46+ pinsTable , _ := m ["pinsTable" ].(string )
47+ defaultTable , _ := m ["defaultTable" ].(string )
4548
4649 return & DDBConfig {
47- AccessKey : accessKey ,
48- SecretKey : secretKey ,
49- Region : region ,
50+ AccessKey : accessKey ,
51+ SecretKey : secretKey ,
52+ Region : region ,
53+ ProvidersTable : providersTable ,
54+ PinsTable : pinsTable ,
55+ DefaultTable : defaultTable ,
5056 }, nil
5157 }
5258}
5359
5460type DDBConfig struct {
55- AccessKey string
56- SecretKey string
57- Region string
61+ AccessKey string
62+ SecretKey string
63+ Region string
64+ ProvidersTable string
65+ PinsTable string
66+ DefaultTable string
5867}
5968
6069func (c * DDBConfig ) DiskSpec () fsrepo.DiskSpec {
6170 return fsrepo.DiskSpec {
62- "accessKey" : c .AccessKey ,
63- "secretKey" : c .SecretKey ,
64- "region" : c .Region ,
71+ "accessKey" : c .AccessKey ,
72+ "secretKey" : c .SecretKey ,
73+ "region" : c .Region ,
74+ "providersTable" : c .ProvidersTable ,
75+ "pinsTable" : c .PinsTable ,
76+ "defaultTable" : c .DefaultTable ,
6577 }
6678}
6779
@@ -81,26 +93,23 @@ func (c *DDBConfig) Create(path string) (repo.Datastore, error) {
8193
8294 ddbClient := dynamodb .New (sess )
8395
84- // Mount different namespaces to different tables
96+ // Mount different namespaces to dynamically configured tables
8597 ddbDS := mount .New ([]mount.Mount {
8698 {
87- // Providers datastore with partition & sort keys
8899 Prefix : datastore .NewKey ("/providers" ),
89- Datastore : ddbds .New (ddbClient , "datastore-providers" ,
100+ Datastore : ddbds .New (ddbClient , c . ProvidersTable ,
90101 ddbds .WithPartitionkey ("ContentHash" ), ddbds .WithSortKey ("ProviderID" )),
91102 },
92103 {
93- // Pins datastore (without sort key)
94104 Prefix : datastore .NewKey ("/pins" ),
95- Datastore : ddbds .New (ddbClient , "datastore-pins" ,
105+ Datastore : ddbds .New (ddbClient , c . PinsTable ,
96106 ddbds .WithPartitionkey ("Hash" )),
97107 },
98108 {
99- // Default datastore for everything else
100109 Prefix : datastore .NewKey ("/" ),
101- Datastore : ddbds .New (ddbClient , "datastore-table" ),
110+ Datastore : ddbds .New (ddbClient , c . DefaultTable ),
102111 },
103112 })
104113
105114 return ddbDS , nil
106- }
115+ }
0 commit comments