Documentation
¶
Overview ¶
Utility functions for directories and files
Index ¶
- func CalculateClusterIncludesExcludes(input map[string]string, filters PathFilterOptions) []string
- func CheckObjectMatch(input gjson.Result, filterString string) bool
- func Colorize(input interface{}, colorNum int, disabled bool) string
- func FatalErrorCheck(message string, err error)
- func FetchRepoUrl(url string, destination string, performFetch bool) error
- func Filter(vs []string, f func(string) bool) []string
- func FilterItems(input map[string]string, pfilter PathFilterOptions) []string
- func FormatJsonnetString(input string) (string, error)
- func FormatJsonnetStringCustom(input string, opts formatter.Options) (string, error)
- func GetClusterFilenames(searchDir string) ([]types.Kr8Cluster, error)
- func GetClusterParamsFilenames(basePath string, targetPath string) []string
- func GetClusterPaths(searchDir string, clusterName string) string
- func GetDefaultFormatOptions() formatter.Options
- func JsonnetPrint(output string, format string, color bool)
- func Pretty(input string, colorOutput bool) string
- func WriteObjToJsonFile(filename string, path string, objStruct interface{}) (string, error)
- type PathFilterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateClusterIncludesExcludes ¶
func CalculateClusterIncludesExcludes(input map[string]string, filters PathFilterOptions) []string
Using the allClusterParams variable and command flags to create a list of clusters to generate. Clusters can be filtered with "=" for equality or "~" for regex match.
func CheckObjectMatch ¶
Checks if a input object matches a filter string. The filter string can be an equality match or a regex match.
func Colorize ¶
Colorize function from zerolog console.go file to replicate their coloring functionality. Source: https://github.com/rs/zerolog/blob/a21d6107dcda23e36bc5cfd00ce8fdbe8f3ddc23/console.go#L389
func FatalErrorCheck ¶
Logs an error and exits the program if the error is not nil. Saves 3 lines per use and centralizes fatal errors for rewriting.
func FetchRepoUrl ¶
Fetch a git repo from a url and clone it to a destination directory. If the performFetch flag is false, it will log the command that would be run and return without doing anything.
func Filter ¶
Filter returns a new slice containing only the elements that satisfy the predicate function. From https://gobyexample.com/collection-functions
func FilterItems ¶
func FilterItems(input map[string]string, pfilter PathFilterOptions) []string
Given a map of string, filter them based on the provided options. The map value is parsed as a gjson result and then checked against the provided options.
func FormatJsonnetString ¶
Formats a jsonnet string using the default options.
func FormatJsonnetStringCustom ¶
Formats a jsonnet string using custom options.
func GetClusterFilenames ¶
func GetClusterFilenames(searchDir string) ([]types.Kr8Cluster, error)
Get a list of cluster from within a directory. Walks the directory tree, creating a types.Kr8Cluster for each cluster.jsonnet file found.
func GetClusterParamsFilenames ¶
Get all cluster parameters within a directory. Walks through the directory hierarchy and returns all paths to `params.jsonnet` files.
func GetClusterPaths ¶
Get a specific cluster within a directory by name. Returns the path to the cluster.
func GetDefaultFormatOptions ¶
Configures the default options for the jsonnet formatter.
func JsonnetPrint ¶
Print the jsonnet output in the specified format. Acceptable formats are: yaml, stream, json.
Types ¶
type PathFilterOptions ¶
type PathFilterOptions struct {
// Comma-separated list of include filters
// Filters can include:
//
// regex filters using the "~" operator. For example, "name~^myregex$"
// equality matches using the "=" operator. For example, "name=myvalue"
// substring matches using the "=" operator. For example, "name=myvalue"
//
// If no operator is provided, it is treated as a substring match against the "name" field.
Includes string
// Comma-separated list of exclude filters.
// Filters can include:
//
// regex filters using the "~" operator. For example, "name~^myregex$"
// equality matches using the "=" operator. For example, "name=myvalue"
// substring matches using the "=" operator. For example, "name=myvalue"
//
// If no operator is provided, it is treated as a substring match against the "name" field.
Excludes string
// Comma separated cluster names.
// Filters keys on exact match.
Clusters string
// Comma separated component names.
Components string
}
Fill with string to include and exclude, using kr8's special parsing.