mirror of
https://github.com/portainer/portainer.git
synced 2025-07-21 06:19:41 +02:00
refactor(app): migrate replicas form section [EE-6238] (#10705)
Co-authored-by: testa113 <testa113>
This commit is contained in:
parent
58da51f767
commit
6da71661d5
8 changed files with 142 additions and 66 deletions
|
@ -0,0 +1,41 @@
|
|||
import { SchemaOf, number, object } from 'yup';
|
||||
|
||||
import { ReplicaCountFormValues } from './types';
|
||||
|
||||
type ValidationData = {
|
||||
resourceReservationsOverflow: boolean;
|
||||
quotaExceeded: boolean;
|
||||
nonScalableStorage: string;
|
||||
supportScalableReplicaDeployment: boolean;
|
||||
};
|
||||
|
||||
export function replicationValidation(
|
||||
validationData?: ValidationData
|
||||
): SchemaOf<ReplicaCountFormValues> {
|
||||
const {
|
||||
resourceReservationsOverflow,
|
||||
quotaExceeded,
|
||||
nonScalableStorage,
|
||||
supportScalableReplicaDeployment,
|
||||
} = validationData || {};
|
||||
return object({
|
||||
replicaCount: number()
|
||||
.min(1, 'Instance count must be greater than 0.')
|
||||
.test(
|
||||
'overflow',
|
||||
'This application would exceed available resources. Please review resource reservations or the instance count.',
|
||||
() => !resourceReservationsOverflow // must not have resource reservations overflow
|
||||
)
|
||||
.test(
|
||||
'quota',
|
||||
'This application would exceed available storage. Please review the persisted folders or the instance count.',
|
||||
() => !quotaExceeded // must not have quota exceeded
|
||||
)
|
||||
.test(
|
||||
'scalable',
|
||||
`The following storage option(s) do not support concurrent access from multiples instances: ${nonScalableStorage}. You will not be able to scale that application.`,
|
||||
() => !!supportScalableReplicaDeployment // must have support scalable replica deployment
|
||||
)
|
||||
.required('Instance count is required.'),
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue