Skip to content

Commit

Permalink
make inbound policy a pointer to allow for nil value (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
anderssonw authored Jul 26, 2023
1 parent 38ffa9d commit d632243
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/v1alpha1/podtypes/access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ package podtypes
// +kubebuilder:object:generate=true
type AccessPolicy struct {
//+kubebuilder:validation:Optional
Inbound InboundPolicy `json:"inbound,omitempty"`
Inbound *InboundPolicy `json:"inbound,omitempty"`
//+kubebuilder:validation:Optional
Outbound OutboundPolicy `json:"outbound,omitempty"`
}

// +kubebuilder:object:generate=true
type InboundPolicy struct {
//+kubebuilder:validation:Required
Rules []InternalRule `json:"rules"`
}

Expand Down
6 changes: 5 additions & 1 deletion api/v1alpha1/podtypes/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/resourcegenerator/networking/network_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func getIngressRules(accessPolicy *podtypes.AccessPolicy, ingresses *[]string, p
return ingressRules
}

if len((*accessPolicy).Inbound.Rules) > 0 {
if accessPolicy.Inbound != nil {
inboundTrafficIngressRule := networkingv1.NetworkPolicyIngressRule{
From: getInboundPolicyPeers(accessPolicy.Inbound.Rules, namespace),
Ports: []networkingv1.NetworkPolicyPort{
Expand Down

0 comments on commit d632243

Please sign in to comment.