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wa4Ugp4Xa5BpHqu8qIAE2JUZ7bU
t88aQAYE58pUF+/Lq1QzAQdrjjzQBx6SrBxieecCgYEAvukoPZEC8mmiN1VvbTX+
QFHmlZha3QaDxChB+QUe7bMRojEUL/fVnzkTOLuVFqSfxevaI/km9n0ac5KtAchV
xjp2bTnBb5EUQFqjopYktWA+xO07JRJtMfSEmjZPbbay1kKC7rdTfBm961EIHaRj
xZUf6M+rOE8964oGrdgdLlECgYEA046GQmx6fh7/82FtdZDRQp9tj3SWQUtSiQZc
qhO59Lq8mjUXz+MgBuJXxkiwXRpzlbaFB0Bca1fUoYw8o915SrDYf/Zu2OKGQ/qa
V81sgiVmDuEgycR7YOlbX6OsVUHrUlpwhY3hgfMe6UtkMvhBvHF/WhroBEIJm1pV
PXZ/CbMCgYEApNWVktFBjOaYfY6SNn4iSts1jgsQbbpglg3kT7PLKjCAhI6lNsbk
dyT7ut01PL6RaW4SeQWtrJIVQaM6vF3pprMKqlc5XihOGAmVqH7rQx9rtQB5TicL
BFrwkQE4HQtQBV60hYQUzzlSk44VFDz+jxIEtacRHaomDRh2FtOTz+I=
-----END RSA PRIVATE KEY-----
`
	certFile, err := ioutil.TempFile("", "cert")
	assert.Nil(t, err)
	defer os.Remove(certFile.Name())
	certFile.Write([]byte(cert))
	certFile.Close()
	keyFile, err := ioutil.TempFile("", "key")
	assert.Nil(t, err)
	defer os.Remove(keyFile.Name())
	keyFile.Write([]byte(key))
	keyFile.Close()

	libkv.AddStore("mock", libkvmock.New)
	d := &Discovery{backend: "mock"}
	err = d.Initialize("127.0.0.3:1234", 0, 0, map[string]string{
		"kv.cacertfile": certFile.Name(),
		"kv.certfile":   certFile.Name(),
		"kv.keyfile":    keyFile.Name(),
	})
	assert.Nil(t, err)
	s := d.store.(*libkvmock.Mock)
	assert.Equal(t, s.Options.ClientTLS.CACertFile, certFile.Name())
	assert.Equal(t, s.Options.ClientTLS.CertFile, certFile.Name())
	assert.Equal(t, s.Options.ClientTLS.KeyFile, keyFile.Name())
}
예제 #2
0
파일: etcd.go 프로젝트: MiLk/swarm
// Register registers etcd to libkv
func Register() {
	libkv.AddStore(store.ETCD, New)
}
예제 #3
0
파일: consul.go 프로젝트: MiLk/swarm
// Register registers consul to libkv
func Register() {
	libkv.AddStore(store.CONSUL, New)
}
예제 #4
0
// Register registers zookeeper to libkv
func Register() {
	libkv.AddStore(store.ZK, New)
}
예제 #5
0
파일: boltdb.go 프로젝트: rkazak/swarm
// Register registers boltdb to libkv
func Register() {
	libkv.AddStore(store.BOLTDB, New)
}
예제 #6
0
파일: store.go 프로젝트: luizbafilho/fusis
func registryStores() {
	libkv.AddStore(kv.CONSUL, consul.New)
	libkv.AddStore(kv.ETCD, etcd.New)
}