-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
|
||
type ingressPublicAllowListAnnotationProvider struct{} | ||
|
||
func (*ingressPublicAllowListAnnotationProvider) GetAnnotations(component radixv1.RadixCommonDeployComponent, _ string) (map[string]string, error) { |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional suggestion
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 |
There was a problem hiding this comment.
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
Co-authored-by: Sergey Smolnikov <[email protected]>
No description provided.