Skip to content

Commit

Permalink
feat(kubernetes): added base class K8SEdgeBuilder (#3530)
Browse files Browse the repository at this point in the history
* added base class K8SEdgeBuilder

* added example in find_connection description

* change method signature to return a list

* remove type from method signature

* added line space for linter
  • Loading branch information
PelegLi authored Sep 19, 2022
1 parent 90bfe04 commit 6230185
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import annotations
from abc import abstractmethod

from checkov.kubernetes.graph_builder.graph_components.blocks import KubernetesBlock


class K8SEdgeBuilder:

@abstractmethod
def should_search_for_edges(self, vertex: KubernetesBlock) -> bool:
"""
implementation should examine vertex's attributes and indicate if it's potentially
suitable for the concrete class's edge type.
e.g: search for a label attribute in LabelSelectorEdgeBuilder's implementation
"""
raise NotImplementedError

@abstractmethod
def find_connection(self, vertex: KubernetesBlock, vertices: list[KubernetesBlock]) -> list[KubernetesBlock]:
"""
implementation should search in each of the vertices for a possible connection
to the vertex param according to the concrete class's rule(s).
e.g: find vertices with a label attribute that match current vertex's selector attribute
"""
raise NotImplementedError

0 comments on commit 6230185

Please sign in to comment.