Documentation
¶
Index ¶
- Constants
- Variables
- func CleanStr(str string) string
- func CustomStrSliceToStrings[S any](slice []S, f func(s S) string) []string
- func CustomStrsSliceToStrings[S any](slice []S, f func(s S) []string) []string
- func FileExist(path string) bool
- func GenerateTableString(header []string, lines [][]string, opts *TableOptions) string
- func IPBlockFromCidrOrAddressOrIPRange(ip string) (*netset.IPBlock, error)
- func IPBlockShortString(set *netset.IPBlock) string
- func IntStr[I Int](v I) string
- func JoinCustomStrFuncSlice[S any](slice []S, f func(s S) string, separator string) string
- func JoinNonEmpty(slice []string, sep string) string
- func JoinNonNil[S any](ptrSlice []*S, f func(s *S) string, sep string) string
- func JoinNonNilStrings(ptrSlice []*string, sep string) string
- func JoinStringifiedSlice[S HasString](slice []S, separator string) string
- func LabelFromString(value string) label
- func MarshalJSON(v any) (string, error)
- func NewFilteredSliceFunc[v any](s []v, f func(v) bool) (res []v)
- func OutputGraph(g Graph, fileName string, format OutFormat) (res string, err error)
- func PointerTo[T any](t T) *T
- func SafePointerDeref[T any](p *T) T
- func SliceCompact[A comparable](s []A) []A
- func SliceCountFunc[v any](s []v, f func(v) bool) int
- func SortedJoinCustomStrFuncSlice[S any](slice []S, f func(s S) string, separator string) string
- func SortedJoinStringifiedSlice[S HasString](slice []S, separator string) string
- func StringifiedSliceToStrings[S HasString](slice []S) []string
- func WriteToFile(file, content string) error
- func WriteYamlUsingJSON[A any](content []A, file string) error
- type DotGraph
- type EdgesGraph
- type Endpoints
- type Graph
- type HasString
- type Int
- type LogLevel
- type OutFormat
- type OutputParameters
- type SectionsOutput
- type Segments
- type TableOptions
- type TreeGraph
Constants ¶
const ( ErrNoResources string = "didn't get any collected resources" ErrNoHostArg string = "didn't get any host arg" ErrMissingRquiredArg string = "missing required arg" ErrCreatingConnection string = "fail to create a connection from service %v" )
const ( OutputSectionSep = "\n-------------------------------------------------------------------\n" ShortSep = "\n-------------------------\n" CommaSeparator string = "," CommaSpaceSeparator string = ", " NewLine string = "\n" Tab string = "\t" Space = " " AnalyzedConnectivityHeader = "Analyzed connectivity:" AnyStr = "ANY" // ANY can specify any service or any src/dst in DFW rules )
Variables ¶
var AllEndpointsStr = JoinStringifiedSlice(allEndpoints, CommaSeparator)
var AllFormatsStr = JoinStringifiedSlice(allFormats, CommaSeparator)
var AllLogLevelOptionsStr = JoinStringifiedSlice(allLogLevelOptions, CommaSeparator)
var AllSegmentOptionsStr = JoinStringifiedSlice(allSegmentOptions, CommaSeparator)
var Update = flag.Bool("update", false, "write or override golden files")
a flag for writing/overriding the golden result files for tests
Functions ¶
func CleanStr ¶
CleanStr for comparison that should be insensitive to line comparators; cleaning strings from line comparators
func CustomStrSliceToStrings ¶
func GenerateTableString ¶
func GenerateTableString(header []string, lines [][]string, opts *TableOptions) string
GenerateTableString returns a string in table format for input header and lines
func IPBlockShortString ¶
func JoinCustomStrFuncSlice ¶
func JoinNonEmpty ¶
func JoinNonNilStrings ¶
func JoinStringifiedSlice ¶
func LabelFromString ¶
func LabelFromString(value string) label
func MarshalJSON ¶
func NewFilteredSliceFunc ¶
func OutputGraph ¶
func PointerTo ¶
func PointerTo[T any](t T) *T
PointerTo is used as shorthand to extract pointer from const value
func SafePointerDeref ¶
func SafePointerDeref[T any](p *T) T
SafePointerDeref dereferences pointer if not nil, else returns empty object
func SliceCompact ¶
func SliceCompact[A comparable](s []A) []A
func SliceCountFunc ¶
func WriteToFile ¶
func WriteYamlUsingJSON ¶
Types ¶
type DotGraph ¶
type DotGraph struct {
// contains filtered or unexported fields
}
func NewDotGraph ¶
func (*DotGraph) JSONString ¶
type EdgesGraph ¶
type EdgesGraph struct {
// contains filtered or unexported fields
}
func NewEdgesGraph ¶
func NewEdgesGraph(header string, tableHeaderComponents []string, color bool) *EdgesGraph
func (*EdgesGraph) AddEdge ¶
func (eg *EdgesGraph) AddEdge(src, dst node, label label)
func (*EdgesGraph) JSONString ¶
func (eg *EdgesGraph) JSONString() (string, error)
func (*EdgesGraph) String ¶
func (eg *EdgesGraph) String() string
type Endpoints ¶
type Endpoints string
func (*Endpoints) SetDefault ¶
func (e *Endpoints) SetDefault()
type Graph ¶
type Graph interface {
AddEdge(src, dst node, label label)
String() string
JSONString() (string, error)
}
Graph interface is implemented by: EdgesGraph (for text output) DotGraph (for dot/svg output) TreeGraph (for json output)
type LogLevel ¶ added in v0.2.1
type LogLevel string
func (*LogLevel) SetDefault ¶ added in v0.2.1
func (e *LogLevel) SetDefault()
type OutFormat ¶
type OutFormat string
/////////////////////////////////////////////////////////////////////////////////////////// outFormat is a custom flag type. Cobra allows to define custom value types to be used as flags through the pflag.(*FlagSet).Var() method. defining a new type that implements the pflag.Value interface.
func (*OutFormat) SetDefault ¶
func (e *OutFormat) SetDefault()
type OutputParameters ¶
type OutputParameters struct {
Format OutFormat
FileName string
VMs []string
Explain bool
Color bool
}
func DefaultOutputParameters ¶
func DefaultOutputParameters() OutputParameters
type SectionsOutput ¶ added in v0.2.1
type SectionsOutput struct {
// contains filtered or unexported fields
}
func (*SectionsOutput) AddSection ¶ added in v0.2.1
func (s *SectionsOutput) AddSection(section, content string)
func (*SectionsOutput) GenerateSectionsString ¶ added in v0.2.1
func (s *SectionsOutput) GenerateSectionsString() string
type TableOptions ¶
type TreeGraph ¶
type TreeGraph struct {
// contains filtered or unexported fields
}
////////////////////////////////////////////////////////////////
func NewTreeGraph ¶
func NewTreeGraph() *TreeGraph