Merge pull request #47 from navi-infra/INFRA-672
INFRA-672 | Abhishek | Fix validation for HPA
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import * as React from 'react';
|
||||
import { makeStyles, Typography, Box, TableCell } from '@material-ui/core';
|
||||
import {makeStyles, Typography, Box, TableCell, Tooltip} from '@material-ui/core';
|
||||
import { FormikTextField } from '../components/common/FormikTextField';
|
||||
import { toMenuItems } from './FormUtil';
|
||||
import * as _m from '../models/Manifest'
|
||||
@@ -22,7 +22,7 @@ const ScalingParameters = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Box {...boxStyleProps} >
|
||||
<Typography className={classes.boxHeading} variant="overline">Scaling Parameters</Typography>
|
||||
<Typography className={classes.boxHeading} variant="overline">Scaling Parameters (CPU or Memory)</Typography>
|
||||
<FormikTable className={classes.boxTable} name='deployment.hpa.metrics' headers={['Name', 'Threshold']} newItem={_m.newHpaMetric}>
|
||||
{(i) => <>
|
||||
<TableCell> <FormikTextField className={classes.boxTableField} select name={`deployment.hpa.metrics.${i}.name`} > {toMenuItems(['cpu', 'memory'])} </FormikTextField> </TableCell>
|
||||
@@ -64,7 +64,7 @@ const CronHPAAutoscaling = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Box {...boxStyleProps} >
|
||||
<Typography className={classes.boxHeading} variant="overline">Scale HPA using Cron</Typography>
|
||||
<Typography className={classes.boxHeading} variant="overline">Schedule Autoscaling</Typography>
|
||||
<FormikTable className={classes.boxTable} name='deployment.hpa.cronJobs' headers={['Name', 'Cron Expression']} newItem={_m.newHpaCronJob}>
|
||||
{(i) => <>
|
||||
<TableCell> <FormikTextField className={classes.boxTableField} select name={`deployment.hpa.cronJobs.${i}.name`} >{toMenuItems(['ScaleDown', 'ScaleUp'])} </FormikTextField> </TableCell>
|
||||
|
||||
@@ -138,7 +138,7 @@ const BaseForm = (props: BaseFormProps) => {
|
||||
<Button color="secondary" type="submit" variant="contained" size="large" style={{ float: "right", marginRight: 100 }} >
|
||||
Submit
|
||||
</Button>
|
||||
{/*<Debug {...props} />*/}
|
||||
<Debug {...props} />
|
||||
<ErrorSnackBar errors={props.errors} />
|
||||
</Form>
|
||||
)
|
||||
|
||||
@@ -49,9 +49,9 @@ const alertsValidationSchema = yup.object({
|
||||
|
||||
const hpaValidationSchema = yup.object({
|
||||
cronJobs: yup.array().of(yup.object({
|
||||
name: yup.string().required('is Required'),
|
||||
schedule: yup.string().required('is Required')
|
||||
})).max(2),
|
||||
name: yup.string().required('is Required').defined(),
|
||||
schedule: yup.string().required('is Required').defined()
|
||||
}).defined()).max(2),
|
||||
})
|
||||
|
||||
const deploymentValidationSchema = yup.object({
|
||||
@@ -61,7 +61,13 @@ const deploymentValidationSchema = yup.object({
|
||||
loadBalancers: loadBalancersValidationSchema.default(undefined),
|
||||
securityGroup: securityGroupValidationSchema.default(undefined),
|
||||
alerts: alertsValidationSchema.default(undefined),
|
||||
hpa: hpaValidationSchema.default(undefined)
|
||||
hpa: hpaValidationSchema.default(undefined).test('test','Cannot have same job twice',value => {
|
||||
if(value?.cronJobs===undefined || value?.cronJobs[0]===undefined || value?.cronJobs[0]===null || value?.cronJobs[1]===undefined){
|
||||
console.log(value?.cronJobs)
|
||||
return true
|
||||
}
|
||||
return value?.cronJobs[0].name !== value?.cronJobs[1].name
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user