client

package
v0.0.0-...-2af5034 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CmdWrapper

type CmdWrapper struct {
	// contains filtered or unexported fields
}

func NewCmdWrapper

func NewCmdWrapper(command []string, cwd string, env []string) *CmdWrapper

func (*CmdWrapper) CombinedOutputPipe

func (cw *CmdWrapper) CombinedOutputPipe() (io.ReadCloser, io.WriteCloser)

func (*CmdWrapper) Run

func (cw *CmdWrapper) Run(captureOutput bool, clientLog *Log) (*CommandResult, error)

func (*CmdWrapper) StdinPipe

func (cw *CmdWrapper) StdinPipe() (io.WriteCloser, error)

type Command

type Command struct {
	ID            string
	Path          string
	Env           []string
	Cwd           string
	CaptureOutput bool
}

func NewCommand

func NewCommand(id string, script string) (*Command, error)

Build a new Command out of an arbitrary script The script is written to disk and then executed ensuring that it can be fairly arbitrary and provide its own shebang

type CommandResult

type CommandResult struct {
	Output  []byte // buffered output if requested
	Success bool
}

type Config

type Config struct {
	Server             string
	JobstepID          string
	ArtifactSearchPath string
	UpstreamMonitor    bool
	Snapshot           struct {
		ID string
	}
	Source struct {
		Revision struct {
			Sha string
		}
		Patch struct {
			ID string
		}
	}
	Repository struct {
		URL     string
		Backend struct {
			ID string
		}
	}
	Project struct {
		Name string
		Slug string
	}
	Cmds             []ConfigCmd `json:"commands"`
	ExpectedSnapshot struct {
		// If this build is expected to generate a snapshot, this is the snapshot ID.
		ID string
	}

	ResourceLimits ResourceLimits

	DebugConfig map[string]*json.RawMessage `json:"debugConfig"`
}

func GetConfig

func GetConfig(jobstepID string) (*Config, error)

func LoadConfig

func LoadConfig(content []byte) (*Config, error)

func (*Config) GetDebugConfig

func (c *Config) GetDebugConfig(key string, dest interface{}) (present bool, err error)

GetDebugConfig parses the debug config JSON at the given key to dest, returning whether the key was present, and if it was, any error that occurred in trying to parse it to dest.

func (*Config) GetDebugConfigBool

func (c *Config) GetDebugConfigBool(key string, fallback bool) bool

GetDebugConfigBool is a helper to simplify basic gating; it acts just like GetDebugConfig, but always uses the fallback value when the value is missing or there is an error.

type ConfigCmd

type ConfigCmd struct {
	ID            string
	Script        string
	Env           map[string]string
	Cwd           string
	Artifacts     []string
	CaptureOutput bool
	Type          struct {
		ID string
	}
}

type Log

type Log struct {
	// contains filtered or unexported fields
}

func NewLog

func NewLog() *Log

func (*Log) Close

func (l *Log) Close()

func (*Log) Drain

func (l *Log) Drain()

Repeatedly calls GetChunk() until Close is called. Mostly useful for tests.

func (*Log) GetChunk

func (l *Log) GetChunk() ([]byte, bool)

Returns the next log chunk, or a nil slice and false if Close was called.

func (*Log) Printf

func (l *Log) Printf(format string, v ...interface{}) error

Printf calls l.Writeln to print to the log. Arguments are handled in the manner of fmt.Printf. The output is guaranteed to be newline-terminated.

func (*Log) WriteStream

func (l *Log) WriteStream(pipe io.Reader)

func (*Log) Writeln

func (l *Log) Writeln(payload string) error

Writes the payload (with a newline appended) to the console, and uses Write to send it to the log.

type LogLine

type LogLine struct {
	// contains filtered or unexported fields
}

type Metrics

type Metrics map[string]float64

type for recording metrics we might want to report (e.g. to Changes)

func (Metrics) Empty

func (m Metrics) Empty() bool

return true if there are no actual metrics recorded

func (Metrics) SetDuration

func (m Metrics) SetDuration(key string, value time.Duration)

set the duration for the given key

func (Metrics) SetDurationSince

func (m Metrics) SetDurationSince(key string, start time.Time) time.Duration

calculate duration since `start` and use that as duration for given key

func (Metrics) StartTimer

func (m Metrics) StartTimer() Timer

create and return a timer starting now

type ResourceLimits

type ResourceLimits struct {
	// Number of CPUs.
	Cpus *int
	// Memory limit in megabytes.
	Memory *int
}

ResourceLimits describes all specified limits that should be applied while executing the JobStep.

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

convenience object for timing functions/sections. See StartTimer() and Record() for usage.

func (Timer) Record

func (t Timer) Record(key string) time.Duration

record a metric with the given key of the duration since this timer was created

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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