mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-14 21:51:43 +00:00
fix #cloud-config disappear when add/remove ssh key (#273)
Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
5682bf4c3a
commit
9dd8ae479a
@ -919,7 +919,9 @@ export default {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return userDataYaml;
|
const hasCloudComment = this.hasCloudConfigComment(userDataYaml);
|
||||||
|
|
||||||
|
return hasCloudComment ? userDataYaml : `#cloud-config\n${ userDataYaml }`;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Error: Unable to parse yaml document', e); // eslint-disable-line no-console
|
console.error('Error: Unable to parse yaml document', e); // eslint-disable-line no-console
|
||||||
|
|
||||||
@ -1430,7 +1432,6 @@ export default {
|
|||||||
sshAuthorizedKeys.splice(index, 1);
|
sshAuthorizedKeys.splice(index, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const userDataJson = this.convertToJson(this.userScript);
|
const userDataJson = this.convertToJson(this.userScript);
|
||||||
|
|
||||||
userDataJson.ssh_authorized_keys = sshAuthorizedKeys;
|
userDataJson.ssh_authorized_keys = sshAuthorizedKeys;
|
||||||
@ -1552,19 +1553,9 @@ export default {
|
|||||||
*/
|
*/
|
||||||
handler(neu) {
|
handler(neu) {
|
||||||
if (this.deleteAgent) {
|
if (this.deleteAgent) {
|
||||||
let out = this.getUserData({
|
this['userScript'] = this.getUserData({
|
||||||
installAgent: neu, osType: this.osType, deletePackage: this.deletePackage
|
installAgent: neu, osType: this.osType, deletePackage: this.deletePackage
|
||||||
});
|
});
|
||||||
|
|
||||||
if (neu) {
|
|
||||||
const hasCloudComment = this.hasCloudConfigComment(out);
|
|
||||||
|
|
||||||
if (!hasCloudComment) {
|
|
||||||
out = `#cloud-config\n${ out }`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this['userScript'] = out;
|
|
||||||
this.refreshYamlEditor();
|
this.refreshYamlEditor();
|
||||||
}
|
}
|
||||||
this.deleteAgent = true;
|
this.deleteAgent = true;
|
||||||
@ -1589,15 +1580,16 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
sshKey(neu, old) {
|
sshKey(neu, old) {
|
||||||
// refresh yaml editor to get the latest userScript
|
|
||||||
this.userScript = this.getUserData({ installAgent: this.installAgent, osType: this.osType });
|
|
||||||
this.refreshYamlEditor();
|
|
||||||
|
|
||||||
const _diff = difference(old, neu);
|
const _diff = difference(old, neu);
|
||||||
|
|
||||||
|
// delete removed ssh key in userdata if needed
|
||||||
if (_diff.length > 0 && this.isCreate) {
|
if (_diff.length > 0 && this.isCreate) {
|
||||||
this.deleteSSHFromUserData(_diff);
|
this.deleteSSHFromUserData(_diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// refresh yaml editor to get the latest userScript
|
||||||
|
this.userScript = this.getUserData({ installAgent: this.installAgent, osType: this.osType });
|
||||||
|
this.refreshYamlEditor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user