utils

package
v0.0.0-...-80d5f3f Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const FRAMEWORK_WEIGHT = 10
View Source
const FROM_PORT = 0
View Source
const TOOL_WEIGHT = 5
View Source
const TO_PORT = 65535

Variables

This section is empty.

Functions

func AddToArrayIfValueExist

func AddToArrayIfValueExist(arr *[]string, val string)

func Contains

func Contains(s []string, str string) bool

func ConvertPropertiesFileAsPathToMap

func ConvertPropertiesFileAsPathToMap(path string) (map[string]string, error)

func ConvertPropertiesFileToMap

func ConvertPropertiesFileToMap(fileInBytes []byte) (map[string]string, error)

func FindAllPortsSubmatch

func FindAllPortsSubmatch(re *regexp.Regexp, text string, group int) []int

func FindPortSubmatch

func FindPortSubmatch(re *regexp.Regexp, text string, group int) int

func FindPotentialPortGroup

func FindPotentialPortGroup(re *regexp.Regexp, text string, group int) string

func GenLogger

func GenLogger(logLevel string) error

GenLogger: Generates the logger with the given zapcore.Level

func GetAnyApplicationFilePath

func GetAnyApplicationFilePath(root string, propsFiles []model.ApplicationFileInfo, ctx *context.Context) string

GetAnyApplicationFilePath returns the location of a file if it exists in the directory and the given file name is a substring.

func GetAnyApplicationFilePathExactMatch

func GetAnyApplicationFilePathExactMatch(root string, propsFiles []model.ApplicationFileInfo) string

GetAnyApplicationFilePathExactMatch returns the location of a file if it exists in the directory and matches the given file name.

func GetCachedFilePathsFromRoot

func GetCachedFilePathsFromRoot(root string, ctx *context.Context) ([]string, error)

func GetComposerJsonSchemaFromFile

func GetComposerJsonSchemaFromFile(path string) (schema.ComposerJson, error)

GetComposerJsonSchemaFromFile returns the composer.json found in the path.

func GetFile

func GetFile(filePaths *[]string, wantedFile string) string

GetFile returns the first match where the wantedFile is in a filePaths path.

func GetFilePathsFromRoot

func GetFilePathsFromRoot(root string) ([]string, error)

GetFilePathsFromRoot walks the file tree starting from root and returns a slice of all file paths found. Ignores files from .gitignore if it exists.

func GetFilePathsInRoot

func GetFilePathsInRoot(root string) ([]string, error)

GetFilePathsInRoot returns a slice of all files in the root.

func GetFilesByRegex

func GetFilesByRegex(filePaths *[]string, regexFile string) []string

GetFilesByRegex returns a slice of file paths from filePaths if the file name matches the regex.

func GetOrCreateLogger

func GetOrCreateLogger() logr.Logger

GetOrCreateLogger: Checks if the CliLogger is already created, otherwise it creates it with errorLevel

func GetPackageJsonSchemaFromFile

func GetPackageJsonSchemaFromFile(path string) (schema.PackageJson, error)

GetPackageJsonSchemaFromFile returns the package.json found in the path.

func GetPomFileContent

func GetPomFileContent(pomFilePath string) (schema.Pom, error)

GetPomFileContent returns the pom found in the path.

func GetPortValueFromEnvFile

func GetPortValueFromEnvFile(root string, regex string) int

func GetPortValuesFromEnvFile

func GetPortValuesFromEnvFile(root string, regexes []string) []int

func GetStringValueFromEnvFile

func GetStringValueFromEnvFile(root string, regex string) string

func GetValidPort

func GetValidPort(port string) (int, error)

GetValidPort checks if a string is a valid port and returns the port. Returns -1 if not a valid port.

func GetValidPorts

func GetValidPorts(ports []string) []int

GetValidPorts returns a slice of valid ports.

func GetValidPortsFromEnvs

func GetValidPortsFromEnvs(envs []string) []int

GetValidPortsFromEnvs returns a slice of valid ports.

func HasFile

func HasFile(files *[]string, wantedFile string) bool

HasFile checks if the file is in a filePaths path.

func IsPathOfWantedFile

func IsPathOfWantedFile(path string, wantedFile string) bool

IsPathOfWantedFile checks if the file is in the path.

func IsTagInComposerJsonFile

func IsTagInComposerJsonFile(file string, tag string) bool

IsTagInComposerJsonFile checks if the file is a composer.json and contains the tag.

func IsTagInFile

func IsTagInFile(file string, tag string) (bool, error)

IsTagInFile checks if the file contains the tag.

func IsTagInPackageJsonFile

func IsTagInPackageJsonFile(file string, tag string) bool

IsTagInPackageJsonFile checks if the file is a package.json and contains the tag.

func IsTagInPomXMLFile

func IsTagInPomXMLFile(pomFilePath string, tag string) (bool, error)

IsTagInPomXMLFile checks if a pom file contains the tag.

func IsTagInPomXMLFileArtifactId

func IsTagInPomXMLFileArtifactId(pomFilePath, groupId, artifactId string) (bool, error)

IsTagInPomXMLFileArtifactId checks if a pom file contains the artifactId.

func IsValidPort

func IsValidPort(port int) bool

IsValidPort checks if an integer is a valid port.

func NormalizeSplit

func NormalizeSplit(file string) (string, string)

func PrintNoArgsWarningMessage

func PrintNoArgsWarningMessage(command string)

func PrintPrettifyOutput

func PrintPrettifyOutput(value interface{}, err error)

func PrintWrongLoggingLevelMessage

func PrintWrongLoggingLevelMessage(command string)

func ReadAnyApplicationFile

func ReadAnyApplicationFile(root string, propsFiles []model.ApplicationFileInfo, ctx *context.Context) ([]byte, error)

ReadAnyApplicationFile returns a byte slice of a file if it exists in the directory and the given file name is a substring.

func ReadAnyApplicationFileExactMatch

func ReadAnyApplicationFileExactMatch(root string, propsFiles []model.ApplicationFileInfo) ([]byte, error)

ReadAnyApplicationFileExactMatch returns a byte slice if the exact given file exists in the directory.

func RedirectErrorStringToStdErrAndExit

func RedirectErrorStringToStdErrAndExit(err string)

func RedirectErrorToStdErrAndExit

func RedirectErrorToStdErrAndExit(err error)

Types

type CLILogger

type CLILogger struct {
	Logger    logr.Logger
	Activated bool
}
var CliLogger CLILogger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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