Exemplo n.º 1
0
func ConnectToEventStream(conf config.Config) error {

	kClient := kubernetesclient.NewClient(conf.KubernetesURL, false)
	dClient, err := dockerclient.NewDockerClient()
	if err != nil {
		return err
	}
	sh := syncHandler{
		kClient: kClient,
		dClient: dClient,
	}
	ph := PingHandler{}

	eventHandlers := map[string]revents.EventHandler{
		"compute.instance.providelabels": sh.Handler,
		"config.update":                  ph.Handler,
		"ping":                           ph.Handler,
	}

	router, err := revents.NewEventRouter("", 0, conf.CattleURL, conf.CattleAccessKey, conf.CattleSecretKey, nil, eventHandlers, "", conf.WorkerCount)
	if err != nil {
		return err
	}
	err = router.Run(nil)
	return err
}
Exemplo n.º 2
0
func (s *ListenerTestSuite) SetUpSuite(c *check.C) {
	s.publishChan = make(chan client.Publish, 10)

	s.kClient = kubernetesclient.NewClient(conf.KubernetesURL, true)

	mock := &MockPublishOperations{
		publishChan: s.publishChan,
	}
	s.mockRClient = &client.RancherClient{
		Publish: mock,
	}

	dClient, err := dockerclient.NewDockerClient()
	if err != nil {
		c.Fatal(err)
	}
	s.dClient = dClient
}