Documentation ¶
Index ¶
- Variables
- func AddHeaders(root string) error
- func ApplyTemplate(dir string, data interface{}, deleteSources bool, strict bool) error
- func CloneRepo(ctx context.Context, url string, ref string, path string) error
- func CompareJSONObjs(t *testing.T, exp kruntime.Object, actual kruntime.Object)
- func CreateNamespace(ctx context.Context, t *testing.T, namespace string, kubeconfig string)
- func DeleteNamespace(ctx context.Context, t *testing.T, namespace string, kubeconfig string)
- func DirExists(path string) (bool, error)
- func FileExists(path string) (bool, error)
- func GetResources(ctx context.Context, t *testing.T, kind string, namespace string, ...) []apply.TypedKubeObj
- func GetSSMValue(ctx context.Context, sess *session.Session, ssmKeyName string) (string, error)
- func KindEnabled() bool
- func ParseS3URL(url string) (string, string, error)
- func RecursiveCopy(srcDir string, destDir string) error
- func RemoveDirs(rootDir string, indicatorName string) error
- func RestoreData(ctx context.Context, rootDir string, url string, destDir string) error
- func RunCmdWithPrinters(ctx context.Context, command string, args []string, extraEnv []string, ...) error
- func WriteFiles(t *testing.T, baseDir string, files map[string]string)
- type Printer
Constants ¶
This section is empty.
Variables ¶
var ( HeaderComment = []byte("# Generated by \"kubeapply expand\". DO NOT EDIT.\n") HeaderCommentStr = string(HeaderComment) )
Functions ¶
func AddHeaders ¶
AddHeaders adds a comment header to all yaml files in the argument path.
func ApplyTemplate ¶
ApplyTemplate runs golang templating on all files in the provided path, replacing them in-place with their templated versions.
func CloneRepo ¶
CloneRepo makes a shallow clone of the argument repo at a single ref.
See https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset for a discussion of the commands run.
func CompareJSONObjs ¶
CompareJSONObjs compares two objects via their JSON representations. This is much easier to debug that comparing the objects directly.
func CreateNamespace ¶
CreateNamespace creates a namespace in a test cluster.
func DeleteNamespace ¶
DeleteNamespace deletes a namespace in a test cluster.
func FileExists ¶
FileExists returns whether the given path exists and is a file.
func GetResources ¶
func GetResources( ctx context.Context, t *testing.T, kind string, namespace string, kubeconfig string, ) []apply.TypedKubeObj
GetResources gets the objects with the given kind in the argument namespace.
func GetSSMValue ¶
GetSSMValue gets a secret value from AWS SSM.
func KindEnabled ¶
func KindEnabled() bool
KindEnabled returns whether testing with kind is enabled. This is generally true locally but false in CI (for now).
func ParseS3URL ¶
ParseS3URL splits an s3 url into its bucket and key.
func RecursiveCopy ¶
RecursiveCopy does a recursive copy from the source directory to the destination one.
func RemoveDirs ¶
RemoveDirs removes all directories that contain a file with the specified indicatorName (e.g., ".noexpand"). This is used to prune directories that are used for templating/generation but are not valid kube configs.
func RestoreData ¶
RestoreData generates a local version of the resource(s) at the argument URL. Currently, it supports the schemes "file://", "http://", "https://", "git://", "git-https://", and "s3://".
If there is no scheme, then "file://" is assumed.
In the http(s) and s3 cases, the url must refer to an archive. In the file case, it can refer to either an archive or a directory.
The rootDir argument is used in the file case as the base for relative file URLs. It is unused in other cases.
func RunCmdWithPrinters ¶
func RunCmdWithPrinters( ctx context.Context, command string, args []string, extraEnv []string, blockedEnv map[string]struct{}, stdoutPrinter Printer, stderrPrinter Printer, ) error
RunCmdWithPrinters runs a command with output streamed via custom printer functions. Adapted from example in https://github.com/golang/go/issues/19685#issuecomment-288949629.
Types ¶
type Printer ¶
type Printer func(input string)
Printer is a function that prints out a string, e.g. to stdout.
func LogrusDebugPrinter ¶
LogrusDebugPrinter returns a printer that prints via logrus at the debug level.
func LogrusInfoPrinter ¶
LogrusInfoPrinter returns a printer that prints via logrus at the info level.
func LogrusWarnPrinter ¶
LogrusWarnPrinter returns a printer that prints via logrus at the warn level.