Exemple #1
0
// PrintEtcd print etcd key/values from remote etcd
func PrintEtcd(context *cli.Context) {
	namespace := context.GlobalString("namespace")
	etcdURI := context.GlobalString("etcd-uri")
	useTable := context.Bool("table")

	etcdClient, err := etcd.Dial(etcdURI, nil)
	FatalIfError("etcd.Dial", err)

	keyValues, err := etcdClient.KeyValuePairs(namespace)
	FatalIfError("etcdClient.KeyValuePairs", err)

	printKeyValuePairs(useTable, keyValues)
}
Exemple #2
0
// Load dumps remote etcd pairs into the local filesystem
func Load(context *cli.Context) {
	namespace := context.GlobalString("namespace")
	localPath := context.GlobalString("local-path")
	etcdURI := context.GlobalString("etcd-uri")
	includeDirs := context.Bool("include-directories")

	localEtcdFS := fs.New(localPath)
	keyValues, err := localEtcdFS.KeyValuePairs(namespace, includeDirs)
	FatalIfError("localEtcdFS.KeyValuePairs", err)

	etcdClient, err := etcd.Dial(etcdURI, nil)
	FatalIfError("etcd.Dial", err)
	err = etcdClient.SetAll(keyValues)
	FatalIfError("etcdClient.SetAll", err)

	os.Exit(0)
}
Exemple #3
0
// Dump dumps remote etcd pairs into the local filesystem
func Dump(context *cli.Context) {
	namespace := context.GlobalString("namespace")
	localPath := context.GlobalString("local-path")
	etcdURI := context.GlobalString("etcd-uri")

	etcdClient, err := etcd.Dial(etcdURI, nil)
	FatalIfError("etcd.Dial", err)

	keyValues, err := etcdClient.KeyValuePairs(namespace)
	FatalIfError("etcdClient.KeyValuePairs", err)

	localEtcdFS := fs.New(localPath)
	err = localEtcdFS.SetAll(keyValues)
	FatalIfError("localEtcdFS.SetAll", err)

	os.Exit(0)
}
Exemple #4
0
	. "github.com/onsi/gomega"
)

var _ = Describe("Etcd", func() {
	var sut *etcd.Etcd
	var err error
	var fakeClient *FakeClient

	BeforeEach(func() {
		fakeClient = NewFakeClient()
	})

	Describe("Dial", func() {
		Describe("When etcdclient.Dial returns a client", func() {
			BeforeEach(func() {
				sut, err = etcd.Dial("http://somewhere:1111", ThisFakeClient(fakeClient))
			})

			It("Should not return an error", func() {
				Expect(err).To(BeNil())
			})

			It("Should return a client", func() {
				Expect(sut).NotTo(BeNil())
			})
		})
	})

	Describe("With a sut", func() {
		BeforeEach(func() {
			sut, _ = etcd.Dial("http://somewhere:1111", ThisFakeClient(fakeClient))