kit

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

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

Go to latest
Published: Mar 25, 2021 License: GPL-3.0, GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package kit contains reusable building blocks for acceptance.

Index

Constants

This section is empty.

Variables

View Source
var (
	Name     = "acceptanceclient"
	Defaults = map[string]interface{}{
		"target":            "",
		"addr":              ":0",
		"vnode":             "",
		"exchange_timeout":  "5s",
		"cert_pem_file":     "",
		"insecure":          false,
		"domain":            "",
		"run_timeout":       "0s",
		"reportPings":       true,
		"model":             "?",
		"imageChannel":      "?",
		"buildNumber":       -1,
		"api":               "",
		"api_cert_pem_file": "",
	}
)

Control.

View Source
var ErrNOk = errors.New("not ok")

Functions

func CliLoop

func CliLoop(totalCfg interface{}, cfg *Configuration, onSetup func(sess *acceptance.ClientSession, apiCli *APIClient, cfgDir string), auth func(string) string, waitFor func() string, onConnect func())

CliLoop parses command line arguments and runs a client loop.

func MakeTLSConfig

func MakeTLSConfig(domain string, insecure bool, certPEMFile string, relDir string) (*tls.Config, error)

MakeTLSConfig makes a tls.Config, optionally reading a cert from disk, possibly relative to relDir.

Types

type APIClient

type APIClient struct {
	ServerAPIURL string
	// hook to adjust requests
	MassageRequest func(req *http.Request, message interface{}) *http.Request
	// contains filtered or unexported fields
}

APIClient helps making api requests.

func (*APIClient) GetRequest

func (api *APIClient) GetRequest(path string, params map[string]string) (map[string]interface{}, error)

Get resource from API endpoint.

func (*APIClient) PostRequest

func (api *APIClient) PostRequest(path string, message interface{}) (map[string]interface{}, error)

Post a API request.

func (*APIClient) SetupClient

func (api *APIClient) SetupClient(tlsConfig *tls.Config, disableKeepAlives bool, maxIdleConnsPerHost int)

SetupClient sets up the http client to make requests.

type APIError

type APIError struct {
	Msg  string
	Body []byte
}

func (*APIError) Error

func (e *APIError) Error() string

type Configuration

type Configuration struct {
	// session configuration
	ExchangeTimeout config.ConfigTimeDuration `json:"exchange_timeout"`
	// server connection config
	Target      string                `json:"target" help:"production|staging - picks defaults"`
	Addr        config.ConfigHostPort `json:"addr"`
	Vnode       string                `json:"vnode" help:"vnode postfix to make up a targeting device-id"`
	CertPEMFile string                `json:"cert_pem_file"`
	Insecure    bool                  `json:"insecure" help:"disable checking of server certificate and hostname"`
	Domain      string                `json:"domain" help:"domain for tls connect"`
	// api config
	APIURL         string `json:"api" help:"api url"`
	APICertPEMFile string `json:"api_cert_pem_file"`
	// run timeout
	RunTimeout config.ConfigTimeDuration `json:"run_timeout"`
	// flags
	ReportPings  bool   `json:"reportPings" help:"report each Ping from the server"`
	DeviceModel  string `json:"model" help:"device image model"`
	ImageChannel string `json:"imageChannel" help:"image channel"`
	BuildNumber  int32  `json:"buildNumber" help:"build number"`
}

func (*Configuration) PickByTarget

func (cfg *Configuration) PickByTarget(what, productionValue, stagingValue string) (value string)

Jump to

Keyboard shortcuts

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