Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 enables reading, observing, and changing | 4 // Package state enables reading, observing, and changing |
5 // the state stored in MongoDB of a whole environment | 5 // the state stored in MongoDB of a whole environment |
6 // managed by juju. | 6 // managed by juju. |
7 package state | 7 package state |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1404 } | 1404 } |
1405 if err != nil { | 1405 if err != nil { |
1406 return nil, fmt.Errorf("cannot get action %q: %v", id, err) | 1406 return nil, fmt.Errorf("cannot get action %q: %v", id, err) |
1407 } | 1407 } |
1408 return newAction(st, doc), nil | 1408 return newAction(st, doc), nil |
1409 } | 1409 } |
1410 | 1410 |
1411 // UnitActions returns a list of pending actions for a unit named name | 1411 // UnitActions returns a list of pending actions for a unit named name |
1412 func (st *State) UnitActions(name string) ([]*Action, error) { | 1412 func (st *State) UnitActions(name string) ([]*Action, error) { |
1413 actions := []*Action{} | 1413 actions := []*Action{} |
1414 » actionId := actionPrefix(unitGlobalKey(name)) | 1414 » prefix := actionPrefix(unitGlobalKey(name)) |
fwereade
2014/05/27 06:59:54
`prefix :=` perhaps?
johnweldon4
2014/05/27 17:53:18
Done.
| |
1415 » sel := bson.D{{"_id", bson.D{{"$regex", "^" + actionId}}}} | 1415 » sel := bson.D{{"_id", bson.D{{"$regex", "^" + prefix}}}} |
1416 iter := st.actions.Find(sel).Iter() | 1416 iter := st.actions.Find(sel).Iter() |
1417 doc := actionDoc{} | 1417 doc := actionDoc{} |
1418 for iter.Next(&doc) { | 1418 for iter.Next(&doc) { |
1419 actions = append(actions, newAction(st, doc)) | 1419 actions = append(actions, newAction(st, doc)) |
1420 } | 1420 } |
1421 if err := iter.Err(); err != nil { | 1421 if err := iter.Err(); err != nil { |
1422 return actions, err | 1422 return actions, err |
1423 } | 1423 } |
1424 return actions, nil | 1424 return actions, nil |
1425 } | 1425 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1599 func tagForGlobalKey(key string) (string, bool) { | 1599 func tagForGlobalKey(key string) (string, bool) { |
1600 if len(key) < 3 || key[1] != '#' { | 1600 if len(key) < 3 || key[1] != '#' { |
1601 return "", false | 1601 return "", false |
1602 } | 1602 } |
1603 p, ok := tagPrefix[key[0]] | 1603 p, ok := tagPrefix[key[0]] |
1604 if !ok { | 1604 if !ok { |
1605 return "", false | 1605 return "", false |
1606 } | 1606 } |
1607 return p + key[2:], true | 1607 return p + key[2:], true |
1608 } | 1608 } |
LEFT | RIGHT |