utils

package module
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commit string

Commit is the latest commit

View Source
var Logger log.Logger

Logger is the global logger for Workloader

View Source
var Version string

Version is set by build variable

Functions

func ClearBOM

func ClearBOM(r io.Reader) io.Reader

ClearBOM returns an io.Reader that will skip over initial UTF-8 byte order marks.

func FileName

func FileName() string

func GetCommit

func GetCommit() string

GetCommit returns the latest commit set by the build variable

func GetPCEbyName

func GetPCEbyName(name string, GetLabelMaps bool) (illumioapi.PCE, error)

GetPCEbyName gets a PCE by it's provided name

func GetPCEbyNameV2

func GetPCEbyNameV2(name string, GetLabelMaps bool) (illumioapi.PCE, error)

GetPCEbyName gets a PCE by it's provided name

func GetProcesses

func GetProcesses(file string) ([]string, error)

GetProcesses returns a list of processes from an inputfile

func GetServicePortsCSV

func GetServicePortsCSV(filename string) ([][2]int, error)

GetServicePortsCSV returns port proto list from a CSV

func GetServicePortsPCE

func GetServicePortsPCE(pce illumioapi.PCE, serviceName string) ([][2]int, [][3]int)

GetServicePortsPCE returns PortProto list and PortRangeProto for use in a traffic query from a service object in the PCE

func GetTargetPCE

func GetTargetPCE(GetLabelMaps bool) (illumioapi.PCE, error)

GetTargetPCE gets the target PCE for a command

func GetTargetPCEV2

func GetTargetPCEV2(GetLabelMaps bool) (illumioapi.PCE, error)

GetTargetPCE gets the target PCE for a command

func GetVersion

func GetVersion() string

GetVersion returns the version set by the build variable reads the PCE information from the JSON generated by the login command

func LogAPIResp

func LogAPIResp(callType string, apiResp illumioapi.APIResponse)

LogAPIResp will log the HTTP Requset, Request Header, Response Status Code, and Response Body The callType should be the name of call: GetAllLabels, GetAllWorkloads, etc. This is just for logging purposes and any string will be accepted. The log type will be DEBUG. This call will not do anything if the debug flag isn't set. A debug conditional is not required in app code.

func LogAPIRespV2

func LogAPIRespV2(callType string, apiResp illumioapi.APIResponse)

LogAPIResp will log the HTTP Requset, Request Header, Response Status Code, and Response Body The callType should be the name of call: GetAllLabels, GetAllWorkloads, etc. This is just for logging purposes and any string will be accepted. The log type will be DEBUG. This call will not do anything if the debug flag isn't set. A debug conditional is not required in app code.

func LogBlankValue

func LogBlankValue(val string) string

Replaces a blank string with <empty>

func LogDebug

func LogDebug(msg string)

LogDebug writes the log to workloader.log only if debug flag is set and never prints to stdout. Debug logic is not required in code.

func LogEndCommand

func LogEndCommand(commandName string)

LogEndCommand is used at the end of each command

func LogError

func LogError(msg string)

LogError writes the error the workloader.log and always prints an error to stdout.

func LogErrorf

func LogErrorf(format string, a ...any)

LogErrorf uses string formatting to write to log to workloader.log and always prints msg to stdout.

func LogErrorfCode

func LogErrorfCode(exitCode int, format string, a ...any)

LogErrorfCode a custom exitCode and uses string formatting to write to log to workloader.log and always prints msg to stdout.

func LogInfo

func LogInfo(msg string, stdout bool)

LogInfo writes the log to workloader.log and optionally prints msg to stdout.

func LogInfof

func LogInfof(stdout bool, format string, a ...any)

LogInfof uses string formatting to write to log to workloader.log and optionally prints msg to stdout.

func LogMultiAPIResp

func LogMultiAPIResp(APIResps map[string]illumioapi.APIResponse)

func LogMultiAPIRespV2

func LogMultiAPIRespV2(APIResps map[string]illumioapi.APIResponse)

func LogOutDesc

func LogOutDesc() string

LogOutDesc returns the text of the logout command based on runtime

func LogStartCommand

func LogStartCommand(fullCommand string)

LogStartCommand is used at the beginning of each command

func LogWarning

func LogWarning(msg string, stdout bool)

LogWarning writes the log to workloader.log and optionally prints msg to stdout.

func LogWarningf

func LogWarningf(stdout bool, format string, a ...any)

LogWarningf uses string formatting to write to log to workloader.log and optionally prints msg to stdout.

func ParseCSV

func ParseCSV(filename string) ([][]string, error)

ParseCSV parses a file and returns a slice of slice of strings

func ParseCsvHeaders

func ParseCsvHeaders(filename string) (csvData [][]string, headerMap map[string]int, err error)

ParseCsvHeaders parses a file and returns a slice of slice of strings and header map The header map points to the header index in the slice

func PtrToStr

func PtrToStr(ptr *string) string

PtrToStr converts a pointer to a string. nil pointer returns an empty string

func ReplaceNewLine

func ReplaceNewLine(s string) string

ReplaceNewLine replaces the \r and \n with a space

func RootTemplate

func RootTemplate() string

RootTemplate returns the root usage template

func SRootCmdTemplate

func SRootCmdTemplate() string

SRootCmdTemplate returns the usage template for sub root commands

func SetUpLogging

func SetUpLogging()

func SliceComare

func SliceComare(slice1 []string, slice2 []string, slice1Name, slice2Name string) (equal bool, logMsg string)

func StrToPtr

func StrToPtr(str string) *string

StrToPtr returns a pointer from a string value

func SubCmdTemplate

func SubCmdTemplate() string

SubCmdTemplate returns the usage template used for all subcommands

func UseMulti

func UseMulti() bool

func WriteLineOutput

func WriteLineOutput(csvLine []string, csvFileName string)

WriteLineOutput will write the CSV one line at a time

func WriteOutput

func WriteOutput(csvData, stdOutData [][]string, csvFileName string)

WriteOutput will write the CSV and/or stdout data based on the viper configuration

Types

This section is empty.

Jump to

Keyboard shortcuts

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