Skip to content
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

handling selectors with matchexpressions (fixed) #377

Merged
Show file tree
Hide file tree
Changes from 75 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
2fef0d0
support match expression operators for generating and selecting repr…
shireenf-ibm Jun 23, 2024
361c6ab
more tests
shireenf-ibm Jun 11, 2024
f5dedf0
more tests
shireenf-ibm Jun 23, 2024
31e1ec4
updating code with label selectors
shireenf-ibm Jun 27, 2024
f975c11
merge fixes
shireenf-ibm Jun 27, 2024
63ff816
Merge branch 'new_exposure_analysis_first_branch' of github.com:np-gu…
shireenf-ibm Jun 27, 2024
b53ad1e
duplicated tests with matching pods
shireenf-ibm Jun 29, 2024
5789f65
fixing code + tests with multiple policies
shireenf-ibm Jul 3, 2024
f770e7c
update comments in exposure.go
shireenf-ibm Jul 15, 2024
9928c9c
renaming function and updating comments and doc of representative_sel…
shireenf-ibm Jul 15, 2024
cc0cbc1
move `RepresentativeNsLabelSelector` field from namespace.go to pod.go
shireenf-ibm Jul 15, 2024
4d76f6b
1. reverting changes to AddPodByNameAndNamespace and resolveSingleMis…
shireenf-ibm Jul 15, 2024
ea563f2
avoid duplicating code of generating the default namespace name map; …
shireenf-ibm Jul 15, 2024
ca9cb67
eliminate representativePeer.PotentialNamespaceLabelSelector as it du…
shireenf-ibm Jul 15, 2024
6ce26dc
renaming the func in representative_selectors.go again
shireenf-ibm Jul 16, 2024
2a76b89
a new test with handling a special case of equiv rules written in a d…
shireenf-ibm Jul 16, 2024
d9e964a
unit test for representative_selectors.go
shireenf-ibm Jul 16, 2024
99b4286
removing redundant code
shireenf-ibm Jul 17, 2024
cbc399d
updating documentation of new fields in pod.go
shireenf-ibm Jul 17, 2024
5f13394
fixes in resources.go
shireenf-ibm Jul 17, 2024
f0c25d2
fix in check.go
shireenf-ibm Jul 17, 2024
4b19196
update few comments
adisos Jul 22, 2024
e2a19f0
renaming AddObjects + updating its documentation
shireenf-ibm Jul 22, 2024
75f8659
renaming netpol funcs
shireenf-ibm Jul 22, 2024
aaf72f0
renaming connPeers
shireenf-ibm Jul 22, 2024
b8cda5a
fixing representative pods naming and updating relevant funcs
shireenf-ibm Jul 22, 2024
caf949b
renaming "GeneralConns" to "ExposedGeneralConns"
shireenf-ibm Jul 24, 2024
ebcd659
removing PolicyNsFlag
shireenf-ibm Jul 24, 2024
03e384e
no need to split namespaces with policies at first
shireenf-ibm Jul 24, 2024
659d6d0
Revert "no need to split namespaces with policies at first"
shireenf-ibm Jul 24, 2024
f2dcfd9
rename extractLabelsAndRefineRepresentativePeers and refineRepresen…
shireenf-ibm Jul 24, 2024
4f517b6
renaming checkIfP2PConnOrExposureConn
shireenf-ibm Jul 24, 2024
f1b2628
lint fix
shireenf-ibm Jul 24, 2024
eb68a3f
func allAllowedConnectionsBetweenPeers: remove ingressSet, egressSet
shireenf-ibm Jul 24, 2024
d3bd525
using new terms for general conns : ClusterWideExposure and ExternalE…
shireenf-ibm Jul 24, 2024
4df60cc
an example why should split namespaces at the beginning with the poli…
shireenf-ibm Jul 24, 2024
8d66c49
eliminate RepresentativePeer struct
shireenf-ibm Jul 25, 2024
1982e8f
fixing some typos and adding some very used words to a cspell file
shireenf-ibm Jul 25, 2024
a0ba193
more typos fixes
shireenf-ibm Jul 25, 2024
870f4e8
updating some comments
shireenf-ibm Jul 25, 2024
a5e310f
updating readme (all formats supported)
shireenf-ibm Jul 28, 2024
942f08b
getting netpols before pods for live cluster - so it works well for b…
shireenf-ibm Jul 28, 2024
204c571
Update pkg/netpol/eval/check.go
shireenf-ibm Jul 30, 2024
6fad7cf
Update pkg/netpol/eval/check.go
shireenf-ibm Jul 30, 2024
58e1a73
Update pkg/netpol/eval/exposure.go
shireenf-ibm Jul 30, 2024
7ec8f37
Update pkg/netpol/eval/exposure.go
shireenf-ibm Jul 30, 2024
9b89927
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 30, 2024
67361d7
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 30, 2024
3105bda
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 30, 2024
53e5589
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 30, 2024
5b1fb32
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 30, 2024
78e17b8
Update pkg/netpol/eval/exposure.go
shireenf-ibm Jul 30, 2024
82950bc
Update pkg/netpol/eval/exposure.go
shireenf-ibm Jul 30, 2024
31008cf
Update pkg/netpol/eval/exposure.go
shireenf-ibm Jul 30, 2024
6460edc
rename getSelectorsAndUpdateExposedGeneralConns
shireenf-ibm Jul 30, 2024
23de7f0
rename ScanPolicyRulesAndUpdateExposedWideConns
shireenf-ibm Jul 30, 2024
6f36048
rename updateNetworkPolicyWideExposureConns
shireenf-ibm Jul 30, 2024
90fdcc7
Update pkg/netpol/eval/resources.go
shireenf-ibm Jul 31, 2024
068eeac
Merge branch 'new_handling_selectors_with_matchexpressions' of github…
shireenf-ibm Jul 31, 2024
0cd741c
Update pkg/netpol/eval/internal/k8s/peer.go
shireenf-ibm Jul 31, 2024
c8a89ae
Update pkg/netpol/eval/internal/k8s/peer.go
shireenf-ibm Jul 31, 2024
9f20450
Update pkg/netpol/eval/internal/k8s/pod.go
shireenf-ibm Jul 31, 2024
b66ad0c
Update pkg/netpol/eval/internal/k8s/pod.go
shireenf-ibm Jul 31, 2024
707a742
Update pkg/netpol/eval/resources.go
shireenf-ibm Jul 31, 2024
b877bb6
Update pkg/netpol/eval/resources.go
shireenf-ibm Jul 31, 2024
d3c12ee
fixing lint
shireenf-ibm Jul 31, 2024
6e3fe48
Update pkg/netpol/eval/internal/k8s/representative_selectors.go
shireenf-ibm Jul 31, 2024
8de7c24
lint fix
shireenf-ibm Jul 31, 2024
dba327a
Update pkg/netpol/eval/internal/k8s/representative_selectors.go
shireenf-ibm Jul 31, 2024
628a592
fixing the last commit
shireenf-ibm Jul 31, 2024
7565f1f
fixing the SelectorsFullMatch doc
shireenf-ibm Jul 31, 2024
e14f7ca
removing unnecessaryDeepCopy calls
shireenf-ibm Jul 31, 2024
18f4dd4
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 31, 2024
a759598
Update pkg/netpol/eval/internal/k8s/netpol.go
shireenf-ibm Jul 31, 2024
df836b3
lint fix
shireenf-ibm Jul 31, 2024
ca95c20
some renamings in representative_selectors + document why returning f…
shireenf-ibm Jul 31, 2024
e035016
adding line to comment
shireenf-ibm Jul 31, 2024
a3f434c
split funcs in check.go for readability
shireenf-ibm Jul 31, 2024
a96bb43
rename hasRepresentativePod
shireenf-ibm Jul 31, 2024
4fe2b03
updating comment
shireenf-ibm Jul 31, 2024
3723844
updating comment of storing the named port
shireenf-ibm Jul 31, 2024
ff31b89
updating String() func of workloadpeer
shireenf-ibm Jul 31, 2024
230e942
comment update
shireenf-ibm Jul 31, 2024
b107e7e
updating comment
shireenf-ibm Jul 31, 2024
64fbe59
new func of selectors match in `netpol.go` to avoid duplicates
shireenf-ibm Aug 1, 2024
52278a7
updating comment in pod.go (what do the combinations of rep selectors…
shireenf-ibm Aug 1, 2024
9572ad4
renaming str vars
shireenf-ibm Aug 1, 2024
ff7c637
eliminating addIfMissingNamespace func
shireenf-ibm Aug 1, 2024
f04ae1d
new tests - rep peers when there is real ns but no real pods matching
shireenf-ibm Aug 1, 2024
f0fb5a3
add comment on String() func
shireenf-ibm Aug 1, 2024
b6d0f3e
rename handleRequirementWithInOpAndSingleValue
shireenf-ibm Aug 1, 2024
e744b53
renaming test dirs and expected output of exposure-analysis tests
shireenf-ibm Aug 4, 2024
c786a27
new fixes
shireenf-ibm Aug 5, 2024
4336adc
Merge branch 'new_exposure_analysis_first_branch' of github.com:np-gu…
shireenf-ibm Aug 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Flags:
-f, --file string Write output to specified file
--focusworkload Focus connections of specified workload in the output (supported formats: <workload-name>, <workload-namespace>/<workload-name>)
(to focus connections from Ingress/Route only, use `ingress-controller` as <workload-name>)
-o, --output string Required output format (txt, json, dot, csv, md) or (txt, dot) with exposure analysis (default "txt")
-o, --output string Required output format (txt, json, dot, csv, md) (default "txt")
-h, --help help for list

Global Flags:
Expand Down
15 changes: 15 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2",
"ignorePaths": [],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [
"connlist",
"netpol",
"netpols",
"SCTP",
"xgress"
],
"ignoreWords": [],
"import": []
}
4 changes: 2 additions & 2 deletions pkg/cli/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ func runDiffCommand() error {
var connsDiff diff.ConnectivityDiff
var err error

clogger := logger.NewDefaultLoggerWithVerbosity(detrmineLogVerbosity())
diffAnalyzer := diff.NewDiffAnalyzer(getDiffOptions(clogger)...)
cLogger := logger.NewDefaultLoggerWithVerbosity(determineLogVerbosity())
diffAnalyzer := diff.NewDiffAnalyzer(getDiffOptions(cLogger)...)

connsDiff, err = diffAnalyzer.ConnDiffFromDirPaths(dir1, dir2)
if err != nil {
Expand Down
42 changes: 21 additions & 21 deletions pkg/cli/evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func validateEvalFlags() error {
if destinationPod.Name == "" && dstExternalIP == "" {
return errors.New(netpolerrors.NoDestDefinedErr)
} else if destinationPod.Name != "" && dstExternalIP != "" {
return errors.New(netpolerrors.OnlyOneDstFalgErrStr)
return errors.New(netpolerrors.OnlyOneDstFlagErrStr)
}

if srcExternalIP != "" && dstExternalIP == "" {
Expand All @@ -65,22 +65,22 @@ func validateEvalFlags() error {

func updatePolicyEngineObjectsFromDirPath(pe *eval.PolicyEngine, podNames []types.NamespacedName) error {
// get relevant resources from dir path
elogger := logger.NewDefaultLoggerWithVerbosity(detrmineLogVerbosity())
eLogger := logger.NewDefaultLoggerWithVerbosity(determineLogVerbosity())

rList, errs := fsscanner.GetResourceInfosFromDirPath([]string{dirPath}, true, false)
if errs != nil {
// TODO: consider avoid logging this error because it is already printed to log by the builder
if len(rList) == 0 || stopOnFirstError {
err := utilerrors.NewAggregate(errs)
elogger.Errorf(err, netpolerrors.ErrGettingResInfoFromDir)
eLogger.Errorf(err, netpolerrors.ErrGettingResInfoFromDir)
return err // return as fatal error if rList is empty or if stopOnError is on
}
// split err if it's an aggregated error to a list of separate errors
for _, err := range errs {
elogger.Errorf(err, netpolerrors.FailedReadingFileErrorStr) // print to log the error from builder
eLogger.Errorf(err, netpolerrors.FailedReadingFileErrorStr) // print to log the error from builder
}
}
objectsList, processingErrs := parser.ResourceInfoListToK8sObjectsList(rList, elogger, false)
objectsList, processingErrs := parser.ResourceInfoListToK8sObjectsList(rList, eLogger, false)
for _, err := range processingErrs {
if err.IsFatal() || (stopOnFirstError && err.IsSevere()) {
return fmt.Errorf("scan dir path %s had processing errors: %w", dirPath, err.Error())
Expand All @@ -92,11 +92,11 @@ func updatePolicyEngineObjectsFromDirPath(pe *eval.PolicyEngine, podNames []type
for _, obj := range objectsList {
switch obj.Kind {
case parser.Pod:
err = pe.UpsertObject(obj.Pod)
err = pe.InsertObject(obj.Pod)
case parser.Namespace:
err = pe.UpsertObject(obj.Namespace)
case parser.Networkpolicy:
err = pe.UpsertObject(obj.Networkpolicy)
err = pe.InsertObject(obj.Namespace)
case parser.NetworkPolicy:
err = pe.InsertObject(obj.NetworkPolicy)
default:
continue
}
Expand All @@ -114,32 +114,32 @@ func updatePolicyEngineObjectsFromLiveCluster(pe *eval.PolicyEngine, podNames []
defer cancel()

for _, name := range nsNames {
ns, apierr := clientset.CoreV1().Namespaces().Get(ctx, name, metav1.GetOptions{})
if apierr != nil {
return apierr
ns, apiErr := clientset.CoreV1().Namespaces().Get(ctx, name, metav1.GetOptions{})
if apiErr != nil {
return apiErr
}
if err := pe.UpsertObject(ns); err != nil {
if err := pe.InsertObject(ns); err != nil {
return err
}
}

for _, name := range podNames {
pod, apierr := clientset.CoreV1().Pods(name.Namespace).Get(ctx, name.Name, metav1.GetOptions{})
if apierr != nil {
return apierr
pod, apiErr := clientset.CoreV1().Pods(name.Namespace).Get(ctx, name.Name, metav1.GetOptions{})
if apiErr != nil {
return apiErr
}
if err := pe.UpsertObject(pod); err != nil {
if err := pe.InsertObject(pod); err != nil {
return err
}
}

for _, ns := range nsNames {
npList, apierr := clientset.NetworkingV1().NetworkPolicies(ns).List(ctx, metav1.ListOptions{})
if apierr != nil {
return apierr
npList, apiErr := clientset.NetworkingV1().NetworkPolicies(ns).List(ctx, metav1.ListOptions{})
if apiErr != nil {
return apiErr
}
for i := range npList.Items {
if err := pe.UpsertObject(&npList.Items[i]); err != nil {
if err := pe.InsertObject(&npList.Items[i]); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func runListCommand() error {
var conns []connlist.Peer2PeerConnection
var err error

clogger := logger.NewDefaultLoggerWithVerbosity(detrmineLogVerbosity())
analyzer := connlist.NewConnlistAnalyzer(getConnlistOptions(clogger)...)
cLogger := logger.NewDefaultLoggerWithVerbosity(determineLogVerbosity())
analyzer := connlist.NewConnlistAnalyzer(getConnlistOptions(cLogger)...)

if dirPath != "" {
conns, _, err = analyzer.ConnlistFromDirPath(dirPath)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var (
)

// returns verbosity level based on the -q and -v switches
func detrmineLogVerbosity() logger.Verbosity {
func determineLogVerbosity() logger.Verbosity {
verbosity := logger.DefaultVerbosity
if quiet {
verbosity = logger.LowVerbosity
Expand Down
12 changes: 7 additions & 5 deletions pkg/internal/netpolerrors/netpol_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ const (
NotFoundNamespace = "could not find peer namespace"
OnlyOneSrcFlagErrStr = "only one of source pod and namespace or external IP can be defined, not both"
NoDestDefinedErr = "no destination defined, destination pod and namespace or external IP required"
OnlyOneDstFalgErrStr = "only one of destination pod and namespace or external IP can be defined, not both"
OnlyOneDstFlagErrStr = "only one of destination pod and namespace or external IP can be defined, not both"
OnlyOneIPPeerErrStr = "only one of source or destination can be defined as external IP, not both"
RequiredDstPortFlagErr = "destination port name or value is required"

// diff command errors
RequiredFlagsErr = "both directory paths dir1 and dir2 are required"
FlagMisUseErr = "dirpath flag is not used with diff command"

// errors consts from `orig errors` that are raised by external libraries
// errors constants from `orig errors` that are raised by external libraries
InvalidCIDRAddr = "invalid CIDR address"
InvalidKeyVal = "key: Invalid value"
UnrecognizedValType = "unrecognized type"
Expand All @@ -62,6 +62,8 @@ const (
UnableToDecodeErr = "unable to decode"

UnknownCommandErr = "unknown command"

NilRepresentativePodSelectorsErr = "representative pod might not be generated if it does not have any representative selector"
)

// NotSupportedPodResourcesErrorStr returns error string of not supported pods with same ownerRef but different labels
Expand All @@ -70,7 +72,7 @@ func NotSupportedPodResourcesErrorStr(ownerRefName string) string {
ownerRefName + " but with different set of labels."
}

// WorkloadDoesNotExistErrStr returns error string of missing workload for connlist with focusworkload
// WorkloadDoesNotExistErrStr returns error string of missing workload for connlist with focus-workload
func WorkloadDoesNotExistErrStr(workload string) string {
return "Workload " + workload + " does not exist in the input resources." + EmptyConnListErrStr
}
Expand Down Expand Up @@ -98,8 +100,8 @@ func BlockedIngressWarning(objKind, objName, peerStr string) string {
}

// MissingNamespaceErrStr returns error string of a missing namespace of a peer
func MissingNamespaceErrStr(peerStr string) string {
return "error: namespace of pod " + peerStr + " is missing"
func MissingNamespaceErrStr(nsName, peerName string) string {
return "error: namespace " + nsName + " of pod " + peerName + " is missing"
}

// NotPeerErrStr returns error string of a peer that is not workload peer
Expand Down
68 changes: 34 additions & 34 deletions pkg/manifests/parser/k8sobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ import (

// relevant K8s resource kinds as string values
const (
Networkpolicy string = "NetworkPolicy"
NetworkPolicy string = "NetworkPolicy"
Namespace string = "Namespace"
Pod string = "Pod"
ReplicaSet string = "ReplicaSet"
ReplicationController string = "ReplicationController"
Deployment string = "Deployment"
Statefulset string = "StatefulSet"
Daemonset string = "DaemonSet"
StatefulSet string = "StatefulSet"
DaemonSet string = "DaemonSet"
Job string = "Job"
CronJob string = "CronJob"
List string = "List"
NamespaceList string = "NamespaceList"
NetworkpolicyList string = "NetworkPolicyList"
NetworkPolicyList string = "NetworkPolicyList"
PodList string = "PodList"
Service string = "Service"
Route string = "Route"
Expand All @@ -45,7 +45,7 @@ type K8sObject struct {
Namespace *v1.Namespace

// netpol object
Networkpolicy *netv1.NetworkPolicy
NetworkPolicy *netv1.NetworkPolicy

// pod object
Pod *v1.Pod
Expand All @@ -58,29 +58,29 @@ type K8sObject struct {
Ingress *netv1.Ingress

// workload object
Replicaset *appsv1.ReplicaSet
ReplicaSet *appsv1.ReplicaSet
Deployment *appsv1.Deployment
Statefulset *appsv1.StatefulSet
StatefulSet *appsv1.StatefulSet
ReplicationController *v1.ReplicationController
Job *batchv1.Job
CronJob *batchv1.CronJob
Daemonset *appsv1.DaemonSet
DaemonSet *appsv1.DaemonSet
}

func (k *K8sObject) getEmptyInitializedFieldObjByKind(kind string) interface{} {
switch kind {
case Deployment:
k.Deployment = &appsv1.Deployment{}
return k.Deployment
case Daemonset:
k.Daemonset = &appsv1.DaemonSet{}
return k.Daemonset
case DaemonSet:
k.DaemonSet = &appsv1.DaemonSet{}
return k.DaemonSet
case ReplicaSet:
k.Replicaset = &appsv1.ReplicaSet{}
return k.Replicaset
case Statefulset:
k.Statefulset = &appsv1.StatefulSet{}
return k.Statefulset
k.ReplicaSet = &appsv1.ReplicaSet{}
return k.ReplicaSet
case StatefulSet:
k.StatefulSet = &appsv1.StatefulSet{}
return k.StatefulSet
case ReplicationController:
k.ReplicationController = &v1.ReplicationController{}
return k.ReplicationController
Expand All @@ -102,9 +102,9 @@ func (k *K8sObject) getEmptyInitializedFieldObjByKind(kind string) interface{} {
case Pod:
k.Pod = &v1.Pod{}
return k.Pod
case Networkpolicy:
k.Networkpolicy = &netv1.NetworkPolicy{}
return k.Networkpolicy
case NetworkPolicy:
k.NetworkPolicy = &netv1.NetworkPolicy{}
return k.NetworkPolicy
case Namespace:
k.Namespace = &v1.Namespace{}
return k.Namespace
Expand All @@ -119,17 +119,17 @@ func (k *K8sObject) initDefaultNamespace() {
if k.Deployment.Namespace == "" {
k.Deployment.Namespace = metav1.NamespaceDefault
}
case Daemonset:
if k.Daemonset.Namespace == "" {
k.Daemonset.Namespace = metav1.NamespaceDefault
case DaemonSet:
if k.DaemonSet.Namespace == "" {
k.DaemonSet.Namespace = metav1.NamespaceDefault
}
case ReplicaSet:
if k.Replicaset.Namespace == "" {
k.Replicaset.Namespace = metav1.NamespaceDefault
if k.ReplicaSet.Namespace == "" {
k.ReplicaSet.Namespace = metav1.NamespaceDefault
}
case Statefulset:
if k.Statefulset.Namespace == "" {
k.Statefulset.Namespace = metav1.NamespaceDefault
case StatefulSet:
if k.StatefulSet.Namespace == "" {
k.StatefulSet.Namespace = metav1.NamespaceDefault
}
case ReplicationController:
if k.ReplicationController.Namespace == "" {
Expand Down Expand Up @@ -160,9 +160,9 @@ func (k *K8sObject) initDefaultNamespace() {
k.Pod.Namespace = metav1.NamespaceDefault
}
checkAndUpdatePodStatusIPsFields(k.Pod)
case Networkpolicy:
if k.Networkpolicy.Namespace == "" {
k.Networkpolicy.Namespace = metav1.NamespaceDefault
case NetworkPolicy:
if k.NetworkPolicy.Namespace == "" {
k.NetworkPolicy.Namespace = metav1.NamespaceDefault
}
}
}
Expand All @@ -184,8 +184,8 @@ var workloadKinds = map[string]bool{
Pod: true,
ReplicaSet: true,
Deployment: true,
Statefulset: true,
Daemonset: true,
StatefulSet: true,
DaemonSet: true,
Job: true,
CronJob: true,
ReplicationController: true,
Expand All @@ -205,8 +205,8 @@ func FilterObjectsList(allObjects []K8sObject, podNames []types.NamespacedName)
if _, ok := nsMap[obj.Namespace.Name]; ok {
res = append(res, obj)
}
case Networkpolicy:
if _, ok := nsMap[obj.Networkpolicy.Namespace]; ok {
case NetworkPolicy:
if _, ok := nsMap[obj.NetworkPolicy.Namespace]; ok {
res = append(res, obj)
}
case Pod:
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifests/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func ResourceInfoListToK8sObjectsList(infosList []*resource.Info, l logger.Logge
}
if k8sObj != nil && k8sObj.Kind != "" {
res = append(res, *k8sObj)
if k8sObj.Kind == Networkpolicy {
if k8sObj.Kind == NetworkPolicy {
hasNetpols = true
}
if workloadKinds[k8sObj.Kind] {
Expand Down
Loading