Documentation ¶
Index ¶
- func DockerContainerAddress(ctx context.Context, client *client.Client, id string) (string, error)
- func DockerExec(ctx context.Context, client *client.Client, logger *zap.Logger, ...) error
- func DockerImagePull(ctx context.Context, logger *zap.Logger, dockerClient *client.Client, ...) error
- func DockerNetworkName(ctx context.Context, client *client.Client, id string) (string, error)
- func ForwardDockerContainerOutput(ctx context.Context, client *client.Client, containerId string, logs bool, ...) error
- func GetEnvDefault(key string, def string) string
- func MakeVariants(base interface{}) *variants
- func MustString(s string, err error) string
- func MustT(t testing.TB) mustT
- func PrettySelect(db DB, query string, args ...interface{}) (string, error)
- func RandomString(len int) string
- func UniqueName(t testing.TB, hint string) string
- type DB
- type Icinga2Client
- func (c *Icinga2Client) CreateHost(t testing.TB, name string, body interface{})
- func (c *Icinga2Client) CreateObject(t testing.TB, typ string, name string, body interface{})
- func (c *Icinga2Client) CreateService(t testing.TB, host string, service string, body interface{})
- func (c *Icinga2Client) DeleteHost(t testing.TB, name string, cascade bool)
- func (c *Icinga2Client) DeleteJson(url string) (*http.Response, error)
- func (c *Icinga2Client) DeleteObject(t testing.TB, typ string, name string, cascade bool)
- func (c *Icinga2Client) DeleteService(t testing.TB, host string, service string, cascade bool)
- func (c *Icinga2Client) Do(req *http.Request) (*http.Response, error)
- func (c *Icinga2Client) GetJson(url string) (*http.Response, error)
- func (c *Icinga2Client) PostJson(url string, body io.Reader) (*http.Response, error)
- func (c *Icinga2Client) PutJson(url string, body io.Reader) (*http.Response, error)
- func (c *Icinga2Client) UpdateObject(t testing.TB, typ string, name string, body interface{})
- type LineWriter
- type VariantInfo
- type VariantInfoSetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DockerContainerAddress ¶
func DockerExec ¶
func DockerExec( ctx context.Context, client *client.Client, logger *zap.Logger, containerId string, cmd []string, stdin io.Reader, stdout io.Writer, stderr io.Writer, ) error
DockerExec runs a command in a container, forwards its stdin/stdout/stderr to/from the reader/writers passed as arguments and waits for the command to complete with exit code 0.
func DockerImagePull ¶
func DockerImagePull(ctx context.Context, logger *zap.Logger, dockerClient *client.Client, image string, force bool) error
DockerImagePull pulls an image from the registry. If force=false, no pull is done if the image already exists.
func DockerNetworkName ¶
func ForwardDockerContainerOutput ¶
func ForwardDockerContainerOutput( ctx context.Context, client *client.Client, containerId string, logs bool, w io.Writer, ) error
ForwardDockerContainerOutput attaches to a docker container and forwards all its output to a writer.
func GetEnvDefault ¶
GetEnvDefault returns the value of an environment variable or a default value if the variable is not set.
func MakeVariants ¶
func MakeVariants(base interface{}) *variants
func MustString ¶
MustString panics if err != nil and returns s otherwise.
func MustT ¶
MustT returns a struct with receiver functions that fail the given testing.TB on errors.
For example, MustT(t).String(fn()), where fn is of type func() (string, error), returns the string returned by fn if it did not return an error, or calls t.Fatal(err) otherwise.
func PrettySelect ¶
PrettySelect performs a query on the given database connection, retrieves the result set, pretty-prints it and returns the result as a string suitable for writing into a log for debugging.
Example usage:
t.Log(utils.MustT(t).String(utils.PrettySelect(db, "SELECT * FROM somewhere")))
func RandomString ¶
RandomString returns a string of length len consisting of random characters (alphanumeric).
Types ¶
type DB ¶
DB is an interface that contains functions provided by *database/sql.DB and *github.com/jmoiron/sqlx.DB required by functions in this package so that in can be used with both.
type Icinga2Client ¶
func NewIcinga2Client ¶
func NewIcinga2Client(address string, username string, password string) *Icinga2Client
func (*Icinga2Client) CreateHost ¶
func (c *Icinga2Client) CreateHost(t testing.TB, name string, body interface{})
func (*Icinga2Client) CreateObject ¶
func (c *Icinga2Client) CreateObject(t testing.TB, typ string, name string, body interface{})
func (*Icinga2Client) CreateService ¶
func (c *Icinga2Client) CreateService(t testing.TB, host string, service string, body interface{})
func (*Icinga2Client) DeleteHost ¶
func (c *Icinga2Client) DeleteHost(t testing.TB, name string, cascade bool)
func (*Icinga2Client) DeleteJson ¶
func (c *Icinga2Client) DeleteJson(url string) (*http.Response, error)
func (*Icinga2Client) DeleteObject ¶
func (*Icinga2Client) DeleteService ¶
func (*Icinga2Client) UpdateObject ¶
func (c *Icinga2Client) UpdateObject(t testing.TB, typ string, name string, body interface{})
type LineWriter ¶
type LineWriter struct {
// contains filtered or unexported fields
}
LineWriter implements io.WriteCloser and calls the given callback for every line written to it.
func NewLineWriter ¶
func NewLineWriter(callback func([]byte)) *LineWriter
func (*LineWriter) Close ¶
func (l *LineWriter) Close() error
type VariantInfo ¶
func (*VariantInfo) SetVariantInfo ¶
func (v *VariantInfo) SetVariantInfo(field string, index int, value interface{})
func (*VariantInfo) VariantInfoString ¶
func (v *VariantInfo) VariantInfoString() string