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'),
|
title: this.t('cluster.rke2.modal.editYamlMachinePool.title'),
|
||||||
body: this.t('cluster.rke2.modal.editYamlMachinePool.body'),
|
body: this.t('cluster.rke2.modal.editYamlMachinePool.body'),
|
||||||
applyMode: 'editAndContinue',
|
applyMode: 'editAndContinue',
|
||||||
confirm: (confirmed) => {
|
confirm: async(confirmed) => {
|
||||||
if (confirmed) {
|
if (confirmed) {
|
||||||
|
await this.validateMachinePool();
|
||||||
|
|
||||||
|
if (this.errors.length) {
|
||||||
|
reject(new Error('Machine Pool validation errors'));
|
||||||
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(new Error('User Cancelled'));
|
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
|
// We cannot use the hook, because it is triggered on YAML toggle without restore initialized data
|
||||||
this.agentConfigurationCleanup();
|
this.agentConfigurationCleanup();
|
||||||
|
|
||||||
if ( this.errors ) {
|
|
||||||
clear(this.errors);
|
|
||||||
}
|
|
||||||
|
|
||||||
const isEditVersion = this.isEdit && this.liveValue?.spec?.kubernetesVersion !== this.value?.spec?.kubernetesVersion;
|
const isEditVersion = this.isEdit && this.liveValue?.spec?.kubernetesVersion !== this.value?.spec?.kubernetesVersion;
|
||||||
|
|
||||||
if (isEditVersion) {
|
if (isEditVersion) {
|
||||||
|
|
@ -1304,31 +1306,7 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.value.cloudProvider === 'aws') {
|
await this.validateMachinePool();
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.errors.length) {
|
if (this.errors.length) {
|
||||||
btnCb(false);
|
btnCb(false);
|
||||||
|
|
@ -1995,8 +1973,39 @@ export default {
|
||||||
},
|
},
|
||||||
handleRegistrySecretChanged(neu) {
|
handleRegistrySecretChanged(neu) {
|
||||||
this.registrySecret = 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>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue