2015-11-01 15:35:01 +00:00
|
|
|
package provider
|
|
|
|
|
2015-11-13 10:50:32 +00:00
|
|
|
import (
|
2016-07-13 15:18:55 +00:00
|
|
|
"fmt"
|
2016-04-13 18:36:23 +00:00
|
|
|
"github.com/containous/traefik/safe"
|
2016-02-24 15:43:39 +00:00
|
|
|
"github.com/containous/traefik/types"
|
2015-11-13 10:50:32 +00:00
|
|
|
"github.com/docker/libkv/store"
|
|
|
|
"github.com/docker/libkv/store/boltdb"
|
|
|
|
)
|
2015-10-01 10:04:25 +00:00
|
|
|
|
2016-08-16 17:13:18 +00:00
|
|
|
var _ Provider = (*BoltDb)(nil)
|
|
|
|
|
2015-11-01 18:29:47 +00:00
|
|
|
// BoltDb holds configurations of the BoltDb provider.
|
2015-11-02 18:48:34 +00:00
|
|
|
type BoltDb struct {
|
2016-06-24 07:58:42 +00:00
|
|
|
Kv `mapstructure:",squash"`
|
2015-10-01 10:04:25 +00:00
|
|
|
}
|
|
|
|
|
2015-11-01 18:29:47 +00:00
|
|
|
// Provide allows the provider to provide configurations to traefik
|
|
|
|
// using the given configuration channel.
|
2016-05-31 07:54:42 +00:00
|
|
|
func (provider *BoltDb) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints []types.Constraint) error {
|
2016-07-13 15:18:55 +00:00
|
|
|
store, err := provider.CreateStore()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("Failed to Connect to KV store: %v", err)
|
|
|
|
}
|
|
|
|
provider.kvclient = store
|
|
|
|
return provider.provide(configurationChan, pool, constraints)
|
|
|
|
}
|
|
|
|
|
|
|
|
// CreateStore creates the KV store
|
|
|
|
func (provider *BoltDb) CreateStore() (store.Store, error) {
|
2016-01-13 21:46:44 +00:00
|
|
|
provider.storeType = store.BOLTDB
|
2015-11-13 10:50:32 +00:00
|
|
|
boltdb.Register()
|
2016-07-13 15:18:55 +00:00
|
|
|
return provider.createStore()
|
2015-10-01 10:04:25 +00:00
|
|
|
}
|