Merge ~twom/launchpad:oci-build-path-ui into launchpad:master
- Git
- lp:~twom/launchpad
- oci-build-path-ui
- Merge into master
Proposed by
Tom Wardill
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Tom Wardill | ||||
Approved revision: | 2facb6d9b0a71626fef923e395e5296470d111cd | ||||
Merge reported by: | Otto Co-Pilot | ||||
Merged at revision: | not available | ||||
Proposed branch: | ~twom/launchpad:oci-build-path-ui | ||||
Merge into: | launchpad:master | ||||
Diff against target: |
235 lines (+41/-7) 9 files modified
lib/lp/oci/browser/ocirecipe.py (+6/-1) lib/lp/oci/interfaces/ocirecipe.py (+8/-0) lib/lp/oci/model/ocirecipe.py (+8/-3) lib/lp/oci/model/ocirecipebuildbehaviour.py (+1/-0) lib/lp/oci/templates/ocirecipe-index.pt (+5/-0) lib/lp/oci/templates/ocirecipe-new.pt (+3/-0) lib/lp/oci/tests/test_ocirecipe.py (+4/-2) lib/lp/oci/tests/test_ocirecipebuildbehaviour.py (+2/-0) lib/lp/testing/factory.py (+4/-1) |
||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+389415@code.launchpad.net |
Commit message
Add build_path to OCI UI
Description of the change
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py | |||
2 | index 3dd764c..15a2b14 100644 | |||
3 | --- a/lib/lp/oci/browser/ocirecipe.py | |||
4 | +++ b/lib/lp/oci/browser/ocirecipe.py | |||
5 | @@ -505,6 +505,7 @@ class IOCIRecipeEditSchema(Interface): | |||
6 | 505 | "description", | 505 | "description", |
7 | 506 | "git_ref", | 506 | "git_ref", |
8 | 507 | "build_file", | 507 | "build_file", |
9 | 508 | "build_path", | ||
10 | 508 | "build_daily", | 509 | "build_daily", |
11 | 509 | "require_virtualized", | 510 | "require_virtualized", |
12 | 510 | "allow_internet", | 511 | "allow_internet", |
13 | @@ -523,6 +524,7 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin): | |||
14 | 523 | "description", | 524 | "description", |
15 | 524 | "git_ref", | 525 | "git_ref", |
16 | 525 | "build_file", | 526 | "build_file", |
17 | 527 | "build_path", | ||
18 | 526 | "build_daily", | 528 | "build_daily", |
19 | 527 | ) | 529 | ) |
20 | 528 | custom_widget_git_ref = GitRefWidget | 530 | custom_widget_git_ref = GitRefWidget |
21 | @@ -557,6 +559,7 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin): | |||
22 | 557 | return { | 559 | return { |
23 | 558 | "owner": self.user, | 560 | "owner": self.user, |
24 | 559 | "build_file": "Dockerfile", | 561 | "build_file": "Dockerfile", |
25 | 562 | "build_path": ".", | ||
26 | 560 | "processors": [ | 563 | "processors": [ |
27 | 561 | p for p in getUtility(IProcessorSet).getAll() | 564 | p for p in getUtility(IProcessorSet).getAll() |
28 | 562 | if p.build_by_default], | 565 | if p.build_by_default], |
29 | @@ -580,7 +583,8 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin): | |||
30 | 580 | recipe = getUtility(IOCIRecipeSet).new( | 583 | recipe = getUtility(IOCIRecipeSet).new( |
31 | 581 | name=data["name"], registrant=self.user, owner=data["owner"], | 584 | name=data["name"], registrant=self.user, owner=data["owner"], |
32 | 582 | oci_project=self.context, git_ref=data["git_ref"], | 585 | oci_project=self.context, git_ref=data["git_ref"], |
34 | 583 | build_file=data["build_file"], description=data["description"], | 586 | build_file=data["build_file"], build_path=data["build_path"], |
35 | 587 | description=data["description"], | ||
36 | 584 | build_daily=data["build_daily"], processors=data["processors"]) | 588 | build_daily=data["build_daily"], processors=data["processors"]) |
37 | 585 | self.next_url = canonical_url(recipe) | 589 | self.next_url = canonical_url(recipe) |
38 | 586 | 590 | ||
39 | @@ -638,6 +642,7 @@ class OCIRecipeEditView(BaseOCIRecipeEditView, EnableProcessorsMixin): | |||
40 | 638 | "description", | 642 | "description", |
41 | 639 | "git_ref", | 643 | "git_ref", |
42 | 640 | "build_file", | 644 | "build_file", |
43 | 645 | "build_path", | ||
44 | 641 | "build_daily", | 646 | "build_daily", |
45 | 642 | ) | 647 | ) |
46 | 643 | custom_widget_git_ref = GitRefWidget | 648 | custom_widget_git_ref = GitRefWidget |
47 | diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py | |||
48 | index 37f74a2..b290f42 100644 | |||
49 | --- a/lib/lp/oci/interfaces/ocirecipe.py | |||
50 | +++ b/lib/lp/oci/interfaces/ocirecipe.py | |||
51 | @@ -383,6 +383,14 @@ class IOCIRecipeEditableAttributes(IHasOwner): | |||
52 | 383 | required=True, | 383 | required=True, |
53 | 384 | readonly=False)) | 384 | readonly=False)) |
54 | 385 | 385 | ||
55 | 386 | build_path = exported(TextLine( | ||
56 | 387 | title=_("Build directory context"), | ||
57 | 388 | description=_("Directory to use for build context " | ||
58 | 389 | "and OCIRecipe.build_file location."), | ||
59 | 390 | constraint=path_does_not_escape, | ||
60 | 391 | required=True, | ||
61 | 392 | readonly=False)) | ||
62 | 393 | |||
63 | 386 | build_daily = exported(Bool( | 394 | build_daily = exported(Bool( |
64 | 387 | title=_("Build daily"), | 395 | title=_("Build daily"), |
65 | 388 | required=True, | 396 | required=True, |
66 | diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py | |||
67 | index 0125114..e95c8c6 100644 | |||
68 | --- a/lib/lp/oci/model/ocirecipe.py | |||
69 | +++ b/lib/lp/oci/model/ocirecipe.py | |||
70 | @@ -145,6 +145,7 @@ class OCIRecipe(Storm, WebhookTargetMixin): | |||
71 | 145 | git_repository = Reference(git_repository_id, "GitRepository.id") | 145 | git_repository = Reference(git_repository_id, "GitRepository.id") |
72 | 146 | git_path = Unicode(name="git_path", allow_none=True) | 146 | git_path = Unicode(name="git_path", allow_none=True) |
73 | 147 | build_file = Unicode(name="build_file", allow_none=False) | 147 | build_file = Unicode(name="build_file", allow_none=False) |
74 | 148 | build_path = Unicode(name="build_path", allow_none=False) | ||
75 | 148 | 149 | ||
76 | 149 | require_virtualized = Bool(name="require_virtualized", default=True, | 150 | require_virtualized = Bool(name="require_virtualized", default=True, |
77 | 150 | allow_none=False) | 151 | allow_none=False) |
78 | @@ -156,7 +157,7 @@ class OCIRecipe(Storm, WebhookTargetMixin): | |||
79 | 156 | def __init__(self, name, registrant, owner, oci_project, git_ref, | 157 | def __init__(self, name, registrant, owner, oci_project, git_ref, |
80 | 157 | description=None, official=False, require_virtualized=True, | 158 | description=None, official=False, require_virtualized=True, |
81 | 158 | build_file=None, build_daily=False, date_created=DEFAULT, | 159 | build_file=None, build_daily=False, date_created=DEFAULT, |
83 | 159 | allow_internet=True): | 160 | allow_internet=True, build_path=None): |
84 | 160 | if not getFeatureFlag(OCI_RECIPE_ALLOW_CREATE): | 161 | if not getFeatureFlag(OCI_RECIPE_ALLOW_CREATE): |
85 | 161 | raise OCIRecipeFeatureDisabled() | 162 | raise OCIRecipeFeatureDisabled() |
86 | 162 | super(OCIRecipe, self).__init__() | 163 | super(OCIRecipe, self).__init__() |
87 | @@ -173,6 +174,7 @@ class OCIRecipe(Storm, WebhookTargetMixin): | |||
88 | 173 | self.date_last_modified = date_created | 174 | self.date_last_modified = date_created |
89 | 174 | self.git_ref = git_ref | 175 | self.git_ref = git_ref |
90 | 175 | self.allow_internet = allow_internet | 176 | self.allow_internet = allow_internet |
91 | 177 | self.build_path = build_path | ||
92 | 176 | 178 | ||
93 | 177 | def __repr__(self): | 179 | def __repr__(self): |
94 | 178 | return "<OCIRecipe ~%s/%s/+oci/%s/+recipe/%s>" % ( | 180 | return "<OCIRecipe ~%s/%s/+oci/%s/+recipe/%s>" % ( |
95 | @@ -532,7 +534,7 @@ class OCIRecipeSet: | |||
96 | 532 | def new(self, name, registrant, owner, oci_project, git_ref, build_file, | 534 | def new(self, name, registrant, owner, oci_project, git_ref, build_file, |
97 | 533 | description=None, official=False, require_virtualized=True, | 535 | description=None, official=False, require_virtualized=True, |
98 | 534 | build_daily=False, processors=None, date_created=DEFAULT, | 536 | build_daily=False, processors=None, date_created=DEFAULT, |
100 | 535 | allow_internet=True): | 537 | allow_internet=True, build_path=None): |
101 | 536 | """See `IOCIRecipeSet`.""" | 538 | """See `IOCIRecipeSet`.""" |
102 | 537 | if not registrant.inTeam(owner): | 539 | if not registrant.inTeam(owner): |
103 | 538 | if owner.is_team: | 540 | if owner.is_team: |
104 | @@ -550,11 +552,14 @@ class OCIRecipeSet: | |||
105 | 550 | if self.exists(owner, oci_project, name): | 552 | if self.exists(owner, oci_project, name): |
106 | 551 | raise DuplicateOCIRecipeName | 553 | raise DuplicateOCIRecipeName |
107 | 552 | 554 | ||
108 | 555 | if build_path is None: | ||
109 | 556 | build_path = "." | ||
110 | 557 | |||
111 | 553 | store = IMasterStore(OCIRecipe) | 558 | store = IMasterStore(OCIRecipe) |
112 | 554 | oci_recipe = OCIRecipe( | 559 | oci_recipe = OCIRecipe( |
113 | 555 | name, registrant, owner, oci_project, git_ref, description, | 560 | name, registrant, owner, oci_project, git_ref, description, |
114 | 556 | official, require_virtualized, build_file, build_daily, | 561 | official, require_virtualized, build_file, build_daily, |
116 | 557 | date_created, allow_internet) | 562 | date_created, allow_internet, build_path) |
117 | 558 | store.add(oci_recipe) | 563 | store.add(oci_recipe) |
118 | 559 | 564 | ||
119 | 560 | if processors is None: | 565 | if processors is None: |
120 | diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py | |||
121 | index fce6dd3..844a2c8 100644 | |||
122 | --- a/lib/lp/oci/model/ocirecipebuildbehaviour.py | |||
123 | +++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py | |||
124 | @@ -96,6 +96,7 @@ class OCIRecipeBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase): | |||
125 | 96 | logger=logger)) | 96 | logger=logger)) |
126 | 97 | 97 | ||
127 | 98 | args['build_file'] = build.recipe.build_file | 98 | args['build_file'] = build.recipe.build_file |
128 | 99 | args['build_path'] = build.recipe.build_path | ||
129 | 99 | 100 | ||
130 | 100 | if build.recipe.git_ref is not None: | 101 | if build.recipe.git_ref is not None: |
131 | 101 | args["git_repository"] = ( | 102 | args["git_repository"] = ( |
132 | diff --git a/lib/lp/oci/templates/ocirecipe-index.pt b/lib/lp/oci/templates/ocirecipe-index.pt | |||
133 | index 21a6939..c2ef69e 100644 | |||
134 | --- a/lib/lp/oci/templates/ocirecipe-index.pt | |||
135 | +++ b/lib/lp/oci/templates/ocirecipe-index.pt | |||
136 | @@ -56,6 +56,11 @@ | |||
137 | 56 | <span tal:content="context/build_file"/> | 56 | <span tal:content="context/build_file"/> |
138 | 57 | <a tal:replace="structure view/menu:overview/edit/fmt:icon"/> | 57 | <a tal:replace="structure view/menu:overview/edit/fmt:icon"/> |
139 | 58 | </dd> | 58 | </dd> |
140 | 59 | <dt>Build context directory:</dt> | ||
141 | 60 | <dd> | ||
142 | 61 | <span tal:content="context/build_path"/> | ||
143 | 62 | <a tal:replace="structure view/menu:overview/edit/fmt:icon"/> | ||
144 | 63 | </dd> | ||
145 | 59 | </dl> | 64 | </dl> |
146 | 60 | <dl id="build-schedule"> | 65 | <dl id="build-schedule"> |
147 | 61 | <dt>Build schedule:</dt> | 66 | <dt>Build schedule:</dt> |
148 | diff --git a/lib/lp/oci/templates/ocirecipe-new.pt b/lib/lp/oci/templates/ocirecipe-new.pt | |||
149 | index e5f2686..0bc156a 100644 | |||
150 | --- a/lib/lp/oci/templates/ocirecipe-new.pt | |||
151 | +++ b/lib/lp/oci/templates/ocirecipe-new.pt | |||
152 | @@ -29,6 +29,9 @@ | |||
153 | 29 | <tal:widget define="widget nocall:view/widgets/build_file"> | 29 | <tal:widget define="widget nocall:view/widgets/build_file"> |
154 | 30 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> | 30 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
155 | 31 | </tal:widget> | 31 | </tal:widget> |
156 | 32 | <tal:widget define="widget nocall:view/widgets/build_path"> | ||
157 | 33 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> | ||
158 | 34 | </tal:widget> | ||
159 | 32 | <tal:widget define="widget nocall:view/widgets/build_daily"> | 35 | <tal:widget define="widget nocall:view/widgets/build_daily"> |
160 | 33 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> | 36 | <metal:block use-macro="context/@@launchpad_form/widget_row" /> |
161 | 34 | </tal:widget> | 37 | </tal:widget> |
162 | diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py | |||
163 | index 880c351..024b8e7 100644 | |||
164 | --- a/lib/lp/oci/tests/test_ocirecipe.py | |||
165 | +++ b/lib/lp/oci/tests/test_ocirecipe.py | |||
166 | @@ -799,7 +799,8 @@ class TestOCIRecipeSet(TestCaseWithFactory): | |||
167 | 799 | description='a description', | 799 | description='a description', |
168 | 800 | official=False, | 800 | official=False, |
169 | 801 | require_virtualized=False, | 801 | require_virtualized=False, |
171 | 802 | build_file='build file') | 802 | build_file='build file', |
172 | 803 | build_path='build path') | ||
173 | 803 | self.assertEqual(target.registrant, registrant) | 804 | self.assertEqual(target.registrant, registrant) |
174 | 804 | self.assertEqual(target.owner, owner) | 805 | self.assertEqual(target.owner, owner) |
175 | 805 | self.assertEqual(target.oci_project, oci_project) | 806 | self.assertEqual(target.oci_project, oci_project) |
176 | @@ -992,7 +993,8 @@ class TestOCIRecipeWebservice(OCIConfigHelperMixin, TestCaseWithFactory): | |||
177 | 992 | git_ref_link=Equals(self.getAbsoluteURL(recipe.git_ref)), | 993 | git_ref_link=Equals(self.getAbsoluteURL(recipe.git_ref)), |
178 | 993 | description=Equals(recipe.description), | 994 | description=Equals(recipe.description), |
179 | 994 | build_file=Equals(recipe.build_file), | 995 | build_file=Equals(recipe.build_file), |
181 | 995 | build_daily=Equals(recipe.build_daily) | 996 | build_daily=Equals(recipe.build_daily), |
182 | 997 | build_path=Equals(recipe.build_path) | ||
183 | 996 | ))) | 998 | ))) |
184 | 997 | 999 | ||
185 | 998 | def test_api_patch_oci_recipe(self): | 1000 | def test_api_patch_oci_recipe(self): |
186 | diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py | |||
187 | index 3fdf8b4..bbc1ee6 100644 | |||
188 | --- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py | |||
189 | +++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py | |||
190 | @@ -242,6 +242,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory): | |||
191 | 242 | "archives": Equals(expected_archives), | 242 | "archives": Equals(expected_archives), |
192 | 243 | "arch_tag": Equals("i386"), | 243 | "arch_tag": Equals("i386"), |
193 | 244 | "build_file": Equals(job.build.recipe.build_file), | 244 | "build_file": Equals(job.build.recipe.build_file), |
194 | 245 | "build_path": Equals(job.build.recipe.build_path), | ||
195 | 245 | "build_url": Equals(canonical_url(job.build)), | 246 | "build_url": Equals(canonical_url(job.build)), |
196 | 246 | "fast_cleanup": Is(True), | 247 | "fast_cleanup": Is(True), |
197 | 247 | "git_repository": Equals(ref.repository.git_https_url), | 248 | "git_repository": Equals(ref.repository.git_https_url), |
198 | @@ -272,6 +273,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory): | |||
199 | 272 | "archives": Equals(expected_archives), | 273 | "archives": Equals(expected_archives), |
200 | 273 | "arch_tag": Equals("i386"), | 274 | "arch_tag": Equals("i386"), |
201 | 274 | "build_file": Equals(job.build.recipe.build_file), | 275 | "build_file": Equals(job.build.recipe.build_file), |
202 | 276 | "build_path": Equals(job.build.recipe.build_path), | ||
203 | 275 | "build_url": Equals(canonical_url(job.build)), | 277 | "build_url": Equals(canonical_url(job.build)), |
204 | 276 | "fast_cleanup": Is(True), | 278 | "fast_cleanup": Is(True), |
205 | 277 | "git_repository": Equals(ref.repository.git_https_url), | 279 | "git_repository": Equals(ref.repository.git_https_url), |
206 | diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py | |||
207 | index 45d64f0..fb9d56b 100644 | |||
208 | --- a/lib/lp/testing/factory.py | |||
209 | +++ b/lib/lp/testing/factory.py | |||
210 | @@ -4999,7 +4999,7 @@ class BareLaunchpadObjectFactory(ObjectFactory): | |||
211 | 4999 | oci_project=None, git_ref=None, description=None, | 4999 | oci_project=None, git_ref=None, description=None, |
212 | 5000 | official=False, require_virtualized=True, | 5000 | official=False, require_virtualized=True, |
213 | 5001 | build_file=None, date_created=DEFAULT, | 5001 | build_file=None, date_created=DEFAULT, |
215 | 5002 | allow_internet=True): | 5002 | allow_internet=True, build_path=None): |
216 | 5003 | """Make a new OCIRecipe.""" | 5003 | """Make a new OCIRecipe.""" |
217 | 5004 | if name is None: | 5004 | if name is None: |
218 | 5005 | name = self.getUniqueString(u"oci-recipe-name") | 5005 | name = self.getUniqueString(u"oci-recipe-name") |
219 | @@ -5015,6 +5015,8 @@ class BareLaunchpadObjectFactory(ObjectFactory): | |||
220 | 5015 | [git_ref] = self.makeGitRefs() | 5015 | [git_ref] = self.makeGitRefs() |
221 | 5016 | if build_file is None: | 5016 | if build_file is None: |
222 | 5017 | build_file = self.getUniqueUnicode(u"build_file_for") | 5017 | build_file = self.getUniqueUnicode(u"build_file_for") |
223 | 5018 | if build_path is None: | ||
224 | 5019 | build_path = self.getUniqueUnicode(u"build_path_for") | ||
225 | 5018 | return getUtility(IOCIRecipeSet).new( | 5020 | return getUtility(IOCIRecipeSet).new( |
226 | 5019 | name=name, | 5021 | name=name, |
227 | 5020 | registrant=registrant, | 5022 | registrant=registrant, |
228 | @@ -5022,6 +5024,7 @@ class BareLaunchpadObjectFactory(ObjectFactory): | |||
229 | 5022 | oci_project=oci_project, | 5024 | oci_project=oci_project, |
230 | 5023 | git_ref=git_ref, | 5025 | git_ref=git_ref, |
231 | 5024 | build_file=build_file, | 5026 | build_file=build_file, |
232 | 5027 | build_path=build_path, | ||
233 | 5025 | description=description, | 5028 | description=description, |
234 | 5026 | official=official, | 5029 | official=official, |
235 | 5027 | require_virtualized=require_virtualized, | 5030 | require_virtualized=require_virtualized, |
looks good to me.