support ability to set store, address and namespace via flags and env vars (#1092)

This commit is contained in:
Asim Aslam
2020-01-08 12:11:31 +00:00
committed by GitHub
parent 0b8ff3a8bb
commit 048065fe96
9 changed files with 143 additions and 50 deletions

View File

@@ -96,6 +96,16 @@ func validateOptions(account, token, namespace string) {
}
}
func (w *workersKV) Init(opts ...store.Option) error {
for _, o := range opts {
o(&w.options)
}
if len(w.options.Namespace) > 0 {
w.namespace = w.options.Namespace
}
return nil
}
// In the cloudflare workers KV implemention, List() doesn't guarantee
// anything as the workers API is eventually consistent.
func (w *workersKV) List() ([]*store.Record, error) {
@@ -308,7 +318,7 @@ func NewStore(opts ...store.Option) store.Store {
}
if len(namespace) == 0 {
namespace = getNamespace(options.Context)
namespace = options.Namespace
}
// validate options are not blank or log.Fatal