diff --git a/renku/ui/service/controllers/templates_create_project.py b/renku/ui/service/controllers/templates_create_project.py index b6a94e00cb..d01220d7a7 100644 --- a/renku/ui/service/controllers/templates_create_project.py +++ b/renku/ui/service/controllers/templates_create_project.py @@ -66,7 +66,7 @@ def default_metadata(self): metadata = { "__template_source__": self.ctx["template_git_url"], - "__template_ref__": self.ctx["branch"], + "__template_ref__": self.ctx["ref"], "__template_id__": self.ctx["identifier"], "__namespace__": self.ctx["project_namespace"], "__repository__": self.ctx["project_repository"], @@ -117,7 +117,7 @@ def setup_new_project(self): def setup_template(self): """Reads template manifest.""" - templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["branch"]) + templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["ref"]) identifier = self.ctx["identifier"] try: self.template = templates_source.get_template(id=identifier, reference=None) diff --git a/renku/ui/service/controllers/templates_read_manifest.py b/renku/ui/service/controllers/templates_read_manifest.py index 7a54e35c29..b3e374e4e7 100644 --- a/renku/ui/service/controllers/templates_read_manifest.py +++ b/renku/ui/service/controllers/templates_read_manifest.py @@ -49,7 +49,7 @@ def template_manifest(self): """Reads template manifest.""" from PIL import Image - templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["branch"]) + templates_source = fetch_templates_source(source=self.ctx["template_git_url"], reference=self.ctx["ref"]) manifest = templates_source.manifest.get_raw_content() # NOTE: convert icons to base64 diff --git a/renku/ui/service/serializers/templates.py b/renku/ui/service/serializers/templates.py index 28fc70ae0d..1154987ab3 100644 --- a/renku/ui/service/serializers/templates.py +++ b/renku/ui/service/serializers/templates.py @@ -35,16 +35,16 @@ class ManifestTemplatesRequest(Schema): template_git_url = fields.String(required=True, metadata={"description": "Template git repository url."}) depth = fields.Integer(load_default=TEMPLATE_CLONE_DEPTH_DEFAULT) - branch = fields.String(load_default=None, metadata={"description": "Remote git branch (or tag or commit SHA)."}) + ref = fields.String(load_default=None, metadata={"description": "Remote git branch (or tag or commit SHA)."}) @pre_load def set_fields(self, data, **_): - """Set `branch` field from `ref` if present and set template url.""" - if "ref" in data and not data.get("branch"): + """Set `ref` field from `branch` if present and set template url.""" + if "branch" in data and not data.get("ref"): # Backward compatibility: branch and ref were both used. Let's keep branch as the exposed field # even if internally it gets converted to "ref" later. - data["branch"] = data["ref"] - del data["ref"] + data["ref"] = data["branch"] + del data["branch"] if "url" in data and not data.get("template_git_url"): # needed for tests that share a fixture data["template_git_url"] = data["url"] diff --git a/tests/fixtures/templates.py b/tests/fixtures/templates.py index b058d46fa5..45b594d022 100644 --- a/tests/fixtures/templates.py +++ b/tests/fixtures/templates.py @@ -58,7 +58,7 @@ def template(template_metadata): "url": "https://github.com/SwissDataScienceCenter/renku-project-template", "id": "python-minimal", "index": 1, - "branch": "master", + "ref": "master", # TODO: Add template parameters here once parameters are added to the template. "metadata": {}, "default_metadata": template_metadata, @@ -83,7 +83,7 @@ def project_init(template): "init_custom": [ "init", "--template-ref", - template["branch"], + template["ref"], "--template-id", "python-minimal", data["test_project"], @@ -91,7 +91,7 @@ def project_init(template): "init_custom_template": ( "https://gitlab.dev.renku.ch/renku-python-integration-tests/core-it-template-variable-test-project" ), - "remote": ["--template-source", template["url"], "--template-ref", template["branch"]], + "remote": ["--template-source", template["url"], "--template-ref", template["ref"]], "id": ["--template-id", template["id"]], "force": ["--force"], "parameters": ["--parameter", "p1=v1", "--parameter", "p2=v2"], diff --git a/tests/service/controllers/test_templates_create_project.py b/tests/service/controllers/test_templates_create_project.py index 9459a604a9..e3945fcfad 100644 --- a/tests/service/controllers/test_templates_create_project.py +++ b/tests/service/controllers/test_templates_create_project.py @@ -56,7 +56,7 @@ def test_template_create_project_ctrl(ctrl_init, svc_client_templates_creation, "template_git_url", "project_name_stripped", "depth", - "branch", + "ref", "new_project_url_with_auth", } assert expected_context.issubset(set(ctrl.context.keys()))