util

package
v0.0.0-...-15868fb Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const Loopback = "127.0.0.1"

Loopback network address. Skaffold should not bind to 0.0.0.0 unless we really want to expose something to the network.

Variables

View Source
var OSEnviron = os.Environ
View Source
var SkipWrapperCheck = false

Functions

func AbsFile

func AbsFile(workspace string, filename string) (string, error)

AbsFile resolves the absolute path of the file named filename in directory workspace, erroring if it is not a file

func AbsolutePaths

func AbsolutePaths(workspace string, paths []string) []string

AbsolutePaths prepends each path in paths with workspace if the path isn't absolute

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr returns a pointer to a bool

func CloneThroughJSON

func CloneThroughJSON(old interface{}, new interface{}) error

CloneThroughJSON marshals the old interface into the new one

func CreateMappedTar

func CreateMappedTar(w io.Writer, root string, pathMap map[string]string) error

func CreateTar

func CreateTar(w io.Writer, root string, paths []string) error

func CreateTarGz

func CreateTarGz(w io.Writer, root string, paths []string) error

func Download

func Download(url string) ([]byte, error)

func ExecuteEnvTemplate

func ExecuteEnvTemplate(envTemplate *template.Template, customMap map[string]string) (string, error)

ExecuteEnvTemplate executes an envTemplate based on OS environment variables and a custom map

func Expand

func Expand(text, key, value string) string

Expand replaces placeholders for a given key with a given value. It supports the ${key} and the $key syntax.

func ExpandPathsGlob

func ExpandPathsGlob(workingDir string, paths []string) ([]string, error)

ExpandPathsGlob expands paths according to filepath.Glob patterns Returns a list of unique files that match the glob patterns passed in.

func HasMeta

func HasMeta(path string) bool

HasMeta reports whether path contains any of the magic characters recognized by filepath.Match. This is a copy of filepath/match.go's hasMeta

func IsHiddenDir

func IsHiddenDir(filename string) bool

IsHiddenDir returns if a directory is hidden.

func IsHiddenFile

func IsHiddenFile(filename string) bool

IsHiddenFile returns if a file is hidden. File is hidden if it starts with prefix "."

func IsSupportedKubernetesFormat

func IsSupportedKubernetesFormat(n string) bool

IsSupportedKubernetesFormat is for determining if a file under a glob pattern is deployable file format. It makes no attempt to check whether or not the file is actually deployable or has the correct contents.

func IsURL

func IsURL(s string) bool

func NonEmptyLines

func NonEmptyLines(input []byte) []string

NonEmptyLines scans the provided input and returns the non-empty strings found as an array

func ParseEnvTemplate

func ParseEnvTemplate(t string) (*template.Template, error)

ParseEnvTemplate is a simple wrapper to parse an env template

func RandomFourCharacterID

func RandomFourCharacterID() string

func RandomID

func RandomID() string

func ReadConfiguration

func ReadConfiguration(filename string) ([]byte, error)

ReadConfiguration reads a `skaffold.yaml` configuration and returns its content.

func RemoveFromSlice

func RemoveFromSlice(s []string, target string) []string

RemoveFromSlice removes a string from a slice of strings

func RunCmd

func RunCmd(cmd *exec.Cmd) error

func RunCmdOut

func RunCmdOut(cmd *exec.Cmd) ([]byte, error)

func SHA256

func SHA256(r io.Reader) (string, error)

SHA256 returns the shasum of the contents of r

func StrSliceContains

func StrSliceContains(sl []string, s string) bool

func StringPtr

func StringPtr(s string) *string

StringPtr returns a pointer to a string

func SubstituteDefaultRepoIntoImage

func SubstituteDefaultRepoIntoImage(defaultRepo string, originalImage string) string

func VerifyOrCreateFile

func VerifyOrCreateFile(path string) error

VerifyOrCreateFile checks if a file exists at the given path, and if not, creates all parent directories and creates the file.

Types

type Command

type Command interface {
	RunCmdOut(cmd *exec.Cmd) ([]byte, error)
	RunCmd(cmd *exec.Cmd) error
}

Command is an interface used to run commands. All packages should use this interface instead of calling exec.Cmd directly.

var DefaultExecCommand Command = &Commander{}

DefaultExecCommand runs commands using exec.Cmd

type CommandWrapper

type CommandWrapper struct {
	// Executable is the base name of the command, like `gradle`
	Executable string

	// Wrapper is the optional base name of a command wrapper, like `gradlew`
	Wrapper string
}

CommandWrapper defines an association between an executable command (like `gradle`) and possible command wrappers (like `gradlew`). `CreateCommand` uses this definition to create a `Cmd` object. Maven and Gradle projects often provide a wrapper script to ensure a particular version of their builder is used.

func (CommandWrapper) CreateCommand

func (cw CommandWrapper) CreateCommand(ctx context.Context, workingDir string, args []string) *exec.Cmd

CreateCommand creates an `exec.Cmd` that is configured to call the executable (possibly using a wrapper in `workingDir`, when found) with the given arguments, with working directory set to `workingDir`.

type Commander

type Commander struct{}

Commander is the exec.Cmd implementation of the Command interface

func (*Commander) RunCmd

func (*Commander) RunCmd(cmd *exec.Cmd) error

RunCmd runs an exec.Command.

func (*Commander) RunCmdOut

func (*Commander) RunCmdOut(cmd *exec.Cmd) ([]byte, error)

RunCmdOut runs an exec.Command and returns the stdout and error.

Jump to

Keyboard shortcuts

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