Documentation
¶
Index ¶
- Variables
- func OpenAPISpecCORSMiddleware(cfg OpenAPIConfig) func(http.Handler) http.Handler
- func OpenAPISpecHandler(cfg OpenAPIConfig) func(w http.ResponseWriter, r *http.Request)
- func OpenAPIUIHandler(cfg OpenAPIConfig) func(w http.ResponseWriter, r *http.Request)
- func ReadEnvs(envVars string) (map[string]string, error)
- func RunServer(cfg Config, rr Runner) error
- type Config
- type LoadTestStatus
- type LoadTestStatusPage
- type MetricsReporter
- type OpenAPIConfig
- type Proxy
- func (p *Proxy) Create(w http.ResponseWriter, r *http.Request)
- func (p *Proxy) Delete(w http.ResponseWriter, r *http.Request)
- func (p *Proxy) Get(w http.ResponseWriter, r *http.Request)
- func (p *Proxy) GetLogs(w http.ResponseWriter, r *http.Request)
- func (p *Proxy) List(w http.ResponseWriter, r *http.Request)
- type Runner
Constants ¶
This section is empty.
Variables ¶
var ( // ErrFileToStringEmpty is the error returned when the defined users file is empty ErrFileToStringEmpty = errors.New("file is empty") // ErrWrongFileFormat is the error returned when the defined users file is empty ErrWrongFileFormat = errors.New("file format is not supported") // ErrWrongURLFormat is the error returned when the targetURL is not containing scheme ErrWrongURLFormat = errors.New("invalid URL format") // ErrWrongImageFormat is the error returned when the docker image is in wrong format ErrWrongImageFormat = errors.New("invalid image format") // ErrEmptyType is the error returned when there's no loadtest type provided ErrEmptyType = errors.New("loadtest type is empty") )
var ( // ErrInvalidCSVFormat when the number of columns is different than two ErrInvalidCSVFormat = errors.New("invalid csv format for environment variables, expecting: key, value") )
Functions ¶
func OpenAPISpecCORSMiddleware ¶
func OpenAPISpecCORSMiddleware(cfg OpenAPIConfig) func(http.Handler) http.Handler
OpenAPISpecCORSMiddleware returns a middleware to handle CORS requests for OpenAPI spec
func OpenAPISpecHandler ¶
func OpenAPISpecHandler(cfg OpenAPIConfig) func(w http.ResponseWriter, r *http.Request)
OpenAPISpecHandler returns a http handler for OpenAPI Spec
func OpenAPIUIHandler ¶
func OpenAPIUIHandler(cfg OpenAPIConfig) func(w http.ResponseWriter, r *http.Request)
OpenAPIUIHandler returns a http handler for UI built out of OpenAPI Spec
Types ¶
type Config ¶
type Config struct {
HTTPPort int `envconfig:"WEB_HTTP_PORT" default:"8080"`
Logger observability.LoggerConfig
OpenAPI OpenAPIConfig
Report report.Config
MaxLoadTestsRun int
MaxListLimit int64 `envconfig:"MAX_LIST_LIMIT" required:"true" default:"50"`
MasterURL string
AllowedCustomImages bool `envconfig:"ALLOWED_CUSTOM_IMAGES" default:"false"`
// KubeClientTimeout specifies timeout for each operation done by kube client
KubeClientTimeout time.Duration `envconfig:"KUBE_CLIENT_TIMEOUT" default:"5s"`
}
Config is the possible Proxy configurations
type LoadTestStatus ¶
type LoadTestStatus struct {
Type string `json:"type"`
DistributedPods int32 `json:"distributedPods"` // number of distributed pods requested
Namespace string `json:"loadtestName,omitempty"` // namespace created equals the loadtest name
Phase string `json:"phase,omitempty"` // jmeter loadtest status
Tags apisLoadTestV1.LoadTestTags `json:"tags"`
HasEnvVars bool `json:"hasEnvVars"`
HasTestData bool `json:"hasTestData"`
}
LoadTestStatus defines response structure for status request
type LoadTestStatusPage ¶
type LoadTestStatusPage struct {
Limit int64 `json:"limit"`
Continue string `json:"continue"`
Remain *int64 `json:"remain"`
Items []LoadTestStatus `json:"items"`
}
LoadTestStatusPage represents a page of load tests.
type MetricsReporter ¶
type MetricsReporter struct {
// contains filtered or unexported fields
}
MetricsReporter used to interface with the metrics configurations
func NewMetricsReporter ¶
NewMetricsReporter contains loadtest metrics definition
type OpenAPIConfig ¶
type OpenAPIConfig struct {
SpecPath string `envconfig:"OPEN_API_SPEC_PATH" default:"/etc/kangal"`
SpecFile string `envconfig:"OPEN_API_SPEC_FILE" default:"openapi.json"`
ServerURL string `envconfig:"OPEN_API_SERVER_URL"`
ServerDescription string `envconfig:"OPEN_API_SERVER_DESCRIPTION"`
UIUrl string `envconfig:"OPEN_API_UI_URL"`
AccessControlAllowOrigin []string `envconfig:"OPEN_API_CORS_ALLOW_ORIGIN" default:"*"`
AccessControlAllowHeaders []string `envconfig:"OPEN_API_CORS_ALLOW_HEADERS" default:"Content-Type,api_key,Authorization"`
}
OpenAPIConfig is the OpenAPI specification-specific parameters
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy handler
func NewProxy ¶
func NewProxy(maxLoadTestsRun int, registry backends.Registry, kubeClient *kube.Client, maxListLimit int64, allowedCustomImages bool) *Proxy
NewProxy returns new Proxy handlers
func (*Proxy) Create ¶
func (p *Proxy) Create(w http.ResponseWriter, r *http.Request)
Create creates loadtest CR on POST request
func (*Proxy) Delete ¶
func (p *Proxy) Delete(w http.ResponseWriter, r *http.Request)
Delete deletes load test CR
func (*Proxy) Get ¶
func (p *Proxy) Get(w http.ResponseWriter, r *http.Request)
Get returns the loadtest CR info
type Runner ¶
type Runner struct {
Exporter *otelPrometheus.Exporter
KubeClient *kube.Client
Logger *zap.Logger
StatsReporter *MetricsReporter
}
Runner encapsulates all Kangal Proxy API server dependencies