Merge lp:~cjwatson/launchpad/snap-upload-model into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18028
Proposed branch: lp:~cjwatson/launchpad/snap-upload-model
Merge into: lp:launchpad
Prerequisite: lp:~cjwatson/launchpad/snap-series
Diff against target: 148 lines (+59/-6)
3 files modified
lib/lp/snappy/interfaces/snap.py (+32/-1)
lib/lp/snappy/model/snap.py (+22/-3)
lib/lp/testing/factory.py (+5/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-upload-model
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+293648@code.launchpad.net

Commit message

Add basic model for Snap/SnapBuild store upload columns.

Description of the change

Add basic model for Snap/SnapBuild store upload columns. This doesn't do anything interesting yet and I haven't exported any of the attributes; I just wanted to have this in place to make it easier to submit subsequent branches.

To post a comment you must log in.
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/snappy/interfaces/snap.py'
2--- lib/lp/snappy/interfaces/snap.py 2016-02-28 17:23:53 +0000
3+++ lib/lp/snappy/interfaces/snap.py 2016-05-09 15:49:50 +0000
4@@ -86,6 +86,7 @@
5 PublicPersonChoice,
6 )
7 from lp.services.webhooks.interfaces import IWebhookTarget
8+from lp.snappy.interfaces.snappyseries import ISnappySeries
9 from lp.soyuz.interfaces.archive import IArchive
10 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
11
12@@ -354,6 +355,34 @@
13 "The Git branch containing a snapcraft.yaml recipe at the top "
14 "level.")))
15
16+ store_upload = Bool(
17+ title=_("Automatically upload to store"),
18+ required=True, readonly=False,
19+ description=_(
20+ "Whether builds of this snap package are automatically uploaded "
21+ "to the store."))
22+
23+ store_series = ReferenceChoice(
24+ title=_("Store series"),
25+ schema=ISnappySeries, vocabulary="SnappySeries",
26+ required=False, readonly=False,
27+ description=_(
28+ "The series in which this snap package should be published in the "
29+ "store."))
30+
31+ store_name = TextLine(
32+ title=_("Registered store package name"),
33+ required=False, readonly=False,
34+ description=_(
35+ "The registered name of this snap package in the store."))
36+
37+ store_secrets = List(
38+ value_type=TextLine(), title=_("Store upload tokens"),
39+ required=False, readonly=False,
40+ description=_(
41+ "Serialized secrets issued by the store and the login service to "
42+ "authorize uploads of this snap package."))
43+
44
45 class ISnapAdminAttributes(Interface):
46 """`ISnap` attributes that can be edited by admins.
47@@ -401,7 +430,9 @@
48 @operation_for_version("devel")
49 def new(registrant, owner, distro_series, name, description=None,
50 branch=None, git_ref=None, require_virtualized=True,
51- processors=None, date_created=None, private=False):
52+ processors=None, date_created=None, private=False,
53+ store_upload=False, store_series=None, store_name=None,
54+ store_secrets=None):
55 """Create an `ISnap`."""
56
57 def exists(owner, name):
58
59=== modified file 'lib/lp/snappy/model/snap.py'
60--- lib/lp/snappy/model/snap.py 2016-02-28 17:40:10 +0000
61+++ lib/lp/snappy/model/snap.py 2016-05-09 15:49:50 +0000
62@@ -12,6 +12,7 @@
63 DateTime,
64 Desc,
65 Int,
66+ JSON,
67 Not,
68 Reference,
69 Store,
70@@ -148,10 +149,20 @@
71
72 private = Bool(name='private')
73
74+ store_upload = Bool(name='store_upload', allow_none=False)
75+
76+ store_series_id = Int(name='store_series', allow_none=True)
77+ store_series = Reference(store_series_id, 'SnappySeries.id')
78+
79+ store_name = Unicode(name='store_name', allow_none=True)
80+
81+ store_secrets = JSON('store_secrets', allow_none=True)
82+
83 def __init__(self, registrant, owner, distro_series, name,
84 description=None, branch=None, git_ref=None,
85 require_virtualized=True, date_created=DEFAULT,
86- private=False):
87+ private=False, store_upload=False, store_series=None,
88+ store_name=None, store_secrets=None):
89 """Construct a `Snap`."""
90 if not getFeatureFlag(SNAP_FEATURE_FLAG):
91 raise SnapFeatureDisabled
92@@ -168,6 +179,10 @@
93 self.date_created = date_created
94 self.date_last_modified = date_created
95 self.private = private
96+ self.store_upload = store_upload
97+ self.store_series = store_series
98+ self.store_name = store_name
99+ self.store_secrets = store_secrets
100
101 @property
102 def valid_webhook_event_types(self):
103@@ -389,7 +404,9 @@
104
105 def new(self, registrant, owner, distro_series, name, description=None,
106 branch=None, git_ref=None, require_virtualized=True,
107- processors=None, date_created=DEFAULT, private=False):
108+ processors=None, date_created=DEFAULT, private=False,
109+ store_upload=False, store_series=None, store_name=None,
110+ store_secrets=None):
111 """See `ISnapSet`."""
112 if not registrant.inTeam(owner):
113 if owner.is_team:
114@@ -414,7 +431,9 @@
115 registrant, owner, distro_series, name, description=description,
116 branch=branch, git_ref=git_ref,
117 require_virtualized=require_virtualized, date_created=date_created,
118- private=private)
119+ private=private, store_upload=store_upload,
120+ store_series=store_series, store_name=store_name,
121+ store_secrets=store_secrets)
122 store.add(snap)
123
124 if processors is None:
125
126=== modified file 'lib/lp/testing/factory.py'
127--- lib/lp/testing/factory.py 2016-05-09 15:49:49 +0000
128+++ lib/lp/testing/factory.py 2016-05-09 15:49:50 +0000
129@@ -4607,7 +4607,8 @@
130 def makeSnap(self, registrant=None, owner=None, distroseries=None,
131 name=None, branch=None, git_ref=None,
132 require_virtualized=True, processors=None,
133- date_created=DEFAULT, private=False):
134+ date_created=DEFAULT, private=False, store_upload=False,
135+ store_series=None, store_name=None, store_secrets=None):
136 """Make a new Snap."""
137 if registrant is None:
138 registrant = self.makePerson()
139@@ -4623,7 +4624,9 @@
140 registrant, owner, distroseries, name,
141 require_virtualized=require_virtualized, processors=processors,
142 date_created=date_created, branch=branch, git_ref=git_ref,
143- private=private)
144+ private=private, store_upload=store_upload,
145+ store_series=store_series, store_name=store_name,
146+ store_secrets=store_secrets)
147 IStore(snap).flush()
148 return snap
149