From 4e24a4e676f6e27ef4c57fb8b4270e3600c8bccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix-Antoine=20Fortin?= Date: Fri, 4 Sep 2026 14:31:51 -0400 Subject: [PATCH] Allow user to select the magic castle version they want --- docs/configuration.md | 7 ++ .../src/components/cluster/ClusterEditor.vue | 30 ++++++++ .../components/cluster/ClusterEditor.spec.js | 22 ++++++ mchub/configuration/__init__.py | 12 ++++ mchub/models/cloud/cloud_manager.py | 4 ++ mchub/models/magic_castle/magic_castle.py | 20 ++++++ .../magic_castle_configuration.py | 6 ++ mchub/models/template.py | 1 + mchub/models/version_constraint.py | 69 +++++++++++++++++++ mchub/resources/magic_castle_api.py | 2 + mchub/services/github_api.py | 30 ++++++++ pyproject.toml | 1 + tests/data/__init__.py | 2 + tests/mocks/configuration/config_mock.py | 3 +- tests/mocks/github_api_mock.py | 3 + tests/unit/magic_castle/test_magic_castle.py | 35 ++++++++++ .../test_magic_castle_configuration.py | 26 ++++++- .../magic_castle/test_version_constraint.py | 30 ++++++++ tests/unit/test_magic_castle_versions.py | 29 ++++++++ tests/unit/user/test_local_user.py | 1 + tests/unit/user/test_saml_user.py | 1 + uv.lock | 2 + 22 files changed, 334 insertions(+), 2 deletions(-) create mode 100644 mchub/models/version_constraint.py create mode 100644 tests/unit/magic_castle/test_version_constraint.py create mode 100644 tests/unit/test_magic_castle_versions.py diff --git a/docs/configuration.md b/docs/configuration.md index 526c4eb9..2af6cdc4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -44,6 +44,7 @@ An example `configuration.json` is shown below. "github_token": "EXAMPLE_GITHUB_TOKEN", "github_organization": "EXAMPLE_GITHUB_ORGANIZATION", "github_default_template": "owner/repo-template", + "magic_castle_version_range": ">= 14.0.0, < 15.0.0", "tfcloud_api_token": "EXAMPLE_TF_TOKEN", "tfcloud_organization": "EXAMPLE_TFCLOUD_ORGANIZATION", "tfcloud_oauth_vcs_token_id": "VCS_OAUTH_ID" @@ -158,6 +159,12 @@ Two formats are supported: - **Repository name only** (e.g. `"my-template"`): the template is looked up within `github_organization`. This supports both public and private repositories, as long as `github_token` has access to the organization. - **Full `owner/repo` reference** (e.g. `"owner/repo-template"`): the template is fetched globally. This is useful for public templates hosted outside of `github_organization`. Private repositories outside the organization are also supported if `github_token` has read access to them. +### `magic_castle_version_range` + +A Terraform-style version constraint describing the Magic Castle versions vetted by the MC Hub operator. MC Hub fetches tags from the `ComputeCanada/magic_castle` GitHub repository and presents matching versions in newest-first order. The newest matching version is selected by default. The selected value is written as `version` in the cluster's `terraform.tfvars.json` and cannot be changed after the initial plan is created. + +Multiple constraints separated by commas and the `=`, `!=`, `>`, `>=`, `<`, `<=`, and `~>` operators are supported. For example, `">= 14.0.0, < 15.0.0"` accepts version 14 releases, while `"~> 14.1.0"` accepts patch releases from 14.1. + ### `tfcloud_api_token` A [Terraform Cloud API token](https://developer.hashicorp.com/terraform/cloud-docs/users-teams-organizations/api-tokens) used to authenticate with the Terraform Cloud API. You can use either a **user token** or a **team token**, but **organization tokens are not supported** — they lack permissions required for certain operations, such as triggering a destroy run. diff --git a/frontend/src/components/cluster/ClusterEditor.vue b/frontend/src/components/cluster/ClusterEditor.vue index f6707f0d..baf401e1 100644 --- a/frontend/src/components/cluster/ClusterEditor.vue +++ b/frontend/src/components/cluster/ClusterEditor.vue @@ -42,6 +42,19 @@ {{ localSpecs.image }} + + + + Version + {{ localSpecs.version }} + +