INFRA-3897 | Abhishek | Make external auth and internal gateways optional for clusters

This commit is contained in:
Abhishek Katiyar
2024-11-15 14:00:45 +05:30
parent acde519e0b
commit a240988e92

View File

@@ -68,17 +68,34 @@ const InternalCommonApiGatewayUrlMap = {
[Cluster.IAPL_PROD]: InternalCommonApiGatewayUrl.IAPL_PROD,
};
const ExternalAuthEnabledMap = {
[Cluster.LENDING_NP]: InternalCommonApiGatewayUrl.LENDING_NP,
[Cluster.LENDING_PROD]: InternalCommonApiGatewayUrl.LENDING_PROD,
[Cluster.PAY_NP]: InternalCommonApiGatewayUrl.PAY_NP,
[Cluster.PAY_PROD]: InternalCommonApiGatewayUrl.PAY_PROD,
[Cluster.GI_NP]: InternalCommonApiGatewayUrl.GI_NP,
[Cluster.GI_PROD]: InternalCommonApiGatewayUrl.GI_PROD,
[Cluster.SA_NP]: InternalCommonApiGatewayUrl.SA_NP,
[Cluster.SA_PROD]: InternalCommonApiGatewayUrl.SA_PROD,
[Cluster.PPL_NONPROD]: InternalCommonApiGatewayUrl.PPL_NP,
[Cluster.PPL_PROD]: InternalCommonApiGatewayUrl.PPL_PROD,
[Cluster.IAPL_PROD]: InternalCommonApiGatewayUrl.IAPL_PROD,
};
const rateLimitOptions = ['header', 'path'];
const GatewayAttributes = (props: any = { sourceGatewayPath: string }) => {
const { sourceGatewayPath } = props;
const classes = useStyles();
const { values }: { values: any } = useFormikContext();
const cluster = values?.cluster;
const attributeStateValue =
typeof getIn(values, sourceGatewayPath) !== 'undefined' ? getIn(values, sourceGatewayPath) : [];
const deployedState = attributeStateValue.map(
(gatewayAttributes: any) => gatewayAttributes.isDeployed,
);
const externalAuthAllowed =
cluster in ExternalAuthEnabledMap ? ExternalAuthEnabledMap[cluster] : undefined;
return (
<FormikCardList
@@ -134,14 +151,18 @@ const GatewayAttributes = (props: any = { sourceGatewayPath: string }) => {
/>{' '}
</TableCell>
</TableRow>
<TableRow>
<TableCell>
<FormControlLabel
control={<FormikCheckbox name={`${sourceGatewayPath}.${i}.externalAuth`} />}
label="Use External Auth Service"
/>
</TableCell>
</TableRow>
{externalAuthAllowed ? (
<TableRow>
<TableCell>
<FormControlLabel
control={<FormikCheckbox name={`${sourceGatewayPath}.${i}.externalAuth`} />}
label="Use External Auth Service"
/>
</TableCell>
</TableRow>
) : (
<></>
)}
<TableFooter>
<RateLimitRules sourceRateLimitPath={`${sourceGatewayPath}.${i}.rateLimitRules`} />
</TableFooter>
@@ -226,6 +247,8 @@ const ApiGatewayForm = () => {
const gatewayStateValue =
typeof getIn(values, gatewayPath) !== 'undefined' ? getIn(values, gatewayPath) : [];
const deployedState = gatewayStateValue.map((gateway: any) => gateway.isDeployed);
const internalGatewayUrl =
cluster in InternalCommonApiGatewayUrlMap ? InternalCommonApiGatewayUrlMap[cluster] : undefined;
return (
<NotConfigured
@@ -262,15 +285,19 @@ const ApiGatewayForm = () => {
>
{toMenuItems(ExternalCommonApiGatewayUrlMap[cluster])}
</FormikTextField>
<FormikTextField
select
className={classes.field}
label="Corresponding INTERNAL Common API Gateway URL"
name={`deployment.commonApiGateways.${i}.internalCommonApiGatewayUrl`}
disabled={gatewayStateValue[i].isDeployed}
>
{toMenuItems(InternalCommonApiGatewayUrlMap[cluster])}
</FormikTextField>
{internalGatewayUrl !== undefined ? (
<FormikTextField
select
className={classes.field}
label="Corresponding INTERNAL Common API Gateway URL"
name={`deployment.commonApiGateways.${i}.internalCommonApiGatewayUrl`}
disabled={gatewayStateValue[i].isDeployed}
>
{toMenuItems(InternalCommonApiGatewayUrlMap[cluster])}
</FormikTextField>
) : (
<></>
)}
<GatewayAttributes
sourceGatewayPath={`deployment.commonApiGateways.${i}.gatewayAttributes`}
/>