cmd

package
v0.0.0-...-38b8b32 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FileLogLocation = "/dev/null"

TODO dont use a global var, add this to the ctx FileLogLocation to which we write all cmd stdout, stderr

Functions

func GenericExecute

func GenericExecute(envs map[string]string, name string, args []string, ctx *context.Context) error

GenericExecute runs a command and only reports back error message

func Retry

func Retry(c *CommandLine, timeout time.Duration, grepString string, grepNum int, event chan string) bool

Retry command for specifc time or until successful condition

Types

type Command

type Command interface {
	Execute() ([]byte, []byte, error)
	Exists() bool
}

Command interface execute a cli command and returns the stdout, stderr and any error msgs

type CommandLine

type CommandLine struct {
	EnvVars     map[string]string
	CommandName string
	Args        []string
	Ctx         *context.Context
}

The CommandLine contains the env var, command name and args to be run

func NewCommandLine

func NewCommandLine(envs map[string]string, cmd string, args []string, ctx *context.Context) *CommandLine

NewCommandLine constructs a new CommandLine instance

func (*CommandLine) Program

func (c *CommandLine) Program() Command

Program is the only method executed for the CommandLine

type CommandSession

type CommandSession struct {
	CommandLine *CommandLine
	Ctx         context.Context
}

The CommandSession contains the CommandLine

func (*CommandSession) Execute

func (c *CommandSession) Execute() ([]byte, []byte, error)

Execute runs the cli command

func (*CommandSession) Exists

func (c *CommandSession) Exists() bool

Exists checks if a command is in the $PATH var

type ExternalCommand

type ExternalCommand struct {
	Name    string
	Actions *CommandLine
	// contains filtered or unexported fields
}

ExternalCommand is a single external command

type ProvisionerCommands

type ProvisionerCommands struct {
	Name string
	// contains filtered or unexported fields
}

ProvisionerCommands head of command list

func CreateCommandList

func CreateCommandList(name string) *ProvisionerCommands

CreateCommandList constructor

func (*ProvisionerCommands) AddCommand

func (c *ProvisionerCommands) AddCommand(name string, actions *CommandLine) error

AddCommand adds a command to the list

func (*ProvisionerCommands) GetAll

func (c *ProvisionerCommands) GetAll() []string

GetAll returns all commands in the linked list

func (*ProvisionerCommands) NotInPath

func (c *ProvisionerCommands) NotInPath() []string

NotInPath returns commands in the linked list that dont exist in the $PATH

func (*ProvisionerCommands) Remove

func (c *ProvisionerCommands) Remove(t string) error

Remove removes a node

Jump to

Keyboard shortcuts

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