netpol

package
v0.0.0-...-056dfb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NodePrettyPrint

func NodePrettyPrint(rootNode Node) string

func NodeTraverse

func NodeTraverse(node Node, f func(Node, int))

Types

type Branch

type Branch struct {
	Operation string
	Nodes     []Node
}

func (*Branch) Children

func (b *Branch) Children() []Node

func (*Branch) Print

func (b *Branch) Print() string

type Leaf

type Leaf struct {
	Value string
}

func (*Leaf) Children

func (l *Leaf) Children() []Node

func (*Leaf) Print

func (l *Leaf) Print() string

type MatchExpression

type MatchExpression metav1.LabelSelectorRequirement

func (*MatchExpression) Children

func (me *MatchExpression) Children() []Node

func (*MatchExpression) Print

func (me *MatchExpression) Print() string

type MatchKeyValue

type MatchKeyValue struct {
	Key   string
	Value string
}

func (*MatchKeyValue) Children

func (mkv *MatchKeyValue) Children() []Node

func (*MatchKeyValue) Print

func (mkv *MatchKeyValue) Print() string

type NamespaceSelector

type NamespaceSelector struct {
	CurrentNamespace bool
	AllNamespaces    bool
	Selector         Node
}

func ReduceNamespaceSelector

func ReduceNamespaceSelector(sel *metav1.LabelSelector) *NamespaceSelector

func (*NamespaceSelector) Children

func (n *NamespaceSelector) Children() []Node

func (*NamespaceSelector) Print

func (n *NamespaceSelector) Print() string

type Node

type Node interface {
	Children() []Node
	Print() string
}

func Reduce

func Reduce(policy *networkingv1.NetworkPolicy) Node

func ReduceEgress

func ReduceEgress(egress networkingv1.NetworkPolicyEgressRule) Node

func ReduceEgresses

func ReduceEgresses(egresses []networkingv1.NetworkPolicyEgressRule) Node

func ReduceIngress

func ReduceIngress(ingress networkingv1.NetworkPolicyIngressRule) Node

func ReduceIngresses

func ReduceIngresses(ingresses []networkingv1.NetworkPolicyIngressRule) Node

func ReduceIpBlock

func ReduceIpBlock(ipBlock *networkingv1.IPBlock) Node

func ReduceMatchExpressions

func ReduceMatchExpressions(exps []metav1.LabelSelectorRequirement) Node

func ReduceMatchLabels

func ReduceMatchLabels(labels map[string]string) Node

func ReduceNetworkPolicyPeer

func ReduceNetworkPolicyPeer(isEgress bool, npp networkingv1.NetworkPolicyPeer) Node

func ReducePodSelector

func ReducePodSelector(sel *metav1.LabelSelector) Node

func ReducePorts

func ReducePorts(ports []networkingv1.NetworkPolicyPort) Node

func ReduceSelector

func ReduceSelector(sel metav1.LabelSelector) Node

type Peer

type Peer struct {
	Namespace string
	Pod       string
}

func (*Peer) Matches

func (p *Peer) Matches(pod Pod) bool

type Pod

type Pod string

func NewPod

func NewPod(namespace string, podName string) Pod

func (Pod) Namespace

func (pod Pod) Namespace() string

func (Pod) PodName

func (pod Pod) PodName() string

type Port

type Port struct {
	Protocol        string
	PortOrNamedPort string
}

func (*Port) Children

func (p *Port) Children() []Node

func (*Port) Print

func (p *Port) Print() string

type Reachability

type Reachability struct {
	Expected *TruthTable
	Observed *TruthTable
	Pods     []Pod
}

func NewReachability

func NewReachability(pods []Pod, defaultExpectation bool) *Reachability

func (*Reachability) AllowLoopback

func (r *Reachability) AllowLoopback()

AllowLoopback is a convenience func to access Expected and re-enabl all loopback to true. in general call it after doing other logical stuff in loops since loopback logic follows no policy.

func (*Reachability) Expect

func (r *Reachability) Expect(pod1 Pod, pod2 Pod, isConnected bool)

func (*Reachability) ExpectAllEgress

func (r *Reachability) ExpectAllEgress(pod Pod, connected bool)

ExpectAllEgress defines that any traffic going out of the pod will be allowed/denied (true/false)

func (*Reachability) ExpectAllIngress

func (r *Reachability) ExpectAllIngress(pod Pod, connected bool)

ExpectAllIngress defines that any traffic going into the pod will be allowed/denied (true/false)

func (*Reachability) ExpectPeer

func (r *Reachability) ExpectPeer(from *Peer, to *Peer, connected bool)

func (*Reachability) Observe

func (r *Reachability) Observe(pod1 Pod, pod2 Pod, isConnected bool)

func (*Reachability) PrintSummary

func (r *Reachability) PrintSummary(printExpected bool, printObserved bool, printComparison bool)

type StringTruthTable

type StringTruthTable struct {
	Froms []string
	Tos   []string

	Values map[string]map[string]string
	// contains filtered or unexported fields
}

func NewStringTruthTable

func NewStringTruthTable(items []string) *StringTruthTable

func NewStringTruthTableWithDefaultValue

func NewStringTruthTableWithDefaultValue(items []string, defaultValue string) *StringTruthTable

func NewStringTruthTableWithFromsTo

func NewStringTruthTableWithFromsTo(froms []string, tos []string) *StringTruthTable

func (*StringTruthTable) Compare

func (tt *StringTruthTable) Compare(other *StringTruthTable) *StringTruthTable

func (*StringTruthTable) Get

func (tt *StringTruthTable) Get(from string, to string) string

func (*StringTruthTable) IsComplete

func (tt *StringTruthTable) IsComplete() bool

IsComplete returns true if there's a value set for every single pair of items, otherwise it returns false.

func (*StringTruthTable) Set

func (tt *StringTruthTable) Set(from string, to string, value string)

func (*StringTruthTable) SetAllFrom

func (tt *StringTruthTable) SetAllFrom(from string, value string)

func (*StringTruthTable) SetAllTo

func (tt *StringTruthTable) SetAllTo(to string, value string)

func (*StringTruthTable) Table

func (tt *StringTruthTable) Table() *tablewriter.Table

type TruthTable

type TruthTable struct {
	Items []string

	Values map[string]map[string]bool
	// contains filtered or unexported fields
}

func NewTruthTable

func NewTruthTable(items []string, defaultValue *bool) *TruthTable

func (*TruthTable) Compare

func (tt *TruthTable) Compare(other *TruthTable) *TruthTable

func (*TruthTable) Get

func (tt *TruthTable) Get(from string, to string) bool

func (*TruthTable) IsComplete

func (tt *TruthTable) IsComplete() bool

IsComplete returns true if there's a value set for every single pair of items, otherwise it returns false.

func (*TruthTable) PrettyPrint

func (tt *TruthTable) PrettyPrint() string

func (*TruthTable) Set

func (tt *TruthTable) Set(from string, to string, value bool)

func (*TruthTable) SetAllFrom

func (tt *TruthTable) SetAllFrom(from string, value bool)

func (*TruthTable) SetAllTo

func (tt *TruthTable) SetAllTo(to string, value bool)

func (*TruthTable) Table

func (tt *TruthTable) Table() *tablewriter.Table

Directories

Path Synopsis
eav

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL