util

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2021 License: Apache-2.0 Imports: 13 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// KubebuilderBinName define the name of the kubebuilder binary to be used in the tests
	KubebuilderBinName = "kubebuilder"
)

Variables

This section is empty.

Functions

func EnsureExistAndReplace added in v3.2.0

func EnsureExistAndReplace(input, match, replace string) (string, error)

EnsureExistAndReplace check if the content exists and then do the replace

func GetNonEmptyLines added in v3.2.0

func GetNonEmptyLines(output string) []string

GetNonEmptyLines converts given command output string into individual objects according to line breakers, and ignores the empty elements in it.

func HasDifferentCRDVersion

func HasDifferentCRDVersion(config config.Config, crdVersion string) bool

HasDifferentCRDVersion returns true if any other CRD version is tracked in the project configuration.

func HasDifferentWebhookVersion

func HasDifferentWebhookVersion(config config.Config, webhookVersion string) bool

HasDifferentWebhookVersion returns true if any other webhook version is tracked in the project configuration.

func ImplementWebhooks added in v3.2.0

func ImplementWebhooks(filename string) error

ImplementWebhooks will mock an webhook data

func InsertCode added in v3.2.0

func InsertCode(filename, target, code string) error

InsertCode searches target content in the file and insert `toInsert` after the target.

func RandomSuffix added in v3.2.0

func RandomSuffix() (string, error)

RandomSuffix returns a 4-letter string.

func ReplaceInFile added in v3.2.0

func ReplaceInFile(path, old, new string) error

ReplaceInFile replaces all instances of old with new in the file at path.

func ReplaceRegexInFile added in v3.2.0

func ReplaceRegexInFile(path, match, replace string) error

ReplaceRegexInFile finds all strings that match `match` and replaces them with `replace` in the file at path.

func RunCmd

func RunCmd(msg, cmd string, args ...string) error

RunCmd prints the provided message and command and then executes it binding stdout and stderr

func UncommentCode added in v3.2.0

func UncommentCode(filename, target, prefix string) error

UncommentCode searches for target in the file and remove the comment prefix of the target content. The target content may span multiple lines.

func YesNo

func YesNo(reader *bufio.Reader) bool

YesNo reads from stdin looking for one of "y", "yes", "n", "no" and returns true for "y" and false for "n"

Types

This section is empty.

Jump to

Keyboard shortcuts

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