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 ClusterListInRequest
- type ClusterName
- type ClusterReport
- type ClusterReports
- type ContextKey
- type DBDriver
- type DisabledRuleResponse
- type ErrorKey
- type ErrorKeyMetadata
- type ForbiddenError
- type GlobalRuleConfig
- type Identity
- type Internal
- type ItemNotFoundError
- type JWTPayload
- type KafkaOffset
- type NoBodyError
- type OrgID
- type ReportItem
- type ReportResponse
- type ReportResponseMeta
- type ReportRules
- type RequestID
- type RouterMissingParamError
- type RouterParsingError
- type Rule
- type RuleContent
- type RuleContentDirectory
- type RuleContentResponse
- type RuleErrorKey
- type RuleErrorKeyContent
- type RuleID
- type RuleOnReport
- type RulePluginInfo
- type RuleWithContent
- type SchemaVersion
- type Timestamp
- type Token
- type UnauthorizedError
- type UserID
- type UserVote
- type ValidationError
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 ClusterListInRequest ¶ added in v1.6.5
type ClusterListInRequest struct {
Clusters []string `json:"clusters"`
}
ClusterListInRequest represents request body containing list of clusters
type ClusterName ¶
type ClusterName string
ClusterName represents name of cluster in format c8590f31-e97e-4b85-b506-c45ce1911a12
type ClusterReports ¶ added in v1.6.6
type ClusterReports struct {
ClusterList []ClusterName `json:"clusters"`
Errors []ClusterName `json:"errors"`
Reports map[ClusterName]interface{} `json:"reports"`
GeneratedAt string `json:"generated_at"`
Status string `json:"status"`
}
ClusterReports is a data structure containing list of clusters, list of errors and dictionary with results per cluster. This structure is used by aggregator to return more reports.
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 ErrorKeyMetadata ¶ added in v1.6.3
type ErrorKeyMetadata struct {
Condition string `yaml:"condition" json:"condition"`
Description string `yaml:"description" json:"description"`
Impact string `yaml:"impact" json:"impact"`
Likelihood int `yaml:"likelihood" json:"likelihood"`
PublishDate string `yaml:"publish_date" json:"publish_date"`
Status string `yaml:"status" json:"status"`
Tags []string `yaml:"tags" json:"tags"`
}
ErrorKeyMetadata is a Go representation of the `metadata.yaml` file inside of an error key content directory.
type ForbiddenError ¶ added in v1.6.2
type ForbiddenError struct {
ErrString string
}
ForbiddenError means you don't have permission to do a particular action, for example your account belongs to a different organization
func (*ForbiddenError) Error ¶ added in v1.6.2
func (e *ForbiddenError) Error() string
type GlobalRuleConfig ¶ added in v1.6.3
GlobalRuleConfig represents the file that contains metadata globally applicable to any/all rule content.
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 ReportItem ¶ added in v1.4.1
type ReportItem struct {
Module RuleID `json:"component"`
ErrorKey ErrorKey `json:"key"`
TemplateData json.RawMessage `json:"details"`
}
ReportItem represents a single (hit) rule of the string encoded report
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 RuleContent ¶ added in v1.6.3
type RuleContent struct {
Summary string `json:"summary"`
Reason string `json:"reason"`
Resolution string `json:"resolution"`
MoreInfo string `json:"more_info"`
Plugin RulePluginInfo `json:"plugin"`
ErrorKeys map[string]RuleErrorKeyContent `json:"error_keys"`
HasReason bool
}
RuleContent wraps all the content available for a rule into a single structure.
type RuleContentDirectory ¶ added in v1.6.3
type RuleContentDirectory struct {
Config GlobalRuleConfig
Rules map[string]RuleContent
}
RuleContentDirectory contains content for all available rules in a directory.
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"`
Internal bool `json:"internal"`
}
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 RuleErrorKeyContent ¶ added in v1.6.3
type RuleErrorKeyContent struct {
Generic string `json:"generic"`
Metadata ErrorKeyMetadata `json:"metadata"`
TotalRisk int `json:"total_risk"`
Reason string `json:"reason"`
// DONTFIX has_reason until CCXDEV-5021
HasReason bool
}
RuleErrorKeyContent wraps content of a single error key.
type RuleOnReport ¶
type RuleOnReport struct {
Module RuleID `json:"component"`
ErrorKey ErrorKey `json:"key"`
UserVote UserVote `json:"user_vote"`
Disabled bool `json:"disabled"`
DisableFeedback string `json:"disable_feedback"`
DisabledAt Timestamp `json:"disabled_at"`
TemplateData interface{} `json:"details"`
}
RuleOnReport represents a single (hit) rule of the string encoded report
type RulePluginInfo ¶ added in v1.6.3
type RulePluginInfo struct {
Name string `yaml:"name" json:"name"`
NodeID string `yaml:"node_id" json:"node_id"`
ProductCode string `yaml:"product_code" json:"product_code"`
PythonModule string `yaml:"python_module" json:"python_module"`
}
RulePluginInfo is a Go representation of the `plugin.yaml` file inside of the rule content directory.
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"`
Internal bool `json:"internal"`
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 SchemaVersion ¶ added in v1.6.9
type SchemaVersion uint8
SchemaVersion is just a constant integer for now, max value 255. If we one day need more versions, better consider upgrading to semantic versioning.
type Timestamp ¶
type Timestamp string
Timestamp represents any timestamp in a form gathered from database TODO: need to be improved
type Token ¶
type Token struct {
Identity Identity `json:"identity"`
}
Token is x-rh-identity struct
type UnauthorizedError ¶ added in v1.6.2
type UnauthorizedError struct {
}
UnauthorizedError means server can't authorize you, for example the token is missing or malformed
func (*UnauthorizedError) Error ¶ added in v1.6.2
func (e *UnauthorizedError) Error() string
type ValidationError ¶ added in v1.4.3
ValidationError validation error, for example when string is longer then expected
func (*ValidationError) Error ¶ added in v1.4.3
func (e *ValidationError) Error() string