You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an inconsistency for specifying the Protocol for ingress and egress network policies that requires a workaround since Go doesn't allow getting a const address directly.
In other areas where you need to specify a protocol/port combination, such as ServicePort you can do:
v1.ServiceSpec{
Ports: []v1.ServicePort{
{
Protocol: v1.ProtocolUDP, // Use the const directly
},
},
}
However, in NetworkPolicyPort you need to provide a pointer to the Protocol constant.
Ports: []networkv1.NetworkPolicyPort{
{
// This can't be done in Go directly// error: cannot take the address of "k8s.io/api/core/v1".ProtocolUDPProtocol: &v1.ProtocolUDP,
Port: &intstr.IntOrString{
Type: intstr.Int,
IntVal: int32(53),
},
},
},
To make this work you need to assign the const to a variable that you can get the address of and use that. This feels wrong to me.
This isn't really an issue as the code works as expected, it just requires an odd workaround to make it work. Am I missing something here? Is there a specific reason why this would require a pointer?
Note: I could not see any reason why it would be generated as such since there is no real difference in the protobuf definitions for NetworkPolicyPort and ServicePort
The text was updated successfully, but these errors were encountered:
Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten
/remove-lifecycle stale
k8s-ci-robot
added
lifecycle/rotten
Denotes an issue or PR that has aged beyond stale and will be auto-closed.
and removed
lifecycle/stale
Denotes an issue or PR has remained open with no activity and has become stale.
labels
Mar 28, 2018
I found an inconsistency for specifying the Protocol for ingress and egress network policies that requires a workaround since Go doesn't allow getting a
const
address directly.Client Version: client-go 5.0
Kubernetes Version: 1.8
In other areas where you need to specify a protocol/port combination, such as
ServicePort
you can do:However, in NetworkPolicyPort you need to provide a pointer to the Protocol constant.
To make this work you need to assign the
const
to a variable that you can get the address of and use that. This feels wrong to me.The differences can be found in core api/types and networking api/types.
This isn't really an issue as the code works as expected, it just requires an odd workaround to make it work. Am I missing something here? Is there a specific reason why this would require a pointer?
Note: I could not see any reason why it would be generated as such since there is no real difference in the protobuf definitions for NetworkPolicyPort and ServicePort
The text was updated successfully, but these errors were encountered: