Skip to content

Commit e683b8d

Browse files
authored
[DEVOPS-621] Fix $ingressWhitelist being set incorrectly (#176)
<details open> <summary><a href="https://amuniversal.atlassian.net/browse/DEVOPS-621" title="DEVOPS-621" target="_blank">DEVOPS-621</a></summary> <br /> <table> <tr> <th>Summary</th> <td>ingressWhitelist is not being set properly during AKS deploys</td> </tr> <tr> <th>Type</th> <td> <img alt="Bug" src="https://amuniversal.atlassian.net/rest/api/2/universal_avatar/view/type/issuetype/avatar/10308?size=medium" /> Bug </td> </tr> <tr> <th>Status</th> <td>In Progress</td> </tr> <tr> <th>Points</th> <td>N/A</td> </tr> <tr> <th>Labels</th> <td>-</td> </tr> </table> </details> <!-- do not remove this marker as it will break action-jira-linter's functionality. added_by_jira_lint --> --- <!-- Please make sure you read the contribution guidelines and then fill out the blanks below. Please format the PR title appropriately based on the type of change: [JIRA-XXX]: <description> --> ## Description Fix `$ingressWhitelist` being set incorrectly Basically, the `$ingressWhitelist` variable was being set before the loop so anytime there was a modification made to it during one of the first items in the loop, it would apply those changes to the rest of the ingresses. - Move setting the `$ingressWhitelist` variable to be inside the loop - Check to make sure `$ingressWhitelist` includes valid CIDR notation before setting it to the default values. ## Related Links <!-- List any links related to this pull request here Replace "JIRA-XXX" with the your Jira issue key --> - Jira Issue: DEVOPS-621
1 parent 04c64e6 commit e683b8d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

.github/workflows/aks-deploy.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,16 @@ jobs:
312312
$webAuthentication = "${{ inputs.webAuthentication }}" -replace '"', '' -replace "'", ""
313313
$environment = "${{ inputs.environment }}"
314314
$environmentIngress = "${{ inputs.environmentIngress }}" -replace '"', '' -replace "'", ""
315-
$ingressWhitelist = "${{ inputs.ingressWhitelist }}"
316315
$adminIngressWhitelist = "${{ inputs.adminIngressWhitelist }}"
317316
$serviceIngressWhitelist = "${{ inputs.serviceIngressWhitelist }}"
318317
319318
if ($appConfig.schemaVersion -eq "2") {
320319
foreach ($item in $appConfig.ingress) {
320+
# Reset ingress whitelist to input
321+
$ingressWhitelist = "${{ inputs.ingressWhitelist }}"
322+
321323
# Set ingress whitelist if not set
322-
if (($item.name -eq "ingress") -and ([string]::IsNullOrEmpty($ingressWhitelist))) {
324+
if (($item.name -eq "ingress") -and ($ingressWhitelist -notmatch '^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.){2}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)(/(3[0-2]|[1-2]?[0-9]))?$')) {
323325
Write-Output "Ingress whitelist not set for $($item.name)"
324326
if (($ingressWhitelist -eq "service") -or ($item.annotations."nginx.ingress.kubernetes.io/whitelist-source-range" -match "207.67.20.239,40.86.103.124,40.77.105.170")) {
325327
# Use service whitelist
@@ -390,8 +392,11 @@ jobs:
390392
}
391393
else {
392394
foreach ($item in ($appConfig.GetEnumerator() | Where-Object { $_.Key -like "*ingress*" })) {
395+
# Reset ingress whitelist to input
396+
$ingressWhitelist = "${{ inputs.ingressWhitelist }}"
397+
393398
# Set ingress whitelist if not set
394-
if ([string]::IsNullOrEmpty($ingressWhitelist)) {
399+
if ($ingressWhitelist -notmatch '^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.){2}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)(/(3[0-2]|[1-2]?[0-9]))?$') {
395400
Write-Output "Ingress whitelist not set for $($item.Key)"
396401
if (($ingressWhitelist -eq "service") -or ($item.Value.annotations."nginx.ingress.kubernetes.io/whitelist-source-range" -match "207.67.20.239,40.86.103.124,40.77.105.170")) {
397402
# Use service whitelist

0 commit comments

Comments
 (0)