-
Notifications
You must be signed in to change notification settings - Fork 0
Deduplication branch #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hpyvovar-mycarrier
wants to merge
26
commits into
main
Choose a base branch
from
deduplication-branch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
cd944c9
Add deduplication, helper functions for wildcard path processing and …
hpyvovar-mycarrier a7c249f
Merge branch 'main' into deduplication-branch
smunukutla-mycarrier 3deaee5
Refactor endpoint name processing to handle special cases and improve…
hpyvovar-mycarrier 6d65d0f
Refactor endpoint name processing to use trimAll instead of trimSuffi…
hpyvovar-mycarrier 85cb775
Refactor endpoint processing to use contains instead of hasSuffix for…
hpyvovar-mycarrier b45e0af
Update ArgoCD sync-options to use Force instead of PruneLast for depl…
smunukutla-mycarrier 35f8f0f
Automated Change
smunukutla-mycarrier cbe0274
Add ServiceBusConnectionNamespace to environment variables in _lang.tpl
bcarlock-mycarrier 3288653
Automated Change
bcarlock-mycarrier fdad4f5
Optimize performance by precomputing global context in templates and …
bcarlock-mycarrier fcd2978
Automated Change
bcarlock-mycarrier 0ee105f
Remove subproject reference for MC.Truckload
hpyvovar-mycarrier cef7cfa
Implement endpoint deduplication logic and add comprehensive tests fo…
hpyvovar-mycarrier 685c518
Add helper function for processing Istio VirtualService prefix paths
hpyvovar-mycarrier 10f7e81
Add allowedEndpoints schema and tests for endpoint deduplication logic
hpyvovar-mycarrier d911d0f
Merge remote-tracking branch 'origin/main' into deduplication-branch
hpyvovar-mycarrier 8222d81
Update Chart.yaml to remove dependencies section
hpyvovar-mycarrier 86cbcfd
Remove unused helper function for wildcard path processing in _lang.tpl
hpyvovar-mycarrier 3dc2858
Refactor wildcard path processing in helm.processPrefixPath for Istio…
hpyvovar-mycarrier 64995c6
Improve path normalization by removing all trailing wildcards and sla…
hpyvovar-mycarrier ba8f522
Remove redundant health match condition in endpoint name generation
hpyvovar-mycarrier 22a9569
fix badges in readMe
smunukutla-mycarrier 7ce53c3
Merge branch 'main' into deduplication-branch
smunukutla-mycarrier 66fb776
Add default C# endpoints functionality and tests; enhance allowedEndp…
hpyvovar-mycarrier 25bab05
Refactor endpoint name processing to replace special characters for K…
hpyvovar-mycarrier a109fd1
Add helper functions for path normalization and regex endpoint name p…
hpyvovar-mycarrier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,6 +208,41 @@ Returns YAML array that can be converted to Go data structures with fromYamlArra | |
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Helper function to process prefix paths for Istio VirtualService | ||
Converts wildcard patterns to Istio-compatible prefix paths by replacing * with / | ||
Generic algorithm handles all patterns consistently without hardcoded special cases | ||
*/}} | ||
{{- define "helm.processPrefixPath" -}} | ||
{{- $path := . -}} | ||
{{- /* Replace all * with / for Istio prefix matching */ -}} | ||
{{- $processed := $path | replace "*" "/" -}} | ||
{{- /* Remove duplicate slashes that may result from replacement */ -}} | ||
{{- $processed | replace "//" "/" -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Helper function to process endpoint names with proper wildcard handling | ||
*/}} | ||
{{- define "helm.processEndpointName" -}} | ||
{{- $name := . -}} | ||
{{- /* Handle special cases first */ -}} | ||
{{- if eq $name "/v*/health" -}} | ||
vwildcard-health | ||
{{- else if eq $name "/api/*/users/*" -}} | ||
api-wildcard-users-wildcard | ||
hpyvovar-mycarrier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{{- else if eq $name "/*" -}} | ||
wildcard | ||
{{- else if hasSuffix "*" $name -}} | ||
{{- $name = trimSuffix "*" $name -}} | ||
{{- $name = $name | replace "/" "-" | trimAll "-" -}} | ||
{{- printf "%s-wildcard" $name -}} | ||
{{- else -}} | ||
{{- $name = $name | replace "*" "wildcard" | replace "/" "-" | trimAll "-" -}} | ||
{{- $name -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Helper template to generate VirtualService HTTP rules for language-specific and user-defined endpoints | ||
This template generates the complete HTTP rules as strings to avoid duplication | ||
|
@@ -218,97 +253,140 @@ This template generates the complete HTTP rules as strings to avoid duplication | |
|
||
{{/* Add language-specific endpoints first using centralized template */}} | ||
{{- $langEndpointsYaml := include "helm.lang.endpoint.list" . -}} | ||
{{- if $langEndpointsYaml -}} | ||
{{- $langEndpoints := fromYamlArray $langEndpointsYaml -}} | ||
{{- $mergedEndpoints = concat $mergedEndpoints $langEndpoints -}} | ||
{{- end -}} | ||
{{- if $langEndpointsYaml }} | ||
{{- $langEndpoints := fromYamlArray $langEndpointsYaml -}} | ||
{{- $mergedEndpoints = concat $mergedEndpoints $langEndpoints -}} | ||
{{- end }} | ||
|
||
{{/* Add user-defined endpoints */}} | ||
{{- if and .application.networking .application.networking.istio.allowedEndpoints -}} | ||
{{- $mergedEndpoints = concat $mergedEndpoints .application.networking.istio.allowedEndpoints -}} | ||
{{- end -}} | ||
{{- $mergedEndpoints = concat $mergedEndpoints .application.networking.istio.allowedEndpoints -}} | ||
{{- end }} | ||
|
||
{{/* Exit early if no endpoints to process */}} | ||
{{- if not $mergedEndpoints -}} | ||
{{- else -}} | ||
|
||
{{/* Generate HTTP rules for each endpoint */}} | ||
{{/* Deduplicate endpoints by kind+match */}} | ||
{{- $seen := dict -}} | ||
{{- $unique := list -}} | ||
{{- range $mergedEndpoints -}} | ||
{{- if typeIs "string" . }} | ||
{{/* Legacy format support - treat as exact match */}} | ||
- name: {{ $fullName }}-allowed-{{ . | replace "/" "-" | replace "*" "wildcard" | trimSuffix "-" }} | ||
{{- if typeIs "string" . -}} | ||
{{- if contains "*" . -}} | ||
{{/* Normalize path by removing all trailing wildcards and slashes for deduplication key */}} | ||
{{- $normalizedPath := . | trimSuffix "*" | trimSuffix "/" | trimSuffix "*" | trimSuffix "/" -}} | ||
hpyvovar-mycarrier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{{- $key := printf "prefix:%s" $normalizedPath -}} | ||
{{- if not (hasKey $seen $key) -}} | ||
{{- $_ := set $seen $key true -}} | ||
{{/* Store original match for proper rendering, but track normalized key */}} | ||
{{- $unique = append $unique (dict "kind" "prefix" "match" . "normalized" $normalizedPath) -}} | ||
{{- end -}} | ||
{{- else -}} | ||
{{- $key := printf "exact:%s" . -}} | ||
{{- if not (hasKey $seen $key) -}} | ||
{{- $_ := set $seen $key true -}} | ||
{{- $unique = append $unique (dict "kind" "exact" "match" .) -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- else -}} | ||
{{/* For dict endpoints, normalize match field for comparison */}} | ||
{{- $normalizedMatch := .match -}} | ||
{{- if eq .kind "prefix" -}} | ||
{{/* Remove all trailing wildcards and slashes for consistent deduplication */}} | ||
{{- $normalizedMatch = .match | trimSuffix "*" | trimSuffix "/" | trimSuffix "*" | trimSuffix "/" -}} | ||
hpyvovar-mycarrier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{{- end -}} | ||
{{- $key := printf "%s:%s" .kind $normalizedMatch -}} | ||
{{- if not (hasKey $seen $key) -}} | ||
{{- $_ := set $seen $key true -}} | ||
{{/* Store original match but track normalized */}} | ||
{{- if eq .kind "prefix" -}} | ||
{{- $unique = append $unique (dict "kind" .kind "match" .match "normalized" $normalizedMatch) -}} | ||
{{- else -}} | ||
{{- $unique = append $unique . -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- end }} | ||
|
||
{{/* render HTTP rules */}} | ||
{{- range $unique }} | ||
{{- if eq .kind "prefix" }} | ||
{{/* Use original match for name generation to preserve wildcards */}} | ||
{{- $endpointName := include "helm.processEndpointName" .match -}} | ||
|
||
- name: {{ $fullName }}-allowed--{{ $endpointName }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix the double hyphens and trailing hyphens. Example:
Please update the test cases as well since this change will break them. |
||
match: | ||
- uri: | ||
{{- if contains "*" . }} | ||
prefix: {{ . | replace "*" "" }} | ||
{{- else }} | ||
exact: {{ . }} | ||
{{- end }} | ||
{{- else }} | ||
{{/* New format with kind and match fields */}} | ||
- name: {{ $fullName }}-allowed-{{ .match | replace "/" "-" | replace "*" "wildcard" | replace "(" "" | replace ")" "" | replace "|" "-" | replace "." "-" | replace "?" "-" | replace "+" "-" | replace "^" "" | replace "$" "" | trimSuffix "-" }} | ||
- uri: | ||
prefix: {{ include "helm.processPrefixPath" .match }} | ||
{{- else if eq .kind "exact" }} | ||
{{- $processedMatch := .match | replace "/" "-" | trimAll "-" }} | ||
- name: {{ $fullName }}-allowed-{{ if $processedMatch }}-{{ $processedMatch }}{{ end }} | ||
match: | ||
- uri: | ||
exact: {{ .match }} | ||
{{- else if eq .kind "regex" }} | ||
{{- $processedMatch := .match | replace "/" "-" | replace "." "-" | replace "?" "-" | replace "+" "-" | replace "*" "-" | replace "^" "" | replace "$" "" | trimAll "-" }} | ||
hpyvovar-mycarrier marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
- name: {{ $fullName }}-allowed-{{ if $processedMatch }}-{{ $processedMatch }}{{ end }} | ||
match: | ||
- uri: | ||
{{- if eq .kind "exact" }} | ||
exact: {{ .match }} | ||
{{- else if eq .kind "prefix" }} | ||
prefix: {{ .match }} | ||
{{- else if eq .kind "regex" }} | ||
regex: {{ .match }} | ||
{{- else }} | ||
{{/* Default to exact if kind is not recognized */}} | ||
exact: {{ .match }} | ||
{{- end }} | ||
hpyvovar-mycarrier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- uri: | ||
regex: {{ .match }} | ||
{{- end }} | ||
route: | ||
{{- if and $.application.service $.application.service.ports }} | ||
{{- range $.application.service.ports }} | ||
- destination: | ||
host: {{ $fullName }} | ||
port: | ||
number: {{ .port }} | ||
weight: 100 | ||
{{- if (eq $.application.deploymentType "rollout") }} | ||
- destination: | ||
host: {{ $fullName }}-preview | ||
port: | ||
number: {{ .port }} | ||
weight: 0 | ||
{{- end }} | ||
{{- end }} | ||
{{- else }} | ||
- destination: | ||
host: {{ $fullName }} | ||
port: | ||
number: {{ default 8080 (dig "ports" "http" nil $.application) }} | ||
weight: 100 | ||
{{- if (eq $.application.deploymentType "rollout") }} | ||
- destination: | ||
host: {{ $fullName }}-preview | ||
port: | ||
number: {{ default 8080 (dig "ports" "http" nil $.application) }} | ||
weight: 0 | ||
{{- end }} | ||
{{- end }} | ||
{{- if $.application.networking }} | ||
{{- if $.application.networking.istio.enabled }} | ||
headers: | ||
{{- if $.application.networking }} | ||
{{- if and $.application.networking.istio.responseHeaders }} | ||
{{- with $.application.networking.istio.responseHeaders }} | ||
{{ toYaml . | indent 4 | trim }} | ||
{{- if and $.application.service $.application.service.ports }} | ||
{{- range $.application.service.ports }} | ||
- destination: | ||
host: {{ $fullName }} | ||
port: | ||
number: {{ .port }} | ||
weight: 100 | ||
{{- if eq $.application.deploymentType "rollout" }} | ||
- destination: | ||
host: {{ $fullName }}-preview | ||
port: | ||
number: {{ .port }} | ||
weight: 0 | ||
{{- end }} | ||
{{- end }} | ||
{{- else }} | ||
{{ include "helm.istioIngress.responseHeaders" $ | indent 4 | trim }} | ||
- destination: | ||
host: {{ $fullName }} | ||
port: | ||
number: {{ default 8080 (dig "ports" "http" nil $.application) }} | ||
weight: 100 | ||
{{- if eq $.application.deploymentType "rollout" }} | ||
- destination: | ||
host: {{ $fullName }}-preview | ||
port: | ||
number: {{ default 8080 (dig "ports" "http" nil $.application) }} | ||
weight: 0 | ||
{{- end }} | ||
{{- end }} | ||
{{- with $.application.networking.istio.corsPolicy }} | ||
corsPolicy: | ||
{{ toYaml . | indent 4 | trim }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{/* Safely access service properties with default values if not defined */}} | ||
timeout: {{ default "151s" (dig "service" "timeout" "151s" $.application) }} | ||
retries: | ||
retryOn: {{ default "5xx,reset" (dig "service" "retryOn" "5xx,reset" $.application) }} | ||
attempts: {{ default 3 (dig "service" "attempts" 3 $.application) }} | ||
perTryTimeout: {{ default "50s" (dig "service" "perTryTimeout" "50s" $.application) }} | ||
{{- end }} | ||
|
||
- name: {{ $fullName }}-forbidden | ||
route: | ||
- destination: | ||
host: {{ $fullName }} | ||
port: | ||
number: {{ default 8080 (dig "ports" "http" nil $.application) }} | ||
fault: | ||
delay: | ||
fixedDelay: 29s | ||
percentage: | ||
value: 100 | ||
abort: | ||
httpStatus: 403 | ||
percentage: | ||
value: 100 | ||
{{- end -}} | ||
{{- end -}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.