kubernetes: github.com/igm/kubernetes/pkg/util/exec Index | Files

package exec

import "github.com/igm/kubernetes/pkg/util/exec"

Package exec provides an injectable interface and implementations for running commands.

Index

Package Files

doc.go exec.go fake_exec.go

type Cmd Uses

type Cmd interface {
    // CombinedOutput runs the command and returns its combined standard output
    // and standard error.  This follows the pattern of package os/exec.
    CombinedOutput() ([]byte, error)
    SetDir(dir string)
}

Cmd is an interface that presents an API that is very similar to Cmd from os/exec. As more functionality is needed, this can grow. Since Cmd is a struct, we will have to replace fields with get/set method pairs.

func InitFakeCmd Uses

func InitFakeCmd(fake *FakeCmd, cmd string, args ...string) Cmd

type ExitError Uses

type ExitError interface {
    String() string
    Error() string
    Exited() bool
    ExitStatus() int
}

ExitError is an interface that presents an API similar to os.ProcessState, which is what ExitError from os/exec is. This is designed to make testing a bit easier and probably loses some of the cross-platform properties of the underlying library.

type FakeCmd Uses

type FakeCmd struct {
    Argv                 []string
    CombinedOutputScript []FakeCombinedOutputAction
    CombinedOutputCalls  int
    CombinedOutputLog    [][]string
    Dirs                 []string
}

A simple scripted Cmd type.

func (*FakeCmd) CombinedOutput Uses

func (fake *FakeCmd) CombinedOutput() ([]byte, error)

func (*FakeCmd) SetDir Uses

func (fake *FakeCmd) SetDir(dir string)

type FakeCombinedOutputAction Uses

type FakeCombinedOutputAction func() ([]byte, error)

type FakeCommandAction Uses

type FakeCommandAction func(cmd string, args ...string) Cmd

type FakeExec Uses

type FakeExec struct {
    CommandScript []FakeCommandAction
    CommandCalls  int
}

A simple scripted Interface type.

func (*FakeExec) Command Uses

func (fake *FakeExec) Command(cmd string, args ...string) Cmd

type FakeExitError Uses

type FakeExitError struct {
    Status int
}

A simple fake ExitError type.

func (*FakeExitError) Error Uses

func (fake *FakeExitError) Error() string

func (*FakeExitError) ExitStatus Uses

func (fake *FakeExitError) ExitStatus() int

func (*FakeExitError) Exited Uses

func (fake *FakeExitError) Exited() bool

func (*FakeExitError) String Uses

func (fake *FakeExitError) String() string

type Interface Uses

type Interface interface {
    // Command returns a Cmd instance which can be used to run a single command.
    // This follows the pattern of package os/exec.
    Command(cmd string, args ...string) Cmd
}

Interface is an interface that presents a subset of the os/exec API. Use this when you want to inject fakeable/mockable exec behavior.

func New Uses

func New() Interface

New returns a new Interface which will os/exec to run commands.

Package exec imports 3 packages (graph). Updated 2018-04-17. Refresh now. Tools for package owners.