Ejemplo n.º 1
0
func assembleConfigFiles(configFile string) (map[string]interface{}, error) {
	logs.Info("Reading config file : %s", configFile)
	doc, err := yaml.ReadFile(configFile)
	if err != nil {
		return nil, err
	}

	mapping := YamlUnmarshal(doc.Root).(map[string]interface{})

	confD_path := path.Dir(configFile) + "/conf.d/*.yaml"
	logs.Info("Reading config folder : %s", confD_path)
	entries, err := filepath.Glob(confD_path)
	if err != nil {
		logs.Warn("Can't read relevant conf.d: %s", err)
	} else {
		for _, path := range entries {
			logs.Info("Reading config file : %s", path)
			doc, err := yaml.ReadFile(path)
			if err != nil {
				logs.Warn("Can't read relevant conf.d: %s", err)
			} else {
				inner := YamlUnmarshal(doc.Root).(map[string]interface{})
				RecursiveMergeNoConflict(mapping, inner, "")
			}
		}
	}
	return mapping, nil
}
Ejemplo n.º 2
0
func ReadConfig(filename string) (*Config, error) {
	config, err := yaml.ReadFile(filename)
	if err != nil {
		return nil, err
	}
	return ParseConfig(config)
}
Ejemplo n.º 3
0
func init() {
	Objects = make(map[string]*Object)
	Keys = []string{}
	file, _ := yaml.ReadFile("models/variant/data.yml")

	for key, node := range file.Root.(yaml.Map) {
		name := node.(yaml.Map)["name"].(yaml.Scalar).String()

		source, err := ioutil.ReadFile(fmt.Sprintf("models/variant/data/%s", key))
		snippet := ""
		if err == nil {
			snippet = string(source[:])
		}

		variants := []string{}
		variants = append(variants, key)
		if list, ok := node.(yaml.Map)["variants"]; ok {
			for _, variant := range list.(yaml.List) {
				variants = append(variants, variant.(yaml.Scalar).String())
			}
		}

		Objects[key] = &Object{key, name, snippet, variants, []*Option{}}
		Keys = append(Keys, key)
	}
}
Ejemplo n.º 4
0
func LoadConf() {
	var err error
	conf, err = yaml.ReadFile("botconf.yaml")
	if err != nil {
		log.Panic(err)
	}
	Categories = List2SliceInConf("catagoris")
	CategoriesSet = set.New(set.NonThreadSafe)
	Groups = []Group{}
	for _, v := range Categories {
		CategoriesSet.Add(v)
		for _, i := range List2SliceInConf(v) {
			reg := regexp.MustCompile("^(.+) (http(s)?://(.*))$")
			strs := reg.FindAllStringSubmatch(i, -1)
			if !reg.MatchString(i) {
				Groups = append(Groups,
					Group{GroupName: i,
						GroupURL: ""})
			}
			if len(strs) > 0 {
				Groups = append(Groups,
					Group{GroupName: strs[0][1],
						GroupURL: strs[0][2]})
			}
		}
	}
}
Ejemplo n.º 5
0
// init function, load the configs
// fill english_ignore_words_map
func init() {
	// load config file
	cfg_filename := "config.yaml"
	config, err := yaml.ReadFile(cfg_filename)
	if err != nil {
		log.Fatalf("readfile(%s): %s", cfg_filename, err)
	}

	// get english ignore entire string
	english_ignore, err := config.Get("english_ignore")
	if err != nil {
		log.Fatalf("%s parse error: %s\n", english_ignore, err)
	}

	// get each separated words
	english_ignore_words_list := strings.Fields(english_ignore)
	for _, word := range english_ignore_words_list {
		word = strings.TrimSpace(word)
		english_ignore_words_map[word] = 1
	}

	// get redis connection info
	redis_config, err := yaml.Child(config.Root, "redis_server")
	if err != nil {
		log.Fatalf("redis config parse error: %s\n", err)
	}

	redis_config_m := redis_config.(yaml.Map)
	host, port := redis_config_m["host"], redis_config_m["port"]
	redis_conn, err = redis.Dial("tcp", fmt.Sprintf("%s:%s", host, port))
	//defer redis_conn.Close()
	if err != nil {
		log.Fatalf("Can not connect to Redis Server: %s", err)
	}
}
Ejemplo n.º 6
0
func MakeFileInfo(path, ns, name string) *FileInfo {
	file, err := yaml.ReadFile(filepath.Join(path, ns, name, "index.yaml"))
	if err != nil {
		return nil
	}
	return yamlToInfo(ns, name, file.Root)
}
Ejemplo n.º 7
0
func LoadConfig() {
	configPath := flag.String("config", "./config.yml", "config file path")
	port := flag.String("port", "default", "port to bind to")
	duration := flag.Int64("duration", 0, "duration to operation on")
	cpuprofile := flag.Bool("cpuprofile", false, "write cpu profile to file")
	flag.Parse()

	absolutePath, _ := filepath.Abs(*configPath)
	c, err := yaml.ReadFile(absolutePath)
	if err != nil {
		panic(err)
	}
	root, _ := c.Get("root")
	if *port == "default" {
		*port, _ = c.Get("port")
	}
	numRetentions, _ := c.Count("retentions")
	retentions := make([]Retention, numRetentions)
	for i := 0; i < numRetentions; i++ {
		retention, _ := c.Get("retentions[" + strconv.Itoa(i) + "]")
		parts := strings.Split(retention, " ")
		d, _ := strconv.ParseInt(parts[0], 0, 64)
		n, _ := strconv.ParseInt(parts[1], 0, 64)
		retentions[i] = Retention{d, n, d * n}
	}
	p, _ := c.Get("redis.port")
	redisPort, _ := strconv.Atoi(p)
	redisHost, _ := c.Get("redis.host")
	Config = Configuration{*port, root, retentions, redisHost, redisPort, *duration}

	ProfileCPU = *cpuprofile
}
Ejemplo n.º 8
0
func newDataSourceFromPath(path string) *DataSource {
	file, _ := yaml.ReadFile(path)
	fName := filepath.Base(path)
	extName := filepath.Ext(path)
	bName := fName[:len(fName)-len(extName)]
	id := bName

	name, _ := file.Get("name")
	length, _ := file.Count("webhooks")
	if length < 0 {
		length = 0
	}
	webhooks := make([]string, length)
	for i := 0; i < length; i++ {
		it := strconv.Itoa(i)
		webhooks[i], _ = file.Get("webhooks[" + it + "]")
	}
	dataSource := new(DataSource)
	dataSource.ID = id
	dataSource.Name = name
	dataSource.Webhooks = webhooks
	dataSource.propagateTimedEvent = make(chan TimedEvent)
	dataSource.registerPersistor = make(chan *Persistor)
	dataSource.registerConnection = make(chan *connection)
	dataSource.unregisterConnection = make(chan *connection)
	dataSource.persistors = make(map[*Persistor]bool)
	dataSource.connections = make(map[*connection]bool)
	return dataSource
}
Ejemplo n.º 9
0
func main() {
	// parse config file
	file := "config.yaml"
	config, err := yaml.ReadFile(file)
	if err != nil {
		log.Fatal("Error load config", err)
	}

	wsaddr, _ = config.Get("ws.address")
	zmqaddr, _ = config.Get("zmq.address")
	zmqsubject, _ = config.Get("zmq.subject")

	// connect to ZMQ broker
	responder, _ = zmq.NewSocket(zmq.SUB)
	defer responder.Close()
	responder.Connect(zmqaddr)
	responder.SetSubscribe(zmqsubject)

	// start handle ws
	http.HandleFunc("/ws", handler)
	err = http.ListenAndServe(wsaddr, nil)
	if err != nil {
		log.Fatal("ListenAndServe: ", err)
	}
}
Ejemplo n.º 10
0
// Attempts to read from the passed in filename and creates a SQLconf as described therin.
// Retruns the DefaultSQLConf if the file cannot be found, or an error
// if one arises during the process of parsing the configuration file.
func GetSQLConfFromFile(filename string) (*SQLConf, error) {
	DefaultSQLConf := sqlConfFromEnv()
	configPath := path.Join(filename)
	_, err := os.Stat(configPath)

	if err != nil && os.IsNotExist(err) {
		return DefaultSQLConf, nil
	} else {

		// Defaults to development environment, you can override
		// by changing the $GO_ENV variable:
		// `$ export GO_ENV=environment` (where environment
		// can be "production", "test", "staging", etc.)
		// TODO: Potentially find a better solution to handling environments
		// Perhaps: https://github.com/adeven/goenv ?
		goEnv := os.Getenv("GO_ENV")
		if goEnv == "" {
			goEnv = "development"
		}

		config, readYamlErr := yaml.ReadFile(configPath)
		if readYamlErr != nil {
			return nil, readYamlErr
		}

		return confFromYamlFile(config, goEnv)
	}

	return nil, err
}
func main() {
	config, err := yaml.ReadFile("conf.yaml")
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(config.Get("path"))
	fmt.Println(config.GetBool("enabled"))
}
Ejemplo n.º 12
0
// 获取配置信息
func GetConfig(configFile string, env string) (map[string]string, map[string]map[string]string) {

	// 装在配置文件对象
	file := flag.String("file", configFile, "(Simple) YAML file to read")

	// 读取配置文件内容
	configHandle, err := yaml.ReadFile(*file)

	if err != nil {
		log.Fatalf("readfile %q: %s", *file, err)
	}

	serviceTotal, err := configHandle.Count("services")

	mainConfig := make(map[string]string)
	serviceConfig := map[string]map[string]string{}

	for i := 0; i < serviceTotal; i++ {
		serviceConf := make(map[string]string)

		// 循环获取Service配置字段值.
		for key, defaultVal := range serviceFieldNames {
			serviceVal, err := configHandle.Get("services[" + fmt.Sprintf("%d", i) + "]." + key)
			if err != nil {
				serviceVal = defaultVal
			}

			if serviceVal == "" && defaultVal != "" {
				serviceVal = defaultVal
			}

			serviceConf[key] = serviceVal
		}

		serviceConfig[serviceConf["name"]] = serviceConf
	}

	// 获取Env环境变量.
	for key, defaultVal := range configFieldName {
		configVal, err := configHandle.Get(key)
		if err != nil {
			if key == "env" {
				mainConfig[key] = env
			} else {
				mainConfig[key] = defaultVal
			}
		} else {
			if key == "env" {
				env = configVal
			}
			mainConfig[key] = configVal
		}
	}

	log.Printf("current ENV: %s", env)

	return mainConfig, serviceConfig
}
Ejemplo n.º 13
0
func LoadConf() {
	var err error
	conf, err = yaml.ReadFile("botconf.yaml")
	if err != nil {
		log.Panic(err)
	}
	turingAPI, _ = conf.Get("turingBotKey")
	ydTransAPI, _ = conf.Get("yandexTransAPI")
}
Ejemplo n.º 14
0
func NewDBConf(conf, p, env string) (*DBConf, error) {
	if !filepath.IsAbs(conf) {
		dir, file := filepath.Split(conf)
		if dir == "" {
			// Path is neither relative nor absolute (just filename)
			conf = filepath.Join(p, file)
		}
	}

	f, err := yaml.ReadFile(conf)
	if err != nil {
		return nil, err
	}

	drv, err := f.Get(fmt.Sprintf("%s.driver", env))
	if err != nil {
		return nil, err
	}

	open, err := f.Get(fmt.Sprintf("%s.open", env))
	if err != nil {
		return nil, err
	}
	open = os.ExpandEnv(open)

	// Automatically parse postgres urls
	if drv == "postgres" {

		// Assumption: If we can parse the URL, we should
		if parsedURL, err := pq.ParseURL(open); err == nil && parsedURL != "" {
			open = parsedURL
		}
	}

	d := newDBDriver(drv, open)

	// allow the configuration to override the Import for this driver
	if imprt, err := f.Get(fmt.Sprintf("%s.import", env)); err == nil {
		d.Import = imprt
	}

	// allow the configuration to override the Dialect for this driver
	if dialect, err := f.Get(fmt.Sprintf("%s.dialect", env)); err == nil {
		d.Dialect = dialectByName(dialect)
	}

	if !d.IsValid() {
		return nil, errors.New(fmt.Sprintf("Invalid DBConf: %v", d))
	}

	return &DBConf{
		MigrationsDir: filepath.Join(p, "migrations"),
		Env:           env,
		Driver:        d,
	}, nil
}
Ejemplo n.º 15
0
/**
 * Main program.
 */
func main() {
	log.Print("Starting up concentrator")

	var file string = "config.yml"
	log.Print("Loading config file: ", file)

	config, err := yaml.ReadFile("config.yml")
	if err != nil {
		log.Fatalf("Error reading config.yml (%q): %s", file, err)
	}

	// Get the backends config list.
	servers, err := yaml.Child(config.Root, "backends")
	server_lst, ok := servers.(yaml.List)
	if !ok {
		log.Fatalf("Could not parse backends list")
		return
	}

	// Load the stats backends.
	for i := 0; i < server_lst.Len(); i++ {
		node := server_lst.Item(i)
		vals := node.(yaml.Map)

		for index, element := range vals {
			backend_host := fmt.Sprintf("%s", index)
			backend_port := fmt.Sprintf("%s", element)
			log.Print(fmt.Sprintf("Adding backend %s:%s", backend_host, backend_port))
			Backends = append(Backends, fmt.Sprintf("%s:%s", backend_host, backend_port))
		}
	}

	for _, backserver := range Backends {
		log.Print(fmt.Sprintf("New server is: %s", backserver))
	}

	port, err := config.GetInt("port")
	host, err := config.Get("host")
	log.Print(fmt.Sprintf("Trying to listen on %s:%v", host, port))

	relay_method, err := config.Get("relay_method")
	log.Print(fmt.Sprintf("We want to relay using %s", relay_method))

	listener, err := net.Listen("tcp", fmt.Sprintf("%s:%v", host, port))
	if err != nil {
		println("Error starting net.Listen: ", err.Error())
		os.Exit(1)
	}

	log.Print("Server started, awaiting connections...")

	conns := clientConnections(listener)
	for {
		go handleConnections(<-conns)
	}
}
Ejemplo n.º 16
0
func (c *Config) GetConfig() *yaml.File {

    file := filepath.Join(c.BasePath, "app/dbconf.yml")

    config, err := yaml.ReadFile(file)
    if err != nil {
        log.Fatal(err)
    }
    return config
}
Ejemplo n.º 17
0
func LoadConf() {
	var err error
	conf, err = yaml.ReadFile("botconf.yaml")
	if err != nil {
		log.Panic(err)
	}
	turingAPI, _ = conf.Get("turingBotKey")
	msID, _ = conf.Get("msTransId")
	msSecret, _ = conf.Get("msTransSecret")
}
Ejemplo n.º 18
0
// ParseYaml parses the glide.yaml format and returns a Configuration object.
//
// Params:
//	- filename (string): YAML filename as a string
//
// Context:
//	- yaml.File: This puts the parsed YAML file into the context.
//
// Returns:
//	- *Config: The configuration.
func ParseYaml(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
	fname := p.Get("filename", "glide.yaml").(string)
	//conf := new(Config)
	f, err := yaml.ReadFile(fname)
	if err != nil {
		return nil, err
	}

	c.Put("yaml.File", f)
	return FromYaml(f.Root)
}
Ejemplo n.º 19
0
func db_params() string {
	data, _ := yaml.ReadFile("conf.yml")
	yaml_user, _ := yaml.Child(data.Root, "user")
	yaml_dbname, _ := yaml.Child(data.Root, "dbname")
	yaml_password, _ := yaml.Child(data.Root, "password")
	user := yaml_user.(yaml.Scalar).String()
	dbname := yaml_dbname.(yaml.Scalar).String()
	password := yaml_password.(yaml.Scalar).String()
	db_pars := "user="******" dbname=" + dbname + " password=" + password
	fmt.Println(db_pars)
	return db_pars
}
Ejemplo n.º 20
0
func ParseFile(filename string) (config *Config, err error) {
	file, err := yaml.ReadFile(filename)
	if err != nil {
		return
	}
	config, err = parseConfigRootNode(file.Root)
	if err != nil {
		return
	}
	config.filename = filename
	return
}
Ejemplo n.º 21
0
// extract configuration details from the given file
func NewDBConf(p, env string, pgschema string) (*DBConf, error) {

	cfgFile := filepath.Join(p, "dbconf.yml")

	f, err := yaml.ReadFile(cfgFile)
	if err != nil {
		return nil, err
	}

	drv, err := f.Get(fmt.Sprintf("%s.driver", env))
	if err != nil {
		return nil, err
	}
	drv = os.ExpandEnv(drv)

	open, err := f.Get(fmt.Sprintf("%s.open", env))
	if err != nil {
		return nil, err
	}
	open = os.ExpandEnv(open)

	// Automatically parse postgres urls
	if drv == "postgres" {

		// Assumption: If we can parse the URL, we should
		if parsedURL, err := pq.ParseURL(open); err == nil && parsedURL != "" {
			open = parsedURL
		}
	}

	d := newDBDriver(drv, open)

	// allow the configuration to override the Import for this driver
	if imprt, err := f.Get(fmt.Sprintf("%s.import", env)); err == nil {
		d.Import = imprt
	}

	// allow the configuration to override the Dialect for this driver
	if dialect, err := f.Get(fmt.Sprintf("%s.dialect", env)); err == nil {
		d.Dialect = dialectByName(dialect)
	}

	if !d.IsValid() {
		return nil, errors.New(fmt.Sprintf("Invalid DBConf: %v", d))
	}

	return &DBConf{
		MigrationsDir: filepath.Join(p, "migrations"),
		Env:           env,
		Driver:        d,
		PgSchema:      pgschema,
	}, nil
}
Ejemplo n.º 22
0
// parseYAML parses the config.yml file and returns the appropriate structs and strings.
func YAMLtoETCD(client *etcd.Client) (c goship.Config, err error) {
	config, err := yaml.ReadFile(*ConfigFile)
	if err != nil {
		return c, err
	}
	log.Printf("Setting project root => /projects")
	client.CreateDir("/projects", 0)
	configRoot, _ := config.Root.(yaml.Map)
	projects, _ := configRoot["projects"].(yaml.List)
	for _, p := range projects {
		for k, v := range p.(yaml.Map) {

			projectPath := "/projects/" + k + "/"

			log.Printf("Setting project => %s \n", projectPath)
			client.CreateDir(projectPath, 0)

			name := getYAMLString(v, "project_name")
			setETCD(client, projectPath+"project_name", name)

			repoOwner := getYAMLString(v, "repo_owner")
			setETCD(client, projectPath+"repo_owner", repoOwner)

			repoName := getYAMLString(v, "repo_name")
			setETCD(client, projectPath+"repo_name", repoName)

			for _, v := range v.(yaml.Map)["environments"].(yaml.List) {
				YAMLtoETCDEnvironment(v, client, projectPath)
			}

		}
	}

	pivProject, _ := config.Get("pivotal_project")
	setETCD(client, "pivotal_project", pivProject)

	pivToken, _ := config.Get("pivotal_token")
	setETCD(client, "pivotal_token", pivToken)

	deployUser, _ := config.Get("deploy_user")
	setETCD(client, "deploy_user", deployUser)

	goshipHost, _ := config.Get("goship_host")
	setETCD(client, "goship_host", goshipHost)

	notify, _ := config.Get("notify")
	setETCD(client, "notify", notify)

	return c, err
}
Ejemplo n.º 23
0
Archivo: yaml.go Proyecto: gocore/goal
// parseFile opens the requested file, makes sure it contains
// a yaml.Map of parameters and returns the latter.
func parseFile(file string) (yaml.Map, error) {
	// Read the YAML configuration file.
	f, err := yaml.ReadFile(file)
	if err != nil {
		return nil, fmt.Errorf(`check your "%s" configuration file, error: %v`, file, err)
	}

	// Make sure it is a map (with "init", "watch", etc. keys).
	root, ok := f.Root.(yaml.Map)
	if !ok {
		return nil, fmt.Errorf(`configuration must be a map with "init", "watch", at al keys`)
	}
	return root, nil
}
Ejemplo n.º 24
0
Archivo: main.go Proyecto: qur/go-gypsy
func main() {
	cmd := os.Args[0]
	flag.Usage = func() {
		fmt.Println(`Usage:`, cmd, `[<options>] [<param> ...]

  All <param>s given on the commandline are looked up in
the config file "config.yaml" (or whatever is specified for -file).

Examples:
  $`, cmd, `mapping.key1 # = value1
    Get the key1 element of the "mapping" mapping

  $`, cmd, `config.server[1]
    Get the second (1th) element of the "server" list inside the "config" mapping

  $`, cmd, `mapping mapping.key1 config config.server config.admin[1].password
	Retrieve a bunch of options.  With the example yaml file, some of these
	options are errors, which will print the (text of the) actual Go error from
	node.Get

Options:`)
		flag.PrintDefaults()
	}

	flag.Parse()

	config, err := yaml.ReadFile(*file)
	if err != nil {
		log.Fatalf("readfile(%q): %s", *file, err)
	}

	params := flag.Args()

	width := 0
	for _, param := range params {
		if w := len(param); w > width {
			width = w
		}
	}

	for _, param := range params {
		val, err := config.Get(param)
		if err != nil {
			fmt.Printf("%-*s = %s\n", width, param, err)
			continue
		}
		fmt.Printf("%-*s = %q\n", width, param, val)
	}
}
Ejemplo n.º 25
0
func dependencyGlideUp(base string, godep, gpm, force bool) error {
	//conf := new(Config)
	fname := path.Join(base, "glide.yaml")
	f, err := yaml.ReadFile(fname)
	if err != nil {
		return err
	}

	conf, err := FromYaml(f.Root)
	if err != nil {
		return err
	}
	for _, imp := range conf.Imports {
		// We don't use the global var to find vendor dir name because the
		// user may mis-use that var to modify the local vendor dir, and
		// we don't want that to break the embedded vendor dirs.
		wd := path.Join(base, "vendor", imp.Name)
		vdir := path.Join(base, "vendor")
		if err := ensureDir(wd); err != nil {
			Warn("Skipped getting %s (vendor/ error): %s\n", imp.Name, err)
			continue
		}

		if VcsExists(imp, wd) {
			Info("Updating project %s (%s)\n", imp.Name, wd)
			if err := VcsUpdate(imp, vdir, force); err != nil {
				// We can still go on just fine even if this fails.
				Warn("Skipped update %s: %s\n", imp.Name, err)
				continue
			}
		} else {
			Info("Importing %s to project %s\n", imp.Name, base)
			if err := VcsGet(imp, wd); err != nil {
				Warn("Skipped getting %s: %v\n", imp.Name, err)
				continue
			}
		}

		// If a revision has been set use it.
		err = VcsVersion(imp, vdir)
		if err != nil {
			Warn("Problem setting version on %s: %s\n", imp.Name, err)
		}

		//recDepResolve(conf, path.Join(wd, "vendor"))
	}
	recDepResolve(conf, path.Join(base, "vendor"), godep, gpm, force)
	return nil
}
Ejemplo n.º 26
0
func validatorTask(c *config.Config, q *registry.Queue) error {
	output, err := utils.Exec("rm", []string{"-rf", "../app/lib/Validators"})
	if err != nil {
		fmt.Println(output)
		return fmt.Errorf("cannot remove original validators: %s", err)
	}

	rootPath := "../app/validators"
	walkFn := func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if info.IsDir() {
			return nil
		}

		// Relative path
		rel, err := filepath.Rel(rootPath, path)
		if err != nil {
			return fmt.Errorf("cannot rel validator path: %s", err)
		}

		// Read file
		f, err := yaml.ReadFile(path)
		if err != nil {
			return fmt.Errorf("read validator failed: %s", err)
		}
		data := config.NewConfig(f)

		// Extract fields
		root := data.GetDefault("root", "Object")
		if root != "Object" && root != "Array" {
			return fmt.Errorf("invalid root type, only 'object' and 'array' are accepted")
		}
		fields := parseFields(data, "fields")

		// Generate validator
		if err := generator(rel, root, fields); err != nil {
			return fmt.Errorf("generator error: %s", err)
		}

		return nil
	}
	if err := filepath.Walk(rootPath, walkFn); err != nil {
		return fmt.Errorf("walk validators failed: %s", err)
	}

	return nil
}
Ejemplo n.º 27
0
func tryLoad() (*Config, error) {
	if _, err := os.Stat("config.yaml"); err != nil {
		if os.IsNotExist(err) {
			return nil, nil
		}
		return nil, fmt.Errorf("stat config failed: %s", err)
	}
	f, err := yaml.ReadFile("config.yaml")
	if err != nil {
		return nil, fmt.Errorf("read config failed: %s", err)
	}

	c := NewConfig(f)
	return c, nil
}
Ejemplo n.º 28
0
func LoadConfig() error {
	conf, err := yaml.ReadFile("webhog.yml")
	if err != nil {
		return err
	}

	Config.mysql, _ = conf.Get(getEnv() + ".mysql")
	Config.dbName, _ = conf.Get(getEnv() + ".db_name")
	Config.ApiKey, _ = conf.Get(getEnv() + ".api_key")
	Config.awsKey, _ = conf.Get(getEnv() + ".aws_key")
	Config.awsSecret, _ = conf.Get(getEnv() + ".aws_secret")
	Config.bucket, _ = conf.Get(getEnv() + ".bucket")

	return err
}
Ejemplo n.º 29
0
func (s *TmdbSuite) SetUpSuite(c *C) {
	pwd, _ := os.Getwd()
	basedir := strings.SplitAfter(pwd, "ryanbradynd05/go-tmdb")
	filename := fmt.Sprintf("%s/local.yml", basedir[0])
	config, _ := yaml.ReadFile(filename)
	s.userToken, _ = config.Get("userToken")
	s.user, _ = config.Get("user")
	s.pw, _ = config.Get("pw")
	s.session, _ = config.Get("session")
	s.guestSession, _ = config.Get("guestSession")
	accountID, _ := config.Get("accountID")
	s.accountID, _ = strconv.Atoi(accountID)
	testKey, _ := config.Get("testKey")
	s.tmdb = Init(testKey)
}
Ejemplo n.º 30
0
func LoadConfig() error {
	conf, err := yaml.ReadFile("webhog.yml")
	if err != nil {
		return err
	}

	Config.mongodb, _ = conf.Get(getEnv() + ".mongodb")
	Config.ApiKey, _ = conf.Get(getEnv() + ".api_key")
	Config.bucket, _ = conf.Get(getEnv() + ".bucket")

	key, _ := conf.Get(getEnv() + ".aws_key")
	secret, _ := conf.Get(getEnv() + ".aws_secret")

	Config.AwsKey = os.Getenv(key)
	Config.AwsSecret = os.Getenv(secret)

	return err
}