OLD | NEW |
1 // Copyright 2012, 2013 Canonical Ltd. | 1 // Copyright 2012, 2013 Canonical Ltd. |
2 // Licensed under the AGPLv3, see LICENCE file for details. | 2 // Licensed under the AGPLv3, see LICENCE file for details. |
3 | 3 |
4 package state | 4 package state |
5 | 5 |
6 import ( | 6 import ( |
7 "net/url" | 7 "net/url" |
8 | 8 |
9 "launchpad.net/juju-core/charm" | 9 "launchpad.net/juju-core/charm" |
10 ) | 10 ) |
11 | 11 |
12 // charmDoc represents the internal state of a charm in MongoDB. | 12 // charmDoc represents the internal state of a charm in MongoDB. |
13 type charmDoc struct { | 13 type charmDoc struct { |
14 URL *charm.URL `bson:"_id"` | 14 URL *charm.URL `bson:"_id"` |
15 Meta *charm.Meta | 15 Meta *charm.Meta |
16 Config *charm.Config | 16 Config *charm.Config |
17 BundleURL *url.URL | 17 BundleURL *url.URL |
18 BundleSha256 string | 18 BundleSha256 string |
19 PendingUpload bool | 19 PendingUpload bool |
| 20 Placeholder bool |
20 } | 21 } |
21 | 22 |
22 // Charm represents the state of a charm in the environment. | 23 // Charm represents the state of a charm in the environment. |
23 type Charm struct { | 24 type Charm struct { |
24 st *State | 25 st *State |
25 doc charmDoc | 26 doc charmDoc |
26 } | 27 } |
27 | 28 |
28 func newCharm(st *State, cdoc *charmDoc) (*Charm, error) { | 29 func newCharm(st *State, cdoc *charmDoc) (*Charm, error) { |
29 return &Charm{st: st, doc: *cdoc}, nil | 30 return &Charm{st: st, doc: *cdoc}, nil |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // BundleSha256 returns the SHA256 digest of the charm bundle bytes. | 65 // BundleSha256 returns the SHA256 digest of the charm bundle bytes. |
65 func (c *Charm) BundleSha256() string { | 66 func (c *Charm) BundleSha256() string { |
66 return c.doc.BundleSha256 | 67 return c.doc.BundleSha256 |
67 } | 68 } |
68 | 69 |
69 // IsUploaded returns whether the charm has been uploaded to the | 70 // IsUploaded returns whether the charm has been uploaded to the |
70 // provider storage. | 71 // provider storage. |
71 func (c *Charm) IsUploaded() bool { | 72 func (c *Charm) IsUploaded() bool { |
72 return !c.doc.PendingUpload | 73 return !c.doc.PendingUpload |
73 } | 74 } |
| 75 |
| 76 // IsPlaceholder returns whether the charm record is just a placeholder |
| 77 // rather than representing a deployed charm. |
| 78 func (c *Charm) IsPlaceholder() bool { |
| 79 return c.doc.Placeholder |
| 80 } |
OLD | NEW |