Adding export Init method for the exported discovery components

Since Swarm discovery is used by libnetwork without the swarm main(), it
is forced to use annonymous import in order to force-trigger the
unexported init() methods. Using annonymous import is highly discouraged
in a Non-Main and Non-Test packages.

Introducing exported Init() methods on these files so that libnetwork
can use Discovery as a library without having a main package.

Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
Madhu Venugopal 2015-05-20 20:03:48 -07:00
parent c1494dd076
commit 23ecada9d7
4 changed files with 20 additions and 0 deletions

View File

@ -16,6 +16,11 @@ type Discovery struct {
}
func init() {
Init()
}
// Init is exported
func Init() {
discovery.Register("file", &Discovery{})
}

View File

@ -21,6 +21,11 @@ type Discovery struct {
}
func init() {
Init()
}
// Init is exported
func Init() {
discovery.Register("zk", &Discovery{backend: store.ZK})
discovery.Register("consul", &Discovery{backend: store.CONSUL})
discovery.Register("etcd", &Discovery{backend: store.ETCD})

View File

@ -13,6 +13,11 @@ type Discovery struct {
}
func init() {
Init()
}
// Init is exported
func Init() {
discovery.Register("nodes", &Discovery{})
}

View File

@ -24,6 +24,11 @@ type Discovery struct {
}
func init() {
Init()
}
// Init is exported
func Init() {
discovery.Register("token", &Discovery{})
}