Esempio n. 1
0
func Test_WebServiceRoutes(t *testing.T) {
	builder, _ := docker.NewBuilder(
		"127.0.0.1",
		false,
		"/tmp",
		"127.0.0.1:5000",
		&docker.Authentication{
			Username: "",
			Password: "",
			Email:    "",
		},
		&pubsub.Config{Type: pubsub.ZEROMQ})
	ws := GetWebService(builder)
	// fmt.Printf("Routes : %#v", ws.Routes())
	routes := ws.Routes()
	if len(routes) != 5 {
		t.Fatalf("Invalid routes. : %v", routes)
	}
	for _, route := range ws.Routes() {
		if api[route.Path] != route.Method {
			t.Fatalf("Unknown route. : %v", route)
		}
	}
}
Esempio n. 2
0
func main() {
	setupLogging(debug)
	if showVersion {
		fmt.Printf("Warhol v%s\n", version.Version)
		return
	}

	// Messaging
	log.Print("[DEBUG] [warhol] Creates the pubsub messaging")
	var brokerConf pubsub.Config
	if messaging == pubsub.REDIS && len(redisHost) > 0 {
		brokerConf = pubsub.Config{
			Type: pubsub.REDIS,
			Host: redisHost,
		}
	} else if messaging == pubsub.ZEROMQ {
		brokerConf = pubsub.Config{
			Type: pubsub.ZEROMQ,
		}
	} else {
		fmt.Printf("Warhol: Please specify messaging system\n")
		return
	}

	// Builder
	log.Print("[INFO] [warhol] Creates the Docker builder")
	builder, err := docker.NewBuilder(
		dockerHost,
		dockerTLSVerify,
		dockerCertPath,
		registryURL,
		&docker.Authentication{
			Username: registryUsername,
			Password: registryPassword,
			Email:    registryEmail,
		},
		&brokerConf)
	if err != nil {
		log.Printf("[FATAL] [warhol] Error with Docker : %v", err)
		return
	}
	e := api.GetWebService(builder)

	// Services
	ircBot, err := irc.NewPublisher(
		&irc.Config{
			Server:   ircServer,
			Channel:  ircChannel,
			Username: ircUser,
			Nickname: ircNickname,
			Password: ircPassword,
		},
		&brokerConf,
		debug)
	if err != nil {
		log.Printf("[FATAL] [warhol] %v", err)
		return
	}
	// Launch
	if debug {
		e.Debug()
		builder.Debug()
	}
	go builder.Build()
	go builder.Push()
	go ircBot.Run()
	log.Printf("[INFO] [warhol] Warhol is on %s", port)
	e.Run(fmt.Sprintf(":%s", port))
}