launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25175
[Merge] ~twom/launchpad:oci-build-path-ui into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:oci-build-path-ui into launchpad:master.
Commit message:
Add build_path to OCI UI
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/389415
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:oci-build-path-ui into launchpad:master.
diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py
index 3dd764c..15a2b14 100644
--- a/lib/lp/oci/browser/ocirecipe.py
+++ b/lib/lp/oci/browser/ocirecipe.py
@@ -505,6 +505,7 @@ class IOCIRecipeEditSchema(Interface):
"description",
"git_ref",
"build_file",
+ "build_path",
"build_daily",
"require_virtualized",
"allow_internet",
@@ -523,6 +524,7 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin):
"description",
"git_ref",
"build_file",
+ "build_path",
"build_daily",
)
custom_widget_git_ref = GitRefWidget
@@ -557,6 +559,7 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin):
return {
"owner": self.user,
"build_file": "Dockerfile",
+ "build_path": ".",
"processors": [
p for p in getUtility(IProcessorSet).getAll()
if p.build_by_default],
@@ -580,7 +583,8 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin):
recipe = getUtility(IOCIRecipeSet).new(
name=data["name"], registrant=self.user, owner=data["owner"],
oci_project=self.context, git_ref=data["git_ref"],
- build_file=data["build_file"], description=data["description"],
+ build_file=data["build_file"], build_path=data["build_path"],
+ description=data["description"],
build_daily=data["build_daily"], processors=data["processors"])
self.next_url = canonical_url(recipe)
@@ -638,6 +642,7 @@ class OCIRecipeEditView(BaseOCIRecipeEditView, EnableProcessorsMixin):
"description",
"git_ref",
"build_file",
+ "build_path",
"build_daily",
)
custom_widget_git_ref = GitRefWidget
diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py
index 37f74a2..b290f42 100644
--- a/lib/lp/oci/interfaces/ocirecipe.py
+++ b/lib/lp/oci/interfaces/ocirecipe.py
@@ -383,6 +383,14 @@ class IOCIRecipeEditableAttributes(IHasOwner):
required=True,
readonly=False))
+ build_path = exported(TextLine(
+ title=_("Build directory context"),
+ description=_("Directory to use for build context "
+ "and OCIRecipe.build_file location."),
+ constraint=path_does_not_escape,
+ required=True,
+ readonly=False))
+
build_daily = exported(Bool(
title=_("Build daily"),
required=True,
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index 0125114..e95c8c6 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -145,6 +145,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
git_repository = Reference(git_repository_id, "GitRepository.id")
git_path = Unicode(name="git_path", allow_none=True)
build_file = Unicode(name="build_file", allow_none=False)
+ build_path = Unicode(name="build_path", allow_none=False)
require_virtualized = Bool(name="require_virtualized", default=True,
allow_none=False)
@@ -156,7 +157,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
def __init__(self, name, registrant, owner, oci_project, git_ref,
description=None, official=False, require_virtualized=True,
build_file=None, build_daily=False, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
if not getFeatureFlag(OCI_RECIPE_ALLOW_CREATE):
raise OCIRecipeFeatureDisabled()
super(OCIRecipe, self).__init__()
@@ -173,6 +174,7 @@ class OCIRecipe(Storm, WebhookTargetMixin):
self.date_last_modified = date_created
self.git_ref = git_ref
self.allow_internet = allow_internet
+ self.build_path = build_path
def __repr__(self):
return "<OCIRecipe ~%s/%s/+oci/%s/+recipe/%s>" % (
@@ -532,7 +534,7 @@ class OCIRecipeSet:
def new(self, name, registrant, owner, oci_project, git_ref, build_file,
description=None, official=False, require_virtualized=True,
build_daily=False, processors=None, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
"""See `IOCIRecipeSet`."""
if not registrant.inTeam(owner):
if owner.is_team:
@@ -550,11 +552,14 @@ class OCIRecipeSet:
if self.exists(owner, oci_project, name):
raise DuplicateOCIRecipeName
+ if build_path is None:
+ build_path = "."
+
store = IMasterStore(OCIRecipe)
oci_recipe = OCIRecipe(
name, registrant, owner, oci_project, git_ref, description,
official, require_virtualized, build_file, build_daily,
- date_created, allow_internet)
+ date_created, allow_internet, build_path)
store.add(oci_recipe)
if processors is None:
diff --git a/lib/lp/oci/model/ocirecipebuildbehaviour.py b/lib/lp/oci/model/ocirecipebuildbehaviour.py
index fce6dd3..844a2c8 100644
--- a/lib/lp/oci/model/ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/model/ocirecipebuildbehaviour.py
@@ -96,6 +96,7 @@ class OCIRecipeBuildBehaviour(SnapProxyMixin, BuildFarmJobBehaviourBase):
logger=logger))
args['build_file'] = build.recipe.build_file
+ args['build_path'] = build.recipe.build_path
if build.recipe.git_ref is not None:
args["git_repository"] = (
diff --git a/lib/lp/oci/templates/ocirecipe-index.pt b/lib/lp/oci/templates/ocirecipe-index.pt
index 21a6939..c2ef69e 100644
--- a/lib/lp/oci/templates/ocirecipe-index.pt
+++ b/lib/lp/oci/templates/ocirecipe-index.pt
@@ -56,6 +56,11 @@
<span tal:content="context/build_file"/>
<a tal:replace="structure view/menu:overview/edit/fmt:icon"/>
</dd>
+ <dt>Build context directory:</dt>
+ <dd>
+ <span tal:content="context/build_path"/>
+ <a tal:replace="structure view/menu:overview/edit/fmt:icon"/>
+ </dd>
</dl>
<dl id="build-schedule">
<dt>Build schedule:</dt>
diff --git a/lib/lp/oci/templates/ocirecipe-new.pt b/lib/lp/oci/templates/ocirecipe-new.pt
index e5f2686..0bc156a 100644
--- a/lib/lp/oci/templates/ocirecipe-new.pt
+++ b/lib/lp/oci/templates/ocirecipe-new.pt
@@ -29,6 +29,9 @@
<tal:widget define="widget nocall:view/widgets/build_file">
<metal:block use-macro="context/@@launchpad_form/widget_row" />
</tal:widget>
+ <tal:widget define="widget nocall:view/widgets/build_path">
+ <metal:block use-macro="context/@@launchpad_form/widget_row" />
+ </tal:widget>
<tal:widget define="widget nocall:view/widgets/build_daily">
<metal:block use-macro="context/@@launchpad_form/widget_row" />
</tal:widget>
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index 880c351..024b8e7 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -799,7 +799,8 @@ class TestOCIRecipeSet(TestCaseWithFactory):
description='a description',
official=False,
require_virtualized=False,
- build_file='build file')
+ build_file='build file',
+ build_path='build path')
self.assertEqual(target.registrant, registrant)
self.assertEqual(target.owner, owner)
self.assertEqual(target.oci_project, oci_project)
@@ -992,7 +993,8 @@ class TestOCIRecipeWebservice(OCIConfigHelperMixin, TestCaseWithFactory):
git_ref_link=Equals(self.getAbsoluteURL(recipe.git_ref)),
description=Equals(recipe.description),
build_file=Equals(recipe.build_file),
- build_daily=Equals(recipe.build_daily)
+ build_daily=Equals(recipe.build_daily),
+ build_path=Equals(recipe.build_path)
)))
def test_api_patch_oci_recipe(self):
diff --git a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
index 3fdf8b4..bbc1ee6 100644
--- a/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
+++ b/lib/lp/oci/tests/test_ocirecipebuildbehaviour.py
@@ -242,6 +242,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory):
"archives": Equals(expected_archives),
"arch_tag": Equals("i386"),
"build_file": Equals(job.build.recipe.build_file),
+ "build_path": Equals(job.build.recipe.build_path),
"build_url": Equals(canonical_url(job.build)),
"fast_cleanup": Is(True),
"git_repository": Equals(ref.repository.git_https_url),
@@ -272,6 +273,7 @@ class TestAsyncOCIRecipeBuildBehaviour(MakeOCIBuildMixin, TestCaseWithFactory):
"archives": Equals(expected_archives),
"arch_tag": Equals("i386"),
"build_file": Equals(job.build.recipe.build_file),
+ "build_path": Equals(job.build.recipe.build_path),
"build_url": Equals(canonical_url(job.build)),
"fast_cleanup": Is(True),
"git_repository": Equals(ref.repository.git_https_url),
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 45d64f0..fb9d56b 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -4999,7 +4999,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
oci_project=None, git_ref=None, description=None,
official=False, require_virtualized=True,
build_file=None, date_created=DEFAULT,
- allow_internet=True):
+ allow_internet=True, build_path=None):
"""Make a new OCIRecipe."""
if name is None:
name = self.getUniqueString(u"oci-recipe-name")
@@ -5015,6 +5015,8 @@ class BareLaunchpadObjectFactory(ObjectFactory):
[git_ref] = self.makeGitRefs()
if build_file is None:
build_file = self.getUniqueUnicode(u"build_file_for")
+ if build_path is None:
+ build_path = self.getUniqueUnicode(u"build_path_for")
return getUtility(IOCIRecipeSet).new(
name=name,
registrant=registrant,
@@ -5022,6 +5024,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
oci_project=oci_project,
git_ref=git_ref,
build_file=build_file,
+ build_path=build_path,
description=description,
official=official,
require_virtualized=require_virtualized,