OLD | NEW |
(Empty) | |
| 1 // Copyright 2012, 2013 Canonical Ltd. |
| 2 // Licensed under the AGPLv3, see LICENCE file for details. |
| 3 |
| 4 package state |
| 5 |
| 6 import ( |
| 7 "launchpad.net/juju-core/agent/tools" |
| 8 "launchpad.net/juju-core/state/api/params" |
| 9 ) |
| 10 |
| 11 // EntityFinder is implemented by *State. See State.FindEntity |
| 12 // for documentation on the method. |
| 13 type EntityFinder interface { |
| 14 FindEntity(tag string) (Entity, error) |
| 15 } |
| 16 |
| 17 var _ EntityFinder = (*State)(nil) |
| 18 |
| 19 // Entity represents any entity that can be returned |
| 20 // by State.FindEntity. All entities have a tag. |
| 21 type Entity interface { |
| 22 Tag() string |
| 23 } |
| 24 |
| 25 var ( |
| 26 _ Entity = (*Machine)(nil) |
| 27 _ Entity = (*Unit)(nil) |
| 28 _ Entity = (*Service)(nil) |
| 29 _ Entity = (*Environment)(nil) |
| 30 _ Entity = (*User)(nil) |
| 31 ) |
| 32 |
| 33 type StatusSetter interface { |
| 34 SetStatus(status params.Status, info string) error |
| 35 } |
| 36 |
| 37 var ( |
| 38 _ StatusSetter = (*Machine)(nil) |
| 39 _ StatusSetter = (*Unit)(nil) |
| 40 ) |
| 41 |
| 42 // Lifer represents an entity with a life. |
| 43 type Lifer interface { |
| 44 Life() Life |
| 45 } |
| 46 |
| 47 var ( |
| 48 _ Lifer = (*Machine)(nil) |
| 49 _ Lifer = (*Unit)(nil) |
| 50 _ Lifer = (*Service)(nil) |
| 51 _ Lifer = (*Relation)(nil) |
| 52 ) |
| 53 |
| 54 // AgentTooler is implemented by entities |
| 55 // that have associated agent tools. |
| 56 type AgentTooler interface { |
| 57 AgentTools() (*tools.Tools, error) |
| 58 SetAgentTools(*tools.Tools) error |
| 59 } |
| 60 |
| 61 // EnsureDeader with an EnsureDead method. |
| 62 type EnsureDeader interface { |
| 63 EnsureDead() error |
| 64 } |
| 65 |
| 66 var ( |
| 67 _ EnsureDeader = (*Machine)(nil) |
| 68 _ EnsureDeader = (*Unit)(nil) |
| 69 ) |
| 70 |
| 71 // Remover represents entities with a Remove method. |
| 72 type Remover interface { |
| 73 Remove() error |
| 74 } |
| 75 |
| 76 var ( |
| 77 _ Remover = (*Machine)(nil) |
| 78 _ Remover = (*Unit)(nil) |
| 79 ) |
| 80 |
| 81 // Authenticator represents entites capable of handling password |
| 82 // authentication. |
| 83 type Authenticator interface { |
| 84 Refresh() error |
| 85 SetPassword(pass string) error |
| 86 PasswordValid(pass string) bool |
| 87 } |
| 88 |
| 89 var ( |
| 90 _ Authenticator = (*Machine)(nil) |
| 91 _ Authenticator = (*Unit)(nil) |
| 92 _ Authenticator = (*User)(nil) |
| 93 ) |
| 94 |
| 95 // MongoPassworder represents an entity that can |
| 96 // have a mongo password set for it. |
| 97 type MongoPassworder interface { |
| 98 SetMongoPassword(password string) error |
| 99 } |
| 100 |
| 101 var ( |
| 102 _ MongoPassworder = (*Machine)(nil) |
| 103 _ MongoPassworder = (*Unit)(nil) |
| 104 ) |
| 105 |
| 106 // Annotator represents entities capable of handling annotations. |
| 107 type Annotator interface { |
| 108 Annotation(key string) (string, error) |
| 109 Annotations() (map[string]string, error) |
| 110 SetAnnotations(pairs map[string]string) error |
| 111 } |
| 112 |
| 113 var ( |
| 114 _ Annotator = (*Machine)(nil) |
| 115 _ Annotator = (*Unit)(nil) |
| 116 _ Annotator = (*Service)(nil) |
| 117 _ Annotator = (*Environment)(nil) |
| 118 ) |
| 119 |
| 120 // NotifyWatcherFactory represents an entity that |
| 121 // can be watched. |
| 122 type NotifyWatcherFactory interface { |
| 123 Watch() NotifyWatcher |
| 124 } |
| 125 |
| 126 var ( |
| 127 _ NotifyWatcherFactory = (*Machine)(nil) |
| 128 _ NotifyWatcherFactory = (*Unit)(nil) |
| 129 _ NotifyWatcherFactory = (*Service)(nil) |
| 130 ) |
| 131 |
| 132 // AgentEntity represents an entity that can |
| 133 // have an agent responsible for it. |
| 134 type AgentEntity interface { |
| 135 Entity |
| 136 Lifer |
| 137 Authenticator |
| 138 MongoPassworder |
| 139 AgentTooler |
| 140 StatusSetter |
| 141 EnsureDeader |
| 142 Remover |
| 143 NotifyWatcherFactory |
| 144 } |
| 145 |
| 146 var ( |
| 147 _ AgentEntity = (*Machine)(nil) |
| 148 _ AgentEntity = (*Unit)(nil) |
| 149 ) |
OLD | NEW |