mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-11-15 13:26:15 +08:00
fix: block VM creation/save with invalid CloudInit YAML (#1040)
* fix(vm): block VM creation with invalid CloudInit YAML content * fix(vm): add isWindows guard to validateCloudInit in template version * fix: validate Windows CloudInit YAML on save Co-authored-by: a110605 <5744158+a110605@users.noreply.github.com> * fix: validate cloud-init by format in the VM mixin Cloud-init picks the user data format from the first line, so scripts, MIME messages and Jinja templates are valid without being YAML. Parsing all user data blocked them, and it stopped any existing VM holding one from being saved, even with nothing changed. Only parse user data that starts with #cloud-config, and require a mapping for it and for network data, because plain words are valid YAML and were still saved. Both forms already use the VM mixin, so the check moves there and shares the header pattern with hasCloudConfigComment. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> * fix: save other user data formats as typed and check text without a header The form added #cloud-config to any user data that parses as YAML, so a script was saved with the header and its lines folded together, and Edit Config then failed the check on it. User data that starts with a script, MIME or another cloud-init or Cloudbase-Init format is now saved as typed, and any other text is checked as cloud-config, with or without the header, because the form adds the header when saving it. Editing only checks cloud-init that changed, so a VM saved before this change can still be edited with the cloud-init it already has. Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> --------- Signed-off-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: a110605 <5744158+a110605@users.noreply.github.com> Co-authored-by: Marcelo Fukumoto <marcelo.fukumoto@suse.com>
This commit is contained in:
co-authored by
a110605
Marcelo Fukumoto
parent
67ff2777d6
commit
aa6d11a840
@@ -179,8 +179,17 @@ export default {
|
||||
},
|
||||
|
||||
async saveVMT(buttonCb) {
|
||||
this.errors = [];
|
||||
this.parseVM();
|
||||
|
||||
this.validateCloudInit();
|
||||
|
||||
if (this.errors.length) {
|
||||
buttonCb(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const templates = await this.$store.dispatch('harvester/findAll', { type: HCI.VM_TEMPLATE });
|
||||
const template = templates.find( (O) => O.metadata.name === this.templateValue.metadata.name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user