Documentation ¶
Index ¶
- Constants
- func DeferIgnoreError(f func() error)
- func FindYamlFiles(root string) ([]string, error)
- func IgnoreError(err error)
- func LogFromContext(ctx context.Context) logr.Logger
- func MyCaller() string
- func PrettyString(v interface{}) string
- func ReadYaml(path string) ([]*yaml.RNode, error)
- func SetKustomizeImage(k *kustomize.Kustomization, name string, resolved DockerImageRef) error
- func SetupLogger(level string, devLogger bool) logr.Logger
- func UniqueStrings(strings []string) []string
- func VerbosityDescription() string
- type CmdSetter
- type DockerImageRef
- type ExecHelper
- type ListOfErrors
Constants ¶
const ( // ContentTypeJSON is a constant for the application type of requests. ContentTypeJSON = "application/json" // FilePermUserGroup value of permissions user and group all permissions FilePermUserGroup = 0o770 )
const (
// Debug indicates debug verbosity level
Debug = 1
)
Variables ¶
This section is empty.
Functions ¶
func DeferIgnoreError ¶
func DeferIgnoreError(f func() error)
DeferIgnoreError is a helper function to ignore errors returned by functions called with defer.
func FindYamlFiles ¶
FindYamlFiles locates all the YAML files in some root. symlinks are evaluated Files are deduped (e.g. a symlink and its source will not be included twice if they are both in root).
func IgnoreError ¶
func IgnoreError(err error)
IgnoreError is a helper function to deal with errors.
func LogFromContext ¶ added in v0.0.2
LogFromContext returns a logr.Logger from the context or an instance of the global logger
func MyCaller ¶
func MyCaller() string
MyCaller returns the caller of the Function in the form ${package}/${file}:${linenumber} e.g. file: somemodule/cmd/parent.go
func parent() { child() }
file: somemodule/cmd/child.go
func child() { c := util.MyCaller() }
The value of c will be "cmd/parent.go:2"
This is useful when you have common error handlers that want to log the location that invoked them.
The function doesn't return the full path of the code because this would be the full path on the machine where it was compiled which isn't useful.
func PrettyString ¶
func PrettyString(v interface{}) string
PrettyString returns a prettily formatted string of the object.
func ReadYaml ¶
ReadYaml reads the specified path and returns an RNode. This is useful for filtering by KRM type.
func SetKustomizeImage ¶
func SetKustomizeImage(k *kustomize.Kustomization, name string, resolved DockerImageRef) error
SetKustomizeImage sets the specified image in the kustomization.
func SetupLogger ¶
SetupLogger performs common setup of a logger.
func UniqueStrings ¶
UniqueStrings takes a list of strings and returns a list with unique strings.
func VerbosityDescription ¶
func VerbosityDescription() string
VerbosityDescription returns a string to be used as the description for verbosity flags.
Types ¶
type DockerImageRef ¶
type DockerImageRef struct { Registry string Repo string Tag string // NB sha should be of the form "sha256:1234..." otherwise ToURL won't return a proper URL Sha string }
DockerImageRef defines the various pieces of a docker image
func ParseImageURL ¶
func ParseImageURL(url string) (*DockerImageRef, error)
ParseImageURL parses the URL refering to a docker image
TODO(jeremy): We should support shas as well
func (*DockerImageRef) GetAwsRegistryID ¶
func (d *DockerImageRef) GetAwsRegistryID() string
GetAwsRegistryID returns the registry ID or "" if there isn't one
func (*DockerImageRef) ToURL ¶
func (d *DockerImageRef) ToURL() string
ToURL returns the full image URL.
type ExecHelper ¶
ExecHelper is a wrapper for executing shell commands.
func (*ExecHelper) Run ¶
func (h *ExecHelper) Run(cmd *exec.Cmd) error
Run runs and logs stdout/stderr
func (*ExecHelper) RunCommands ¶
func (h *ExecHelper) RunCommands(commands [][]string, setter CmdSetter) error
RunCommands runs multiple commands. CmdSetter is a function to configure the command.
func (*ExecHelper) RunQuietly ¶
func (h *ExecHelper) RunQuietly(cmd *exec.Cmd) (string, error)
RunQuietly runs without logging stdout/stderr. Use this method when you want to let the caller decide whether to log or not. A common use case would be when commands failing to run doesn't necessarily indicate an error.
type ListOfErrors ¶
ListOfErrors is used when we want to return more then one error. This happens when we want to keep going and accumulate errors
func (*ListOfErrors) AddCause ¶
func (l *ListOfErrors) AddCause(e error)
AddCause adds an error to the list.
func (*ListOfErrors) Error ¶
func (l *ListOfErrors) Error() string
Error returns a single error wrapping all the errors.