mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Updates to fix against Titan changes and what not.
This commit is contained in:
26
api/config/config.go
Normal file
26
api/config/config.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func InitConfig() {
|
||||
cwd, _ := os.Getwd()
|
||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
viper.SetDefault("log_level", "info")
|
||||
viper.SetDefault("db", fmt.Sprintf("bolt://%s/data/bolt.db?bucket=funcs", cwd))
|
||||
viper.SetConfigName("config")
|
||||
viper.AddConfigPath(".")
|
||||
viper.AutomaticEnv() // picks up env vars automatically
|
||||
viper.ReadInConfig()
|
||||
logLevel, err := log.ParseLevel(viper.GetString("log_level"))
|
||||
if err != nil {
|
||||
log.WithError(err).Fatalln("Invalid log level.")
|
||||
}
|
||||
log.SetLevel(logLevel)
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/iron-io/titan/common"
|
||||
"github.com/iron-io/titan/runner/agent"
|
||||
"github.com/iron-io/titan/runner/drivers"
|
||||
driverscommon "github.com/iron-io/titan/runner/drivers/common"
|
||||
driverscommon "github.com/iron-io/titan/runner/drivers"
|
||||
"github.com/iron-io/titan/runner/drivers/docker"
|
||||
"github.com/iron-io/titan/runner/drivers/mock"
|
||||
)
|
||||
@@ -82,7 +82,7 @@ func (r Runner) Status() string {
|
||||
func selectDriver(driver string, env *common.Environment, conf *driverscommon.Config) (drivers.Driver, error) {
|
||||
switch driver {
|
||||
case "docker":
|
||||
docker := docker.NewDocker(env, conf)
|
||||
docker := docker.NewDocker(env, *conf)
|
||||
return docker, nil
|
||||
case "mock":
|
||||
return mock.New(), nil
|
||||
|
||||
@@ -74,11 +74,13 @@ func handleRunner(c *gin.Context) {
|
||||
if err != nil {
|
||||
log.WithError(err).Error(models.ErrRoutesList)
|
||||
c.JSON(http.StatusInternalServerError, simpleError(models.ErrRoutesList))
|
||||
return
|
||||
}
|
||||
|
||||
if routes == nil || len(routes) == 0 {
|
||||
log.WithError(err).Error(models.ErrRunnerRouteNotFound)
|
||||
c.JSON(http.StatusNotFound, simpleError(models.ErrRunnerRouteNotFound))
|
||||
return
|
||||
}
|
||||
|
||||
log.WithField("routes", routes).Debug("Got routes from datastore")
|
||||
|
||||
Reference in New Issue
Block a user