Skip to content

Define own NetworkPolicyPort field.#219

Open
Gerrit91 wants to merge 3 commits into
masterfrom
own-networking-policy
Open

Define own NetworkPolicyPort field.#219
Gerrit91 wants to merge 3 commits into
masterfrom
own-networking-policy

Conversation

@Gerrit91
Copy link
Copy Markdown
Contributor

@Gerrit91 Gerrit91 commented May 11, 2026

Description

Closes #73.

Noteworthy

The `ClusterWideNetworkPolicy` only supports ports of type `int32` now. Before that, we allowed `intstr`. The string value, however, was always prevented by validation such that the transition should not cause any issues.

Used AI-Tools ✨

  • None used for generation

Comment thread pkg/nftables/networkpolicy.go Outdated
func calculatePorts(ports []firewallv1.NetworkPolicyPort) (tcpPorts, udpPorts []string) {
for _, p := range ports {
proto := proto(p.Protocol)
portStr := fmt.Sprint(p.Port)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if this really worked before in case nil was provided? 🙈

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Took out the pointer possibility as to me it looked like this was not working.

@Gerrit91 Gerrit91 marked this pull request as ready for review May 11, 2026 08:56
@Gerrit91 Gerrit91 requested a review from a team as a code owner May 11, 2026 08:56
}

func port(p int) *intstr.IntOrString {
intstr := intstr.FromInt(p)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought we can now get rid of this as we only support int ports now ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's in a test and we use to create rules from Kubernetes resources (i.e. Service) for which we cannot change the type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

implementation is not matching the cwnp spec

2 participants