Skip to content

Commit 9f16b0a

Browse files
authored
feat(service): allow setting default CLI version for project creation (#3415)
1 parent 00a1963 commit 9f16b0a

File tree

5 files changed

+42
-5
lines changed

5 files changed

+42
-5
lines changed

helm-chart/renku-core/templates/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ spec:
137137
value: {{ $.Values.gitLFSSkipSmudge | quote }}
138138
- name: RENKU_DOMAIN
139139
value: {{ $.Values.global.renku.domain }}
140+
- name: RENKU_PROJECT_DEFAULT_CLI_VERSION
141+
value: {{ $.Values.global.renku.cli_version | default "" | quote }}
140142
{{- include "certificates.env.python" $ | nindent 12 }}
141143
volumeMounts:
142144
- name: shared-volume

renku/command/command_builder/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def _injection_pre_hook(self, builder: Command, context: dict, *args, **kwargs)
9292

9393
current_version = Version(__version__)
9494

95-
if current_version < minimum_renku_version:
95+
if Version(current_version.base_version) < minimum_renku_version:
9696
raise errors.MinimumVersionError(current_version, minimum_renku_version)
9797

9898
def _post_hook(self, builder: Command, context: dict, result: CommandResult, *args, **kwargs) -> None:

renku/ui/service/controllers/templates_create_project.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
"""Renku service template create project controller."""
18+
import os
1819
import shutil
1920
from typing import Any, Dict, Optional, cast
2021

@@ -72,8 +73,10 @@ def default_metadata(self):
7273
"__project_slug__": self.ctx["project_slug"],
7374
"__project_description__": self.ctx["project_description"],
7475
}
75-
if is_release():
76-
metadata["__renku_version__"] = __version__
76+
77+
cli_version = os.environ.get("RENKU_PROJECT_DEFAULT_CLI_VERSION") or __version__
78+
if is_release(cli_version):
79+
metadata["__renku_version__"] = cli_version
7780

7881
return metadata
7982

renku/version.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"""Version information for Renku."""
1717

1818
import re
19+
from typing import Optional
1920

2021
try:
2122
from importlib.metadata import distribution, version
@@ -27,9 +28,12 @@
2728
__minimum_project_version__ = "2.4.0"
2829

2930

30-
def is_release():
31+
def is_release(version: Optional[str] = None):
3132
"""Check if current version is a release semver."""
32-
if re.match(r"\d+.\d+.\d+$", __version__):
33+
if not version:
34+
version = __version__
35+
36+
if re.match(r"\d+.\d+.\d+(rc\d+)?$", version):
3337
return True
3438
return False
3539

tests/service/controllers/test_templates_create_project.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,31 @@ def test_except_project_name_handler(project_name, ctrl_init, svc_client_templat
159159
TemplatesCreateProjectCtrl(cache, user_data, payload)
160160

161161
assert "Project name contains only unsupported characters" in str(exc_info.value)
162+
163+
164+
def test_template_create_project_with_custom_cli_ctrl(
165+
ctrl_init, svc_cache_dir, svc_client_templates_creation, mocker, monkeypatch
166+
):
167+
"""Test template create project controller."""
168+
monkeypatch.setenv("RENKU_PROJECT_DEFAULT_CLI_VERSION", "9.9.9rc9")
169+
from renku.ui.service.controllers.templates_create_project import TemplatesCreateProjectCtrl
170+
171+
cache, user_data = ctrl_init
172+
_, _, payload, _ = svc_client_templates_creation
173+
174+
ctrl = TemplatesCreateProjectCtrl(cache, user_data, payload)
175+
mocker.patch.object(ctrl, "new_project_push", return_value=None)
176+
response = ctrl.to_response()
177+
178+
# Check response.
179+
assert {"result"} == response.json.keys()
180+
assert {"project_id", "url", "namespace", "name", "slug"} == response.json["result"].keys()
181+
182+
cache_dir, _ = svc_cache_dir
183+
184+
project_path = (
185+
cache_dir / user_data["user_id"] / response.json["result"]["namespace"] / response.json["result"]["slug"]
186+
)
187+
188+
with open(project_path / "Dockerfile") as f:
189+
assert "ARG RENKU_VERSION=9.9.9rc9" in f.read()

0 commit comments

Comments
 (0)