~ubuntu-branches/ubuntu/trusty/juju-core/trusty-proposed

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/cmd/charmd/main.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-29 11:40:20 UTC
  • mfrom: (23.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140129114020-ejieitm8smtt5vln
Tags: 1.17.1-0ubuntu2
d/tests/local-provider: Don't fail tests if ~/.juju is present as its
created by the juju version command. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
import (
7
7
        "fmt"
8
 
        "io/ioutil"
9
8
        "net/http"
10
9
        "os"
11
10
        "path/filepath"
12
11
 
13
 
        "launchpad.net/goyaml"
14
 
 
15
12
        "launchpad.net/juju-core/store"
16
13
)
17
14
 
23
20
        }
24
21
}
25
22
 
26
 
type config struct {
27
 
        MongoURL string `yaml:"mongo-url"`
28
 
        APIAddr  string `yaml:"api-addr"`
29
 
}
30
 
 
31
 
func readConfig(path string, conf interface{}) error {
32
 
        f, err := os.Open(path)
33
 
        if err != nil {
34
 
                return fmt.Errorf("opening config file: %v", err)
35
 
        }
36
 
        data, err := ioutil.ReadAll(f)
37
 
        f.Close()
38
 
        if err != nil {
39
 
                return fmt.Errorf("reading config file: %v", err)
40
 
        }
41
 
        err = goyaml.Unmarshal(data, conf)
42
 
        if err != nil {
43
 
                return fmt.Errorf("processing config file: %v", err)
44
 
        }
45
 
        return nil
46
 
}
47
 
 
48
23
func serve() error {
49
24
        var confPath string
50
25
        if len(os.Args) == 2 {
55
30
        if confPath == "" {
56
31
                return fmt.Errorf("usage: %s <config path>", filepath.Base(os.Args[0]))
57
32
        }
58
 
        var conf config
59
 
        err := readConfig(confPath, &conf)
 
33
        conf, err := store.ReadConfig(confPath)
60
34
        if err != nil {
61
35
                return err
62
36
        }