Add image name input to cloud-init build process and update handling
Enhance the dashboard UI by introducing an optional input field for the image name in the cloud-init build form. Update the API to process the image name, ensuring it is sanitized and included in the build request. Modify the build script to utilize the provided image name, allowing for customized output filenames during the image creation process. This improves user experience by offering more flexibility in naming cloud-init images.
This commit is contained in:
@@ -1636,12 +1636,15 @@ def api_build_cloudinit():
|
||||
meta_data = body.get("meta_data") or DEFAULT_META_DATA
|
||||
network_config = body.get("network_config") or DEFAULT_NETWORK_CONFIG
|
||||
set_as_golden_after = bool(body.get("set_as_golden_after"))
|
||||
image_name = (body.get("image_name") or "").strip()[:64]
|
||||
image_name = re.sub(r"[^\w\-]", "", image_name) # only alphanumeric, underscore, dash
|
||||
try:
|
||||
BUILD_REQUEST_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
with open(BUILD_REQUEST_FILE, "w") as f:
|
||||
json.dump({
|
||||
"url": url,
|
||||
"variant": variant,
|
||||
"image_name": image_name or None,
|
||||
"user_data": user_data,
|
||||
"meta_data": meta_data,
|
||||
"network_config": network_config,
|
||||
|
||||
Reference in New Issue
Block a user