cmd

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(y ...func()) error

func InitConfig

func InitConfig() error

func ReadConfig

func ReadConfig(y ...func())

func ReadYamlFile

func ReadYamlFile(file string, j interface{}, replacor ...func(b []byte) []byte) error

func Write

func Write(marshal Marshal, outpath string, content interface{}) error

func WriteAuto

func WriteAuto(outpath string, content interface{}) error

Types

type ApiConfig added in v0.4.1

type ApiConfig struct {
	Address      string `cfg:"address" default:"0.0.0.0" description:"Address (interface) to listen to)"`
	RedirectPort int    `` /* 142-byte string literal not displayed */
	Port         int    `cfg:"port" default:"80" description:"Port to listen to"`
	CertFile     string `cfg:"cert-file" default:"" description:"Number of request to make total"`
	CertKey      string `cfg:"cert-key" default:"" description:"Number of request to make total"`
	DBLocation   string `cfg:"db-path" default:"./storage/db.bbolt" description:"Filepath to where to store the database"`
}

type AuthConfig

type AuthConfig struct {
	Dynamic DynamicAuth
	Kind    string
	ImpersionationCredentials
	ClientID     string
	RedirectUri  string
	ClientSecret string
	Endpoint     string
	EndpointType string
	Token        string
	Expires      *time.Time
	HeaderKey    string
	Payload      map[string]interface{}
}

type Config

type Config struct {
	Auth              AuthConfig             `cfg:"-"`
	Url               string                 `cfg:"url" description:"The url to make requests to"`
	NoTokenValidation bool                   `cfg:"no-token-validation" description:"If set, will skip validation of token"`
	PrintTable        bool                   `cfg:"print-table" description:"If set, will print table while running"`
	AuthToken         string                 `cfg:"auth-token" description:"Set to use a token"`
	OperationName     string                 `cfg:"operation-name" description:"For Graphql, you may set an operation-name"`
	Body              interface{}            `cfg:"data" short:"d" description:"Data to include in requests."`
	Header            map[string]string      `cfg:"header" short:"H" description:"Additional headers to include"`
	Method            string                 `cfg:"method" short:"X" description:"Http-method"`
	Query             string                 `cfg:"query" description:"For Graphql, you may set a query"`
	Variables         map[string]interface{} `cfg:"variables" description:"For Graphql, you may add variables"`
	LogLevel          string                 `cfg:"log-level" default:"info" description:"Log-level to use. Can be trace,debug,info,warn(ing),error or panic"`
	LogFormat         string                 `cfg:"log-format" default:"human" description:"Format of the logs. Can be human or json"`
	Output            string                 `cfg:"output" description:"File to output results to"`
	OkStatusCodes     []int                  `` /* 142-byte string literal not displayed */
	ResponseData      bool                   `cfg:"response-data" description:"Set to include response-data in output"`
	Mock              bool                   `cfg:"mock" description:"Enable to mock the requests."`
	Concurrency       int                    `cfg:"concurrency" description:"Amount of concurrent requests." default:"100" short:"c"`
	RequestCount      int                    `cfg:"request-count" default:"200" description:"Number of request to make total" short:"n"`
	Api               ApiConfig              `cfg:"api" description:"Used with the api-server"`
}

func GetConfig

func GetConfig(l logger.AppLogger) *Config

type DynamicAuth

type DynamicAuth struct {
	Requests []DynamicRequest
}

type DynamicRequest

type DynamicRequest struct {
	Method         string
	Uri            string
	Headers        map[string]string
	JsonRequest    bool
	JsonResponse   bool
	ResultJmesPath string
	Body           interface{}
}

type ImpersionationCredentials

type ImpersionationCredentials struct {
	// Username to impersonate with. Needs to have the impersonation-role
	Username,
	Password,

	UserIDToImpersonate string
	// Will perform a lookup to get the ID of the username.
	UserNameToImpersonate string
}

type Marshal

type Marshal func(j interface{}) ([]byte, error)

type Output

type Output struct {
	Url             string                                        `json:"url,omitempty"`
	Query           queries.Request                               `json:"query,omitempty"`
	Details         map[requests.ErrorType][]requests.CompactStat `json:"details,omitempty"`
	JwtPayload      map[string]interface{}                        `json:"jwt_payload,omitempty"`
	Count           map[requests.ErrorType]int                    `json:"count,omitempty"`
	Stats           map[requests.ErrorType]requests.Stats         `json:"stats,omitempty"`
	AllRequests     map[requests.ErrorType][]queries.RequestStat  `json:"-"`
	ResponseHashMap requests.ByteHashMap                          `json:"responseHashMap,omitempty"`
	// contains filtered or unexported fields
}

func NewOutput

func NewOutput(l logger.AppLogger, path, url string, query queries.Request, JwtPayload map[string]interface{}) (Output, error)

func (*Output) AddStat

func (o *Output) AddStat(stat requests.RequestStat) *Output

func (*Output) CalculateStats

func (o *Output) CalculateStats()

func (*Output) GetPath

func (o *Output) GetPath() string

func (*Output) PrintTable

func (out *Output) PrintTable()

func (*Output) Write

func (o *Output) Write() error

Jump to

Keyboard shortcuts

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