@@ -414,13 +414,37 @@ type WebSphereLibertyApplicationNetworkPolicy struct {
414414 // +operator-sdk:csv:customresourcedefinitions:order=52,type=spec,displayName="Disable",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
415415 Disable * bool `json:"disable,omitempty"`
416416
417- // Specify the labels of namespaces that incoming traffic is allowed from.
418- // +operator-sdk:csv:customresourcedefinitions:order=53,type=spec,displayName="Namespace Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
417+ // Disable the creation of the network policy ingress. Defaults to false.
418+ // +operator-sdk:csv:customresourcedefinitions:order=53,type=spec,displayName="Disable Ingress",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
419+ DisableIngress * bool `json:"disableIngress,omitempty"`
420+
421+ // Disable the creation of the network policy egress. Defaults to false.
422+ // +operator-sdk:csv:customresourcedefinitions:order=54,type=spec,displayName="Disable Egress",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
423+ DisableEgress * bool `json:"disableEgress,omitempty"`
424+
425+ // Bypasses deny all egress rules to allow API server and DNS access. Defaults to false.
426+ // +operator-sdk:csv:customresourcedefinitions:order=55,type=spec,displayName="Bypass Deny All Egress",xDescriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
427+ BypassDenyAllEgress * bool `json:"bypassDenyAllEgress,omitempty"`
428+
429+ // Deprecated. .spec.networkPolicy.fromNamespaceLabels should be used instead. If both are specified, .spec.networkPolicy.fromNamespaceLabels will override this.
430+ // +operator-sdk:csv:customresourcedefinitions:order=56,type=spec,displayName="Namespace Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
419431 NamespaceLabels * map [string ]string `json:"namespaceLabels,omitempty"`
420432
433+ // Specify the labels of namespaces that incoming traffic is allowed from.
434+ // +operator-sdk:csv:customresourcedefinitions:order=57,type=spec,displayName="From Namespace Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
435+ FromNamespaceLabels * map [string ]string `json:"fromNamespaceLabels,omitempty"`
436+
421437 // Specify the labels of pod(s) that incoming traffic is allowed from.
422- // +operator-sdk:csv:customresourcedefinitions:order=54 ,type=spec,displayName="From Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
438+ // +operator-sdk:csv:customresourcedefinitions:order=58 ,type=spec,displayName="From Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
423439 FromLabels * map [string ]string `json:"fromLabels,omitempty"`
440+
441+ // Specify the labels of namespaces that outgoing traffic is allowed to.
442+ // +operator-sdk:csv:customresourcedefinitions:order=59,type=spec,displayName="To Namespace Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
443+ ToNamespaceLabels * map [string ]string `json:"toNamespaceLabels,omitempty"`
444+
445+ // Specify the labels of pod(s) that outgoing traffic is allowed to.
446+ // +operator-sdk:csv:customresourcedefinitions:order=60,type=spec,displayName="To Labels",xDescriptors="urn:alm:descriptor:com.tectonic.ui:text"
447+ ToLabels * map [string ]string `json:"toLabels,omitempty"`
424448}
425449
426450// Defines the desired state and cycle of applications.
@@ -1211,8 +1235,28 @@ func (ssa *WebSphereLibertyApplicationServiceSessionAffinity) GetConfig() *corev
12111235 return ssa .Config
12121236}
12131237
1214- // GetNamespaceLabels returns the namespace selector labels that should be used for the ingress rule
1215- func (np * WebSphereLibertyApplicationNetworkPolicy ) GetNamespaceLabels () map [string ]string {
1238+ // GetToNamespaceLabels returns the namespace selector labels that should be used for the egress rule
1239+ func (np * WebSphereLibertyApplicationNetworkPolicy ) GetToNamespaceLabels () map [string ]string {
1240+ if np .ToNamespaceLabels != nil {
1241+ return * np .ToNamespaceLabels
1242+ }
1243+ return nil
1244+ }
1245+
1246+ // GetToLabels returns the pod selector labels that should be used for the egress rule
1247+ func (np * WebSphereLibertyApplicationNetworkPolicy ) GetToLabels () map [string ]string {
1248+ if np .ToLabels != nil {
1249+ return * np .ToLabels
1250+ }
1251+ return nil
1252+ }
1253+
1254+ // GetFromNamespaceLabels returns the namespace selector labels that should be used for the ingress rule
1255+ func (np * WebSphereLibertyApplicationNetworkPolicy ) GetFromNamespaceLabels () map [string ]string {
1256+ if np .FromNamespaceLabels != nil {
1257+ return * np .FromNamespaceLabels
1258+ }
1259+ // fallback to deprecated flag np.NamespaceLabels for when we only supported one type of network policy (ingress)
12161260 if np .NamespaceLabels != nil {
12171261 return * np .NamespaceLabels
12181262 }
@@ -1232,6 +1276,20 @@ func (np *WebSphereLibertyApplicationNetworkPolicy) IsDisabled() bool {
12321276 return np .Disable != nil && * np .Disable
12331277}
12341278
1279+ // IsIngressDisabled returns whether the network policy ingress should be created or not
1280+ func (np * WebSphereLibertyApplicationNetworkPolicy ) IsIngressDisabled () bool {
1281+ return np .DisableIngress != nil && * np .DisableIngress
1282+ }
1283+
1284+ // IsEgressDisabled returns whether the network policy egress should be created or not
1285+ func (np * WebSphereLibertyApplicationNetworkPolicy ) IsEgressDisabled () bool {
1286+ return np .DisableEgress != nil && * np .DisableEgress
1287+ }
1288+
1289+ func (np * WebSphereLibertyApplicationNetworkPolicy ) IsBypassingDenyAllEgress () bool {
1290+ return np .BypassDenyAllEgress != nil && * np .BypassDenyAllEgress
1291+ }
1292+
12351293// GetLabels returns labels to be added on ServiceMonitor
12361294func (m * WebSphereLibertyApplicationMonitoring ) GetLabels () map [string ]string {
12371295 return m .Labels
0 commit comments