mirror of https://github.com/rancher/dashboard.git
Implement Machine Pool Yaml Validation
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
parent
ab6cdfa482
commit
f65c4ce2c9
|
|
@ -1141,8 +1141,14 @@ export default {
|
|||
title: this.t('cluster.rke2.modal.editYamlMachinePool.title'),
|
||||
body: this.t('cluster.rke2.modal.editYamlMachinePool.body'),
|
||||
applyMode: 'editAndContinue',
|
||||
confirm: (confirmed) => {
|
||||
confirm: async(confirmed) => {
|
||||
if (confirmed) {
|
||||
await this.validateMachinePool();
|
||||
|
||||
if (this.errors.length) {
|
||||
reject(new Error('Machine Pool validation errors'));
|
||||
}
|
||||
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error('User Cancelled'));
|
||||
|
|
@ -1290,10 +1296,6 @@ export default {
|
|||
// We cannot use the hook, because it is triggered on YAML toggle without restore initialized data
|
||||
this.agentConfigurationCleanup();
|
||||
|
||||
if ( this.errors ) {
|
||||
clear(this.errors);
|
||||
}
|
||||
|
||||
const isEditVersion = this.isEdit && this.liveValue?.spec?.kubernetesVersion !== this.value?.spec?.kubernetesVersion;
|
||||
|
||||
if (isEditVersion) {
|
||||
|
|
@ -1304,31 +1306,7 @@ export default {
|
|||
}
|
||||
}
|
||||
|
||||
if (this.value.cloudProvider === 'aws') {
|
||||
const missingProfileName = this.machinePools.some((mp) => !mp.config.iamInstanceProfile);
|
||||
|
||||
if (missingProfileName) {
|
||||
this.errors.push(this.t('cluster.validation.iamInstanceProfileName', {}, true));
|
||||
}
|
||||
}
|
||||
|
||||
for (const [index] of this.machinePools.entries()) { // validator machine config
|
||||
if ( typeof this.$refs.pool[index]?.test === 'function' ) {
|
||||
try {
|
||||
const res = await this.$refs.pool[index].test();
|
||||
|
||||
if (Array.isArray(res) && res.length > 0) {
|
||||
this.errors.push(...res);
|
||||
}
|
||||
} catch (e) {
|
||||
this.errors.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.value.metadata.name && this.agentConfig['cloud-provider-name'] === HARVESTER) {
|
||||
this.errors.push(this.t('validation.required', { key: this.t('cluster.name.label') }, true));
|
||||
}
|
||||
await this.validateMachinePool();
|
||||
|
||||
if (this.errors.length) {
|
||||
btnCb(false);
|
||||
|
|
@ -1995,8 +1973,39 @@ export default {
|
|||
},
|
||||
handleRegistrySecretChanged(neu) {
|
||||
this.registrySecret = neu;
|
||||
}
|
||||
},
|
||||
|
||||
async validateMachinePool() {
|
||||
if (this.errors) {
|
||||
clear(this.errors);
|
||||
}
|
||||
if (this.value.cloudProvider === 'aws') {
|
||||
const missingProfileName = this.machinePools.some((mp) => !mp.config.iamInstanceProfile);
|
||||
|
||||
if (missingProfileName) {
|
||||
this.errors.push(this.t('cluster.validation.iamInstanceProfileName', {}, true));
|
||||
}
|
||||
}
|
||||
|
||||
for (const [index] of this.machinePools.entries()) { // validator machine config
|
||||
if ( typeof this.$refs.pool[index]?.test === 'function' ) {
|
||||
try {
|
||||
const res = await this.$refs.pool[index].test();
|
||||
|
||||
if (Array.isArray(res) && res.length > 0) {
|
||||
this.errors.push(...res);
|
||||
}
|
||||
} catch (e) {
|
||||
this.errors.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.value.metadata.name && this.agentConfig['cloud-provider-name'] === HARVESTER) {
|
||||
this.errors.push(this.t('validation.required', { key: this.t('cluster.name.label') }, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue