Documentation
¶
Overview ¶
Package types contains declaration of various data types (usually structures) used elsewhere in the aggregator code.
Index ¶
- Constants
- Variables
- func HandleServerError(writer http.ResponseWriter, err error)
- type AuthenticationError
- type ClusterName
- type ClusterReport
- type ContextKey
- type DBDriver
- type DisabledRuleResponse
- type ErrorKey
- type Identity
- type Internal
- type ItemNotFoundError
- type JWTPayload
- type KafkaOffset
- type NoBodyError
- type OrgID
- type ReportResponse
- type ReportResponseMeta
- type ReportRules
- type RequestID
- type RouterMissingParamError
- type RouterParsingError
- type Rule
- type RuleContentResponse
- type RuleErrorKey
- type RuleID
- type RuleOnReport
- type RuleWithContent
- type Timestamp
- type Token
- type UserID
- type UserVote
Constants ¶
const ( // ContextKeyUser is a constant for user authentication token in request ContextKeyUser = ContextKey("user") )
Variables ¶
var ErrOldReport = errors.New("More recent report already exists in storage")
ErrOldReport is an error returned if a more recent already exists on the storage while attempting to write a report for a cluster.
Functions ¶
func HandleServerError ¶
func HandleServerError(writer http.ResponseWriter, err error)
HandleServerError handles separate server errors and sends appropriate responses
Types ¶
type AuthenticationError ¶
type AuthenticationError struct {
// contains filtered or unexported fields
}
AuthenticationError happens during auth problems, for example malformed token
func (*AuthenticationError) Error ¶
func (e *AuthenticationError) Error() string
type ClusterName ¶
type ClusterName string
ClusterName represents name of cluster in format c8590f31-e97e-4b85-b506-c45ce1911a12
type ContextKey ¶
type ContextKey string
ContextKey is a type for user authentication token in request
type DisabledRuleResponse ¶
type DisabledRuleResponse struct {
RuleModule string `json:"rule_id"`
Description string `json:"description"`
Generic string `json:"details"`
DisabledAt string `json:"disabled_at"`
}
DisabledRuleResponse represents a single disabled rule displaying only identifying information
type Identity ¶
type Identity struct {
AccountNumber UserID `json:"account_number"`
Internal Internal `json:"internal"`
}
Identity contains internal user info
type Internal ¶
type Internal struct {
OrgID OrgID `json:"org_id,string"`
}
Internal contains information about organization ID
type ItemNotFoundError ¶
type ItemNotFoundError struct {
ItemID interface{}
}
ItemNotFoundError shows that item with id ItemID wasn't found in the storage
func (*ItemNotFoundError) Error ¶
func (e *ItemNotFoundError) Error() string
Error returns error string
type JWTPayload ¶
type JWTPayload struct {
AccountNumber UserID `json:"account_number"`
OrgID OrgID `json:"org_id,string"`
}
JWTPayload is structure that contain data from parsed JWT token
type NoBodyError ¶
type NoBodyError struct{}
NoBodyError error meaning that client didn't provide body when it's required
func (*NoBodyError) Error ¶
func (*NoBodyError) Error() string
type ReportResponse ¶
type ReportResponse struct {
Meta ReportResponseMeta `json:"meta"`
Report []RuleOnReport `json:"reports"`
}
ReportResponse represents the response of /report endpoint
type ReportResponseMeta ¶
type ReportResponseMeta struct {
Count int `json:"count"`
LastCheckedAt Timestamp `json:"last_checked_at"`
}
ReportResponseMeta contains metadata about the report
type ReportRules ¶
type ReportRules struct {
HitRules []RuleOnReport `json:"reports"`
SkippedRules []RuleOnReport `json:"skips"`
PassedRules []RuleOnReport `json:"pass"`
TotalCount int
}
ReportRules is a helper struct for easy JSON unmarshalling of string encoded report
type RequestID ¶
type RequestID string
RequestID is used to store the request ID supplied in input Kafka records as a unique identifier of payloads. Empty string represents a missing request ID.
type RouterMissingParamError ¶
type RouterMissingParamError struct {
ParamName string
}
RouterMissingParamError missing parameter in request
func (*RouterMissingParamError) Error ¶
func (e *RouterMissingParamError) Error() string
type RouterParsingError ¶
RouterParsingError parsing error, for example string when we expected integer
func (*RouterParsingError) Error ¶
func (e *RouterParsingError) Error() string
type Rule ¶
type Rule struct {
Module RuleID `json:"module"`
Name string `json:"name"`
Summary string `json:"summary"`
Reason string `json:"reason"`
Resolution string `json:"resolution"`
MoreInfo string `json:"more_info"`
}
Rule represents the content of rule table
type RuleContentResponse ¶
type RuleContentResponse struct {
CreatedAt string `json:"created_at"`
Description string `json:"description"`
ErrorKey string `json:"-"`
Generic string `json:"details"`
Reason string `json:"reason"`
Resolution string `json:"resolution"`
TotalRisk int `json:"total_risk"`
RiskOfChange int `json:"risk_of_change"`
RuleModule RuleID `json:"rule_id"`
TemplateData interface{} `json:"extra_data"`
Tags []string `json:"tags"`
UserVote UserVote `json:"user_vote"`
Disabled bool `json:"disabled"`
}
RuleContentResponse represents a single rule in the response of /report endpoint
type RuleErrorKey ¶
type RuleErrorKey struct {
ErrorKey ErrorKey `json:"error_key"`
RuleModule RuleID `json:"rule_module"`
Condition string `json:"condition"`
Description string `json:"description"`
Impact int `json:"impact"`
Likelihood int `json:"likelihood"`
PublishDate time.Time `json:"publish_date"`
Active bool `json:"active"`
Generic string `json:"generic"`
Tags []string `json:"tags"`
}
RuleErrorKey represents the content of rule_error_key table
type RuleOnReport ¶
type RuleOnReport struct {
Module RuleID `json:"component"`
ErrorKey ErrorKey `json:"key"`
UserVote UserVote `json:"user_vote"`
Disabled bool `json:"disabled"`
TemplateData interface{} `json:"details"`
}
RuleOnReport represents a single (hit) rule of the string encoded report
type RuleWithContent ¶
type RuleWithContent struct {
Module RuleID `json:"module"`
Name string `json:"name"`
Summary string `json:"summary"`
Reason string `json:"reason"`
Resolution string `json:"resolution"`
MoreInfo string `json:"more_info"`
ErrorKey ErrorKey `json:"error_key"`
Condition string `json:"condition"`
Description string `json:"description"`
TotalRisk int `json:"total_risk"`
RiskOfChange int `json:"risk_of_change"`
PublishDate time.Time `json:"publish_date"`
Active bool `json:"active"`
Generic string `json:"generic"`
Tags []string `json:"tags"`
}
RuleWithContent represents a rule with content, basically the mix of rule and rule_error_key tables' content
type Timestamp ¶
type Timestamp string
Timestamp represents any timestamp in a form gathered from database TODO: need to be improved