mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: update repository names to support special characters in configuration files
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -10,7 +10,7 @@ configurations:
|
||||
sources: []
|
||||
apk:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'APK_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('APK_REPO_PORT' if scheme == 'https' else 'APK_REPO_HTTP_PORT') | env }}/
|
||||
url_to_replace: https://dl-cdn.alpinelinux.org/*
|
||||
|
||||
@@ -25,7 +25,7 @@ configurations:
|
||||
repositories: []
|
||||
go:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'GO_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('GO_REPO_PORT' if scheme == 'https' else 'GO_REPO_HTTP_PORT') | env }}/
|
||||
ruby:
|
||||
|
||||
@@ -21,7 +21,7 @@ configurations:
|
||||
repositories: []
|
||||
npm:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'NPM_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('NPM_REPO_PORT' if scheme == 'https' else 'NPM_REPO_HTTP_PORT') | env }}/
|
||||
rust:
|
||||
|
||||
@@ -29,6 +29,6 @@ configurations:
|
||||
repositories: []
|
||||
nuget:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'NUGET_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('NUGET_REPO_PORT' if scheme == 'https' else 'NUGET_REPO_HTTP_PORT') | env }}/index.json
|
||||
|
||||
@@ -19,7 +19,7 @@ configurations:
|
||||
repositories: []
|
||||
php:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'PHP_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('PHP_REPO_PORT' if scheme == 'https' else 'PHP_REPO_HTTP_PORT') | env }}/
|
||||
npm:
|
||||
|
||||
@@ -15,7 +15,7 @@ configurations:
|
||||
keys: []
|
||||
python:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'PYPI_REPO_SCHEME' | env %}
|
||||
index-url: {{ scheme }}://host.docker.internal:{{ ('PYPI_REPO_PORT' if scheme == 'https' else 'PYPI_REPO_HTTP_PORT') | env }}/simple/
|
||||
java:
|
||||
|
||||
@@ -27,7 +27,7 @@ configurations:
|
||||
repositories: []
|
||||
ruby:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'RUBY_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('RUBY_REPO_PORT' if scheme == 'https' else 'RUBY_REPO_HTTP_PORT') | env }}/
|
||||
nuget:
|
||||
|
||||
@@ -23,7 +23,7 @@ configurations:
|
||||
repositories: []
|
||||
rust:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'CARGO_REPO_SCHEME' | env %}
|
||||
url: {{ scheme }}://host.docker.internal:{{ ('CARGO_REPO_PORT' if scheme == 'https' else 'CARGO_REPO_HTTP_PORT') | env }}/
|
||||
is_sparse: true
|
||||
|
||||
@@ -12,7 +12,7 @@ configurations:
|
||||
repositories: []
|
||||
yum:
|
||||
repositories:
|
||||
- name: demo
|
||||
- name: 'demo _.-/\$.:@;''"'
|
||||
{% set scheme = 'YUM_REPO_SCHEME' | env %}
|
||||
index-url: {{ scheme }}://host.docker.internal:{{ ('YUM_REPO_PORT' if scheme == 'https' else 'YUM_REPO_HTTP_PORT') | env }}/
|
||||
index-url-to-replace: https://mirrors.rockylinux.org/*
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import tomllib
|
||||
|
||||
from id_configurator.config import Configuration
|
||||
from id_configurator.context import Context
|
||||
from id_configurator.modules.python import PythonModule
|
||||
@@ -76,6 +78,33 @@ def test_apply_single_repository(tmp_path) -> None:
|
||||
assert not (dst / "usr/lib").exists()
|
||||
|
||||
|
||||
def test_apply_escapes_non_bmp_characters_as_valid_toml(tmp_path) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
"organisation": "InterDiode",
|
||||
"configurations": {
|
||||
"python": {
|
||||
"repositories": [
|
||||
{"name": "demo 😀", "index-url": "https://example.invalid/simple"}
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
config = Configuration.model_validate(data)
|
||||
dst = tmp_path / "dst"
|
||||
context = Context(config=config, dst=dst, src=None)
|
||||
|
||||
PythonModule().apply(context)
|
||||
|
||||
uv_toml = (dst / "etc/uv/uv.toml").read_text(encoding="utf-8")
|
||||
# json.dumps's default ensure_ascii=True would encode the emoji as a
|
||||
# UTF-16 surrogate pair (😀), which is valid JSON but not
|
||||
# valid TOML (TOML's \uXXXX must be a Unicode scalar value on its own).
|
||||
assert '"demo 😀"' in uv_toml
|
||||
parsed = tomllib.loads(uv_toml)
|
||||
assert parsed["index"][0]["name"] == "demo 😀"
|
||||
|
||||
|
||||
def test_apply_adds_trusted_host_for_non_https_repository(tmp_path) -> None:
|
||||
data = {
|
||||
"uuid": "12345678-1234-5678-1234-567812345678",
|
||||
|
||||
Reference in New Issue
Block a user