Esempio n. 1
0
func main() {
	cli.Colors[log.DebugLevel] = 90
	cli.Colors[log.InfoLevel] = 32
	log.SetHandler(cli.New(os.Stdout))

	log.SetLevel(log.DebugLevel)

	cmd.Execute()
}
Esempio n. 2
0
func main() {
	logger := &log.Logger{
		Handler: cli.New(os.Stdout),
		Level:   log.DebugLevel,
	}
	ctx := scope.New()
	ctx.Set("logger", logger)
	b := bot.NewBot(ctx, []proto.Handler{&handlers.PingHandler{}, &handlers.PongHandler{}}, connection.NewWSDialer(ctx.Fork(), fmt.Sprintf(url, "test")))
	if err := b.Run(); err != nil {
		logger.Fatalf("Bot.Run: Fatal error (%s)", err)
	}
}
Esempio n. 3
0
func main() {
	log.SetHandler(cli.New(os.Stdout))
	log.SetLevel(log.DebugLevel)

	s, err := config.LoadConfig(ConfigurationFileName)
	if err != nil {
		log.Warnf("Unable to read configuration file: %s", err.Error())
	}

	d, err := store.Init(s.Location.Database, 2500)
	if err != nil {
		log.Fatalf("Unable to connect to data store at %s: %s", s.Location.Database, err.Error())
	}

	r := gin.New()

	// If redirects to the secure are enabled, attach the secure middleware helper
	if s.Bind.Redirect {
		log.Debug("Secure redirects enabled")
		r.Use(secure.RedirectToSecureByProxy(s.Domain, s.Bind.Ports.Secure, s.Bind.Proxy.Secure))
	}

	r.Use(gin.Logger())
	r.Use(gin.Recovery())
	// Add out own Middleware
	r.Use(store.Connect(d))

	// Connect the relevant modules to the router
	alive.Init(r)

	log.Debug("Starting Run()")
	err = r.Run(s.Bind.Address + ":" + strconv.FormatInt(int64(s.Bind.Ports.Standard), 10))
	if err != nil {
		log.Fatalf("Fatal error during Run: %s", err.Error())
	}

}
Esempio n. 4
0
func TestDockerfileCreation(t *testing.T) {
	log.SetHandler(cli.New(os.Stdout))
	// The 'expected' hash
	expected_hash := "033429aed5b9104f5c8d0a15ed2b9a043ce93a70"

	// First we will read the sample json file
	dat, err := ioutil.ReadFile("test/sample_data.json")
	if err != nil {
		log.WithError(err)
	}
	// We read the sample json data and create a new DockerInfo struct
	var parsed_data DockerInfo
	err = json.Unmarshal(dat, &parsed_data)
	if err != nil {
		log.WithError(err)
	}

	// Pass the DockerInfo struct into the GenerateDockerFile function
	GenerateDockerFile(parsed_data, "test")
	defer os.Remove("test/Dockerfile")

	// Generate a sha1 hash of the generated Dockerfile and compare
	f, err := ioutil.ReadFile("test/Dockerfile")
	if err != nil {
		log.WithError(err)
	}

	generated_hash := sha1.New()
	generated_hash.Write([]byte(f))
	bs := generated_hash.Sum(nil)

	// We would like a hex-encoding string to compare with
	hash_string := hex.EncodeToString(bs[:])

	expect(t, hash_string, expected_hash)
}