utils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CompilePluginSubFolder = "plugins/compile"

CompilePluginSubFolder plugins complied folder

View Source
const PluginSourceSubFolder = "plugins/source"

PluginSourceSubFolder plugin source folder

Variables

This section is empty.

Functions

func AddNewLineToNonEmptyStr

func AddNewLineToNonEmptyStr(str string) string

AddNewLineToNonEmptyStr add new line to non empty string

func CreateBenchmarkFolderIfNotExist

func CreateBenchmarkFolderIfNotExist(spec, version string, fm FolderMgr) error

CreateBenchmarkFolderIfNotExist create beacon benchmark folder if not exist

func CreateHomeFolderIfNotExist

func CreateHomeFolderIfNotExist(fm FolderMgr) error

CreateHomeFolderIfNotExist create beacon home folder if not exist

func CreatePluginsCompiledFolderIfNotExist

func CreatePluginsCompiledFolderIfNotExist(fm FolderMgr) error

CreatePluginsCompiledFolderIfNotExist create plugins compiled folder if not exist

func CreatePluginsSourceFolderIfNotExist

func CreatePluginsSourceFolderIfNotExist(fm FolderMgr) error

CreatePluginsSourceFolderIfNotExist plugins source folder if not exist

func ExcludeAuditTest

func ExcludeAuditTest(tests []string, name string) bool

ExcludeAuditTest return true if test is not included in specific tests to run

func GetAuditTestsList

func GetAuditTestsList(key, arg string) []string

GetAuditTestsList return processing function by specificTests

func GetBenchmarkFolder

func GetBenchmarkFolder(spec, version string, fm FolderMgr) (string, error)

GetBenchmarkFolder return benchmark folder

func GetCompilePluginSubFolder

func GetCompilePluginSubFolder(fm FolderMgr) (string, error)

GetCompilePluginSubFolder return plugin compiled folder path

func GetEnv

func GetEnv(key, fallback string) string

GetEnv Get Environment Variable value or return default

func GetHomeFolder

func GetHomeFolder() string

GetHomeFolder return beacon home folder

func GetPluginSourceSubFolder

func GetPluginSourceSubFolder(fm FolderMgr) (string, error)

GetPluginSourceSubFolder return plugins source folder path

func RemoveNewLineSuffix

func RemoveNewLineSuffix(str string) string

RemoveNewLineSuffix remove new line from suffix

Types

type CmdExprBuilder

type CmdExprBuilder func(output []string, expr string) string

CmdExprBuilder sanitize expr

var UpdateCmdExprParam CmdExprBuilder = func(outputArr []string, expr string) string {
	var value string
	builder := strings.Builder{}
	sExpr := SeparateExpr(expr)
	for _, exp := range sExpr {
		for i, output := range outputArr {
			if !strings.Contains(exp.Expr, "$") {
				if i > 0 {
					break
				} else {
					value = exp.Expr
					break
				}
			}
			value = exp.EvaExprBuilderFunc(strings.TrimSpace(output), i, exp.Expr)
			exp.Expr = value
		}
		builder.WriteString(value)
	}
	return builder.String()
}

UpdateCmdExprParam check type

type EvaExprBuilderFunc

type EvaExprBuilderFunc func(output string, index int, expr string) string

EvaExprBuilderFunc build evaluation expresion it replace expression params with audit command result

type Expr

type Expr struct {
	Type               string
	Expr               string
	EvaExprBuilderFunc EvaExprBuilderFunc
}

Expr data

func SeparateExpr

func SeparateExpr(expr string) []Expr

SeparateExpr separate expression to single and multi blocks

type FilesInfo

type FilesInfo struct {
	Name string
	Data string
}

FilesInfo file data

func GetK8sBenchAuditFiles

func GetK8sBenchAuditFiles(spec, version string, fm FolderMgr) ([]FilesInfo, error)

GetK8sBenchAuditFiles return k8s benchmark file

type FolderMgr

type FolderMgr interface {
	CreateFolder(folderName string) error
	GetHomeFolder() (string, error)
}

FolderMgr defines the interface for kube-knark folder fileutil.go

func NewKFolder

func NewKFolder() FolderMgr

NewKFolder return bFolder instance

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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