types

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 6

Documentation

Overview

Package types contains declaration of various data types (usually structures) used elsewhere in the aggregator code.

Index

Constants

View Source
const (
	// ContextKeyUser is a constant for user authentication token in request
	ContextKeyUser = ContextKey("user")
)

Variables

View Source
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 ClusterReport

type ClusterReport string

ClusterReport represents cluster report

type ClusterReports added in v1.6.6

type ClusterReports struct {
	ClusterList []ClusterName                   `json:"clusters"`
	Errors      []ClusterName                   `json:"errors"`
	Reports     map[ClusterName]json.RawMessage `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 DBDriver

type DBDriver int

DBDriver type for db driver enum

const (
	// DBDriverSQLite3 shows that db driver is sqlite
	DBDriverSQLite3 DBDriver = iota
	// DBDriverPostgres shows that db driver is postgres
	DBDriverPostgres
	// DBDriverGeneral general sql(used for mock now)
	DBDriverGeneral
)

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 ErrorKey

type ErrorKey string

ErrorKey represents type for error key

type ErrorKeyMetadata added in v1.6.3

type ErrorKeyMetadata struct {
	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

type GlobalRuleConfig struct {
	Impact map[string]int `yaml:"impact" json:"impact"`
}

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 KafkaOffset

type KafkaOffset int64

KafkaOffset type for kafka offset

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 OrgID

type OrgID uint32

OrgID represents organization ID

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

type RouterParsingError struct {
	ParamName  string
	ParamValue interface{}
	ErrString  string
}

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 RuleID

type RuleID string

RuleID represents type for rule id

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 {
	ErrString string
}

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 UserID

type UserID string

UserID represents type for user id

type UserVote

type UserVote int

UserVote is a type for user's vote

const (
	// UserVoteDislike shows user's dislike
	UserVoteDislike UserVote = -1
	// UserVoteNone shows no vote from user
	UserVoteNone UserVote = 0
	// UserVoteLike shows user's like
	UserVoteLike UserVote = 1
)

type ValidationError added in v1.4.3

type ValidationError struct {
	ParamName  string
	ParamValue interface{}
	ErrString  string
}

ValidationError validation error, for example when string is longer then expected

func (*ValidationError) Error added in v1.4.3

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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