~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/tools/lxdclient/addserver.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
        "strings"
14
14
 
15
15
        "github.com/juju/errors"
16
 
        "github.com/lxc/lxd"
17
16
        "github.com/lxc/lxd/shared"
18
17
)
19
18
 
20
 
// addServer adds the given remote info to the provided config.
21
 
// The implementation is based loosely on:
22
 
//  https://github.com/lxc/lxd/blob/master/lxc/remote.go
23
 
func addServer(config *lxd.Config, server string, addr string) error {
24
 
        addr, err := fixAddr(addr)
25
 
        if err != nil {
26
 
                return err
27
 
        }
28
 
 
29
 
        if config.Remotes == nil {
30
 
                config.Remotes = make(map[string]lxd.RemoteConfig)
31
 
        }
32
 
 
33
 
        /* Actually add the remote */
34
 
        // TODO(ericsnow) Fail on collision?
35
 
        config.Remotes[server] = lxd.RemoteConfig{Addr: addr}
36
 
 
37
 
        return nil
38
 
}
39
 
 
40
19
// TODO(ericsnow) Rename addr -> remoteURL?
41
20
 
42
21
func fixAddr(addr string) (string, error) {