~rogpeppe/juju-core/azure

« back to all changes in this revision

Viewing changes to state/charm.go

[r=gz] Check correct info attr in cloudinit.apiHostAddrs

Fixes a copy/paste error in cloudinit.MachineConfig to agent.Conf
conversion helper function. No test as the only codepath that uses
this goes through verifyConfig which already asserts both StateInfo
and APIInfo are not nil, so not possible to write a failing test
using exposed functions.

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 state
 
5
 
 
6
import (
 
7
        "net/url"
 
8
 
 
9
        "launchpad.net/juju-core/charm"
 
10
)
 
11
 
 
12
// charmDoc represents the internal state of a charm in MongoDB.
 
13
type charmDoc struct {
 
14
        URL          *charm.URL `bson:"_id"`
 
15
        Meta         *charm.Meta
 
16
        Config       *charm.Config
 
17
        BundleURL    *url.URL
 
18
        BundleSha256 string
 
19
}
 
20
 
 
21
// Charm represents the state of a charm in the environment.
 
22
type Charm struct {
 
23
        st  *State
 
24
        doc charmDoc
 
25
}
 
26
 
 
27
func newCharm(st *State, cdoc *charmDoc) (*Charm, error) {
 
28
        return &Charm{st: st, doc: *cdoc}, nil
 
29
}
 
30
 
 
31
func (c *Charm) String() string {
 
32
        return c.doc.URL.String()
 
33
}
 
34
 
 
35
// URL returns the URL that identifies the charm.
 
36
func (c *Charm) URL() *charm.URL {
 
37
        clone := *c.doc.URL
 
38
        return &clone
 
39
}
 
40
 
 
41
// Revision returns the monotonically increasing charm
 
42
// revision number.
 
43
func (c *Charm) Revision() int {
 
44
        return c.doc.URL.Revision
 
45
}
 
46
 
 
47
// Meta returns the metadata of the charm.
 
48
func (c *Charm) Meta() *charm.Meta {
 
49
        return c.doc.Meta
 
50
}
 
51
 
 
52
// Config returns the configuration of the charm.
 
53
func (c *Charm) Config() *charm.Config {
 
54
        return c.doc.Config
 
55
}
 
56
 
 
57
// BundleURL returns the url to the charm bundle in
 
58
// the provider storage.
 
59
func (c *Charm) BundleURL() *url.URL {
 
60
        return c.doc.BundleURL
 
61
}
 
62
 
 
63
// BundleSha256 returns the SHA256 digest of the charm bundle bytes.
 
64
func (c *Charm) BundleSha256() string {
 
65
        return c.doc.BundleSha256
 
66
}