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

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/cmd/charm-admin/config.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:
 
1
// Copyright 2012, 2013 Canonical Ltd.
 
2
// Licensed under the AGPLv3, see LICENCE file for details.
 
3
 
 
4
package main
 
5
 
 
6
import (
 
7
        "fmt"
 
8
 
 
9
        "launchpad.net/gnuflag"
 
10
 
 
11
        "launchpad.net/juju-core/cmd"
 
12
        "launchpad.net/juju-core/store"
 
13
)
 
14
 
 
15
// ConfigCommand defines a command which requires a YAML config file.
 
16
type ConfigCommand struct {
 
17
        cmd.CommandBase
 
18
        ConfigPath string
 
19
        Config     *store.Config
 
20
}
 
21
 
 
22
type CharmdConfig struct {
 
23
        MongoUrl string `yaml:"mongo-url"`
 
24
}
 
25
 
 
26
func (c *ConfigCommand) SetFlags(f *gnuflag.FlagSet) {
 
27
        f.StringVar(&c.ConfigPath, "config", "", "charmd configuration file")
 
28
}
 
29
 
 
30
func (c *ConfigCommand) Init(args []string) error {
 
31
        if c.ConfigPath == "" {
 
32
                return fmt.Errorf("--config is required")
 
33
        }
 
34
        return nil
 
35
}
 
36
 
 
37
func (c *ConfigCommand) ReadConfig(ctx *cmd.Context) (err error) {
 
38
        c.Config, err = store.ReadConfig(ctx.AbsPath(c.ConfigPath))
 
39
        return err
 
40
}