Merge lp:~rharding/charmworld/support-implicit-relations into lp:charmworld

Proposed by Richard Harding
Status: Merged
Approved by: Richard Harding
Approved revision: 453
Merged at revision: 453
Proposed branch: lp:~rharding/charmworld/support-implicit-relations
Merge into: lp:charmworld
Diff against target: 53 lines (+35/-0)
2 files modified
charmworld/lib/proof.py (+9/-0)
charmworld/lib/tests/test_proof.py (+26/-0)
To merge this branch: bzr merge lp:~rharding/charmworld/support-implicit-relations
Reviewer Review Type Date Requested Status
Juju Gui Bot continuous-integration Approve
Charmworld Developers Pending
Review via email: mp+194535@code.launchpad.net

Commit message

Allow implicit juju-* relations to be valid.

- https://juju.ubuntu.com/docs/authors-implicit-relations.html
- juju-* is a namespace for implicit juju relations all charms support. This
adds a check for relations that start with juju- and auto approve them in
proof.
- Charms are not allowed to create any relation of their own that start with
juju-, so it's safe to assume anything that starts with this is a safe
implicit relation.

https://codereview.appspot.com/23660043/

R=benji

Description of the change

Allow implicit juju-* relations to be valid.

- https://juju.ubuntu.com/docs/authors-implicit-relations.html
- juju-* is a namespace for implicit juju relations all charms support. This
adds a check for relations that start with juju- and auto approve them in
proof.
- Charms are not allowed to create any relation of their own that start with
juju-, so it's safe to assume anything that starts with this is a safe
implicit relation.

https://codereview.appspot.com/23660043/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Reviewers: mp+194535_code.launchpad.net,

Message:
Please take a look.

Description:
Allow implicit juju-* relations to be valid.

- https://juju.ubuntu.com/docs/authors-implicit-relations.html
- juju-* is a namespace for implicit juju relations all charms support.
This
adds a check for relations that start with juju- and auto approve them
in
proof.
- Charms are not allowed to create any relation of their own that start
with
juju-, so it's safe to assume anything that starts with this is a safe
implicit relation.

https://code.launchpad.net/~rharding/charmworld/support-implicit-relations/+merge/194535

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/23660043/

Affected files (+37, -0 lines):
   A [revision details]
   M charmworld/lib/proof.py
   M charmworld/lib/tests/test_proof.py

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20131108152057-vxjx6ibvpchmbuqw
+New revision: <email address hidden>

Index: charmworld/lib/proof.py
=== modified file 'charmworld/lib/proof.py'
--- charmworld/lib/proof.py 2013-11-06 19:10:38 +0000
+++ charmworld/lib/proof.py 2013-11-08 15:33:33 +0000
@@ -71,6 +71,15 @@
      if check_requires in requires and check_provides in provides:
          exist = True

+ # If the check type is a implicit interface then it's valid.
+ if check_requires and check_requires.startswith('juju-'):
+ return True
+
+ if check_provides and check_provides.startswith('juju-'):
+ return True
+
+ # If it's not implicit then continue to check that it's valid for the
two
+ # services in the relation.
      if check_requires and check_requires in requires:
          require_type = requires[check_requires]['interface']
      if check_provides and check_provides in provides:

Index: charmworld/lib/tests/test_proof.py
=== modified file 'charmworld/lib/tests/test_proof.py'
--- charmworld/lib/tests/test_proof.py 2013-11-06 19:17:39 +0000
+++ charmworld/lib/tests/test_proof.py 2013-11-08 15:33:33 +0000
@@ -322,3 +322,29 @@

          # There's no ProofError raised. Just an empty function return value
          self.assertTrue(res)
+
+ def test_implicit_relations_are_safe(self):
+ # relation = ['wiki:juju-info', 'haproxy:juju-info']
+ check_requires = 'juju-info'
+ check_provides = 'juju-info'
+
+ # Note that none of the services defined a juju-info interface.
+ requires = {
+ 'website': {
+ 'interface': 'http'
+ }
+ }
+ provides = {
+ 'cache': {
+ 'interface': 'http'
+ }
+ }
+
+ res = verify_points_exist_and_same_type(
+ check_requires,
+ check_provides,
+ requires,
+ provides)
+
+ # There's no ProofError raised. Just an empty function return value
+ self.assertTrue(res)

Revision history for this message
Benji York (benji) wrote :
Revision history for this message
Juju Gui Bot (juju-gui-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/lib/proof.py'
2--- charmworld/lib/proof.py 2013-11-06 19:10:38 +0000
3+++ charmworld/lib/proof.py 2013-11-08 15:39:52 +0000
4@@ -71,6 +71,15 @@
5 if check_requires in requires and check_provides in provides:
6 exist = True
7
8+ # If the check type is a implicit interface then it's valid.
9+ if check_requires and check_requires.startswith('juju-'):
10+ return True
11+
12+ if check_provides and check_provides.startswith('juju-'):
13+ return True
14+
15+ # If it's not implicit then continue to check that it's valid for the two
16+ # services in the relation.
17 if check_requires and check_requires in requires:
18 require_type = requires[check_requires]['interface']
19 if check_provides and check_provides in provides:
20
21=== modified file 'charmworld/lib/tests/test_proof.py'
22--- charmworld/lib/tests/test_proof.py 2013-11-06 19:17:39 +0000
23+++ charmworld/lib/tests/test_proof.py 2013-11-08 15:39:52 +0000
24@@ -322,3 +322,29 @@
25
26 # There's no ProofError raised. Just an empty function return value
27 self.assertTrue(res)
28+
29+ def test_implicit_relations_are_safe(self):
30+ # relation = ['wiki:juju-info', 'haproxy:juju-info']
31+ check_requires = 'juju-info'
32+ check_provides = 'juju-info'
33+
34+ # Note that none of the services defined a juju-info interface.
35+ requires = {
36+ 'website': {
37+ 'interface': 'http'
38+ }
39+ }
40+ provides = {
41+ 'cache': {
42+ 'interface': 'http'
43+ }
44+ }
45+
46+ res = verify_points_exist_and_same_type(
47+ check_requires,
48+ check_provides,
49+ requires,
50+ provides)
51+
52+ # There's no ProofError raised. Just an empty function return value
53+ self.assertTrue(res)

Subscribers

People subscribed via source and target branches

to all changes: