Merge ~ilasc/launchpad:oci-recipe-push-rules-view into launchpad:master

Proposed by Ioana Lasc
Status: Merged
Approved by: Ioana Lasc
Approved revision: 6fb37207d74145c21f8d90032424b8767f9430f5
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~ilasc/launchpad:oci-recipe-push-rules-view
Merge into: launchpad:master
Diff against target: 89 lines (+45/-0)
4 files modified
lib/lp/oci/browser/ocirecipe.py (+9/-0)
lib/lp/oci/interfaces/ocipushrule.py (+3/-0)
lib/lp/oci/model/ocipushrule.py (+6/-0)
lib/lp/oci/templates/ocirecipe-index.pt (+27/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+386167@code.launchpad.net

Commit message

Add View for OCI push rules

Description of the change

Add View for OCI push rules

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :
6fb3720... by Ioana Lasc

Merge branch 'master' into oci-recipe-push-rules-view

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py
2index 5fcab06..356ac1c 100644
3--- a/lib/lp/oci/browser/ocirecipe.py
4+++ b/lib/lp/oci/browser/ocirecipe.py
5@@ -184,6 +184,15 @@ class OCIRecipeView(LaunchpadView):
6 def builds(self):
7 return builds_for_recipe(self.context)
8
9+ @cachedproperty
10+ def push_rules(self):
11+ return list(
12+ getUtility(IOCIPushRuleSet).findByRecipe(self.context))
13+
14+ @property
15+ def has_push_rules(self):
16+ return len(self.push_rules) > 0
17+
18 @property
19 def person_picker(self):
20 field = copy_field(
21diff --git a/lib/lp/oci/interfaces/ocipushrule.py b/lib/lp/oci/interfaces/ocipushrule.py
22index 45aeb3b..67db23e 100644
23--- a/lib/lp/oci/interfaces/ocipushrule.py
24+++ b/lib/lp/oci/interfaces/ocipushrule.py
25@@ -127,6 +127,9 @@ class IOCIPushRuleSet(Interface):
26 def new(recipe, registry_credentials, image_name):
27 """Create an `IOCIPushRule`."""
28
29+ def findByRecipe(self, recipe):
30+ """Find matching `IOCIPushRule`s by recipe."""
31+
32 def findByRegistryCredentials(self, credentials):
33 """Find matching `IOCIPushRule` by credentials."""
34
35diff --git a/lib/lp/oci/model/ocipushrule.py b/lib/lp/oci/model/ocipushrule.py
36index 0354aad..24d5e27 100644
37--- a/lib/lp/oci/model/ocipushrule.py
38+++ b/lib/lp/oci/model/ocipushrule.py
39@@ -91,6 +91,12 @@ class OCIPushRuleSet:
40 """See `IOCIPushRuleSet`."""
41 return IStore(OCIPushRule).get(OCIPushRule, id)
42
43+ def findByRecipe(self, recipe):
44+ store = IStore(OCIPushRule)
45+ return store.find(
46+ OCIPushRule,
47+ OCIPushRule.recipe == recipe)
48+
49 def findByRegistryCredentials(self, credentials):
50 store = IStore(OCIPushRule)
51 return store.find(
52diff --git a/lib/lp/oci/templates/ocirecipe-index.pt b/lib/lp/oci/templates/ocirecipe-index.pt
53index f7df628..cf7c549 100644
54--- a/lib/lp/oci/templates/ocirecipe-index.pt
55+++ b/lib/lp/oci/templates/ocirecipe-index.pt
56@@ -116,6 +116,33 @@
57 tal:condition="link/enabled">
58 <tal:request-builds replace="structure link/fmt:link"/>
59 </div>
60+
61+
62+ <h2>Recipe push rules</h2>
63+ <table id="push-rules-listing" tal:condition="view/has_push_rules" class="listing"
64+ style="margin-bottom: 1em; ">
65+ <thead>
66+ <tr>
67+ <th>Registry URL</th>
68+ <th>Username</th>
69+ <th>Image Name</th>
70+ </tr>
71+ </thead>
72+ <tbody>
73+ <tal:recipe-push-rules repeat="item view/push_rules">
74+ <tr tal:define="rule item"
75+ tal:attributes="id string:rule-${rule/id}">
76+ <td tal:content="rule/registry_credentials/url"/>
77+ <td tal:content="rule/registry_credentials/username"/>
78+ <td tal:content="rule/image_name"/>
79+ </tr>
80+ </tal:recipe-push-rules>
81+ </tbody>
82+ </table>
83+ <p tal:condition="not: view/has_push_rules">
84+ This OCI recipe has no push rules defined yet.
85+ </p>
86+
87 </div>
88
89 </body>

Subscribers

People subscribed via source and target branches

to status/vote changes: