Skip to content
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

add support for filtering public ingress traffic by IP or CIDR #1198

Merged
merged 10 commits into from
Sep 25, 2024

Conversation

nilsgstrabo
Copy link
Contributor

No description provided.

@nilsgstrabo nilsgstrabo self-assigned this Sep 23, 2024
@nilsgstrabo nilsgstrabo marked this pull request as ready for review September 24, 2024 11:53
satr
satr previously approved these changes Sep 24, 2024
pkg/apis/ingress/ingressannotationprovider.go Outdated Show resolved Hide resolved

type ingressPublicAllowListAnnotationProvider struct{}

func (*ingressPublicAllowListAnnotationProvider) GetAnnotations(component radixv1.RadixCommonDeployComponent, _ string) (map[string]string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs comment (or in the interface)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 145 to 156
annotations := make(map[string]string, 1)
var sb strings.Builder

for i, addr := range *component.GetNetwork().Ingress.Public.Allow {
if i > 0 {
sb.WriteString(",")
}
sb.WriteString(string(addr))
}
annotations["nginx.ingress.kubernetes.io/whitelist-source-range"] = sb.String()

return annotations, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional suggestion

Suggested change
annotations := make(map[string]string, 1)
var sb strings.Builder
for i, addr := range *component.GetNetwork().Ingress.Public.Allow {
if i > 0 {
sb.WriteString(",")
}
sb.WriteString(string(addr))
}
annotations["nginx.ingress.kubernetes.io/whitelist-source-range"] = sb.String()
return annotations, nil
addressList := slice.Reduce(*component.GetNetwork().Ingress.Public.Allow, []string{}, func(acc []string, addr radixv1.IPOrCIDR) []string {
return append(acc, string(addr))
})
return map[string]string{"nginx.ingress.kubernetes.io/whitelist-source-range": strings.Join(addressList, ",")}, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, but used slice.Map instead of Reduce

satr
satr previously approved these changes Sep 24, 2024
@nilsgstrabo nilsgstrabo merged commit 5ed2b4d into master Sep 25, 2024
5 checks passed
@nilsgstrabo nilsgstrabo deleted the feature/suppoert-ingress-ip-filtering branch September 25, 2024 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants