utils

package
v0.0.0-...-4dc2020 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2016 License: MPL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgsToCmd

func ArgsToCmd(args []string) *exec.Cmd

ArgsToCmd creates a command from a list of arguments

func DecodeRaw

func DecodeRaw(raw interface{}, result interface{}) error

DecodeRaw decodes a raw interface into the target structure

func ExecuteAndWait

func ExecuteAndWait(cmd *exec.Cmd) (int, error)

ExecuteAndWait runs the given command and blocks until completed

func GetIP

func GetIP(specList []string) (string, error)

GetIP determines the IP address of the container

func IPFromInterfaces

func IPFromInterfaces(raw interface{}) (string, error)

IPFromInterfaces ...

func NewLogWriter

func NewLogWriter(fields log.Fields, level log.Level) io.WriteCloser

NewLogWriter pipes stdout/err logs to logrus

func ParseCommandArgs

func ParseCommandArgs(raw interface{}) (*exec.Cmd, error)

ParseCommandArgs tries to parse a command from the supported types

func ParseDuration

func ParseDuration(duration interface{}) (time.Duration, error)

ParseDuration parses the given duration with multiple type support int (defaults to seconds) string with units string without units (default to seconds)

func Run

func Run(cmd *exec.Cmd) (int, error)

Run executes the given command and blocks until completed Returns the exit code and error message (if any). Logs output streams to the log driver instead of stdout/stderr - stderr creates DEBUG level entries - stdout creates INFO level entries

func RunWithFields

func RunWithFields(cmd *exec.Cmd, fields log.Fields) (int, error)

RunWithFields executes the given command and blocks until completed Returns the exit code and error message (if any). Logs output streams to the log driver instead of stdout/stderr - stderr creates DEBUG level entries - stdout creates INFO level entries Adds the given fields to the log entries

func StrToCmd

func StrToCmd(command string) *exec.Cmd

StrToCmd creates a command from a string, triming whitespace

func ToStringArray

func ToStringArray(raw interface{}) ([]string, error)

ToStringArray converts the given interface to a []string if possible

func ValidateServiceName

func ValidateServiceName(name string) error

ValidateServiceName checks if the service name passed as an argument is is alpha-numeric with dashes. This ensures compliance with both DNS and discovery backends.

Types

type ByInterfaceThenIP

type ByInterfaceThenIP []interfaceIP

ByInterfaceThenIP implements the Sort with the following properties: 1. Sort interfaces alphabetically 2. Sort IPs by bytes (normalized to 16 byte form)

func (ByInterfaceThenIP) Len

func (se ByInterfaceThenIP) Len() int

func (ByInterfaceThenIP) Less

func (se ByInterfaceThenIP) Less(i, j int) bool

func (ByInterfaceThenIP) Swap

func (se ByInterfaceThenIP) Swap(i, j int)

Jump to

Keyboard shortcuts

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