types

package
v1.21.9 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: Apache-2.0 Imports: 8 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 Acknowledgement added in v1.13.0

type Acknowledgement struct {
	Acknowledged  bool   `json:"-"` // let's skip this one in responses
	Rule          string `json:"rule"`
	Justification string `json:"justification"`
	CreatedBy     string `json:"created_by"`
	CreatedAt     string `json:"created_at"`
	UpdatedAt     string `json:"updated_at"`
}

Acknowledgement represents user acknowledgement of given rule

type AcknowledgementJustification added in v1.13.0

type AcknowledgementJustification struct {
	Value string `json:"justification"`
}

AcknowledgementJustification data structure represents body of request with specified justification of given acknowledgement

type AcknowledgementRuleSelectorJustification added in v1.13.0

type AcknowledgementRuleSelectorJustification struct {
	RuleSelector RuleSelector `json:"rule_id"`
	Value        string       `json:"justification"`
}

AcknowledgementRuleSelectorJustification data structure represents body of request with specified rule selector and justification of given acknowledgement

type AcknowledgementsMetadata added in v1.13.0

type AcknowledgementsMetadata struct {
	Count int `json:"count"`
}

AcknowledgementsMetadata contains metadata about list of acknowledgements

type AcknowledgementsResponse added in v1.13.0

type AcknowledgementsResponse struct {
	Metadata AcknowledgementsMetadata `json:"meta"`
	Data     []Acknowledgement        `json:"data"`
}

AcknowledgementsResponse is structure returned to client in JSON serialization format

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 Component added in v1.14.0

type Component string

Component represent name of component (of rule)

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 DatabaseVersion added in v1.21.5

type DatabaseVersion uint

DatabaseVersion specifies the latest version the database has been migrated to. It might be zero in case of any migration issue.

type DatabaseVersionStruct added in v1.21.5

type DatabaseVersionStruct struct {
	DatabaseVersion DatabaseVersion `json:"database_version"`
}

DatabaseVersionStruct is a data structure to be returned in JSON format by Insights Results Aggregator.

type DisabledRule added in v1.15.0

type DisabledRule struct {
	ClusterID  ClusterName
	RuleID     RuleID
	ErrorKey   ErrorKey
	Disabled   RuleToggle
	DisabledAt sql.NullTime
	EnabledAt  sql.NullTime
	UpdatedAt  sql.NullTime
}

DisabledRule represents a record from rule_cluster_toggle

type DisabledRuleReason added in v1.17.0

type DisabledRuleReason struct {
	ClusterID ClusterName
	RuleID    RuleID
	ErrorKey  ErrorKey
	Message   string
	AddedAt   sql.NullTime
	UpdatedAt sql.NullTime
}

DisabledRuleReason represents a record from cluster_user_rule_disable_feedback table

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      Impact   `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 HittingClusters added in v1.21.2

type HittingClusters struct {
	Metadata    HittingClustersMetadata `json:"meta"`
	ClusterList []HittingClustersData   `json:"data"`
	Status      string                  `json:"status"`
}

HittingClusters is a data structure containing list of clusters hit by a concrete rule hitting the given rule.

type HittingClustersData added in v1.21.2

type HittingClustersData struct {
	Cluster ClusterName `json:"cluster"`
}

HittingClustersData used to store data of clusters hit by a concrete rule

type HittingClustersMetadata added in v1.21.2

type HittingClustersMetadata struct {
	Count    int          `json:"count"`
	Selector RuleSelector `json:"rule_id"`
}

HittingClustersMetadata used to store metadata of clusters hit by a concrete rule

type Identity

type Identity struct {
	AccountNumber UserID   `json:"account_number"`
	Internal      Internal `json:"internal"`
}

Identity contains internal user info

type Impact added in v1.21.2

type Impact struct {
	Name   string `yaml:"name" json:"name"`
	Impact int    `yaml:"impact" json:"impact"`
}

Impact is contained in ErrorKeyMetadata

type ImpactedClustersCnt added in v1.19.3

type ImpactedClustersCnt uint32

ImpactedClustersCnt represents the number of clusters impacted by a rule

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 MetricsConfiguration added in v1.21.9

type MetricsConfiguration struct {
	Job              string `mapstructure:"job_name" toml:"job_name"`
	GatewayURL       string `mapstructure:"gateway_url" toml:"gateway_url"`
	GatewayAuthToken string `mapstructure:"gateway_auth_token" toml:"gateway_auth_token"`
	TimeBetweenPush  int    `mapstructure:"time_between_push" toml:"time_between_push"`
}

MetricsConfiguration holds metrics related configuration

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 RecommendationImpactedClusters added in v1.19.3

type RecommendationImpactedClusters map[RuleID]ImpactedClustersCnt

RecommendationImpactedClusters is returned by aggregator for the purposes of /rule/ recommendation list endpoint

type RecommendationListRow added in v1.19.3

type RecommendationListRow struct {
	RuleID              RuleID              `json:"rule_id"`
	ImpactedClustersCnt ImpactedClustersCnt `json:"impacted_clusters_cnt"`
}

RecommendationListRow represents a single row retrieved from recommendation table for the purposes of Recommendations List (list of rules + number of impacted clusters)

type RecommendationRow added in v1.19.3

type RecommendationRow struct {
	// RuleID is in "|" format
	RuleID    RuleID       `json:"rule_id"`
	RuleFQDN  RuleFQDN     `json:"rule_fqdn"`
	ErrorKey  ErrorKey     `json:"error_key"`
	OrgID     OrgID        `json:"org_id"`
	ClusterID ClusterName  `json:"cluster_id"`
	CreatedAt sql.NullTime `json:"created_at"`
}

RecommendationRow represents a single row in the recommendation table

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"`
	Generic    string `json:"generic"`
	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 {
	Plugin     RulePluginInfo                 `json:"plugin"`
	ErrorKeys  map[string]RuleErrorKeyContent `json:"error_keys"`
	Generic    string                         `json:"generic"`
	Summary    string                         `json:"summary"`
	Resolution string                         `json:"resolution"`
	MoreInfo   string                         `json:"more_info"`
	Reason     string                         `json:"reason"`
	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 RuleContentStatus added in v1.20.1

type RuleContentStatus struct {
	RuleType RuleType         `json:"type"`
	Loaded   bool             `json:"loaded"`
	Error    RuleParsingError `json:"error"`
}

RuleContentStatus type store information about rule content parsed and checked by Content Service

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"`
	Summary     string    `json:"summary"`
	Reason      string    `json:"reason"`
	Resolution  string    `json:"resolution"`
	MoreInfo    string    `json:"more_info"`
	Tags        []string  `json:"tags"`
}

RuleErrorKey represents the content of rule_error_key table

type RuleErrorKeyContent added in v1.6.3

type RuleErrorKeyContent struct {
	Metadata   ErrorKeyMetadata `json:"metadata"`
	TotalRisk  int              `json:"total_risk"`
	Generic    string           `json:"generic"`
	Summary    string           `json:"summary"`
	Resolution string           `json:"resolution"`
	MoreInfo   string           `json:"more_info"`
	Reason     string           `json:"reason"`
	// DONTFIX has_reason until CCXDEV-5021
	HasReason bool
}

RuleErrorKeyContent wraps content of a single error key.

type RuleFQDN added in v1.19.3

type RuleFQDN string

RuleFQDN represents type for rule FQDN (rule module)

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 RuleParsingError added in v1.20.1

type RuleParsingError string

RuleParsingError represents textual and human-readable form of (any) error occured during reading, parsing, and checking rule content in Content Service

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 RuleRating added in v1.19.1

type RuleRating struct {
	Rule   string   `json:"rule"`
	Rating UserVote `json:"rating"`
}

RuleRating represents the body request of request to the rating endpoint

type RuleSelector added in v1.13.0

type RuleSelector string

RuleSelector represents component + error key

type RuleToggle added in v1.15.0

type RuleToggle int

RuleToggle is a type for user's vote

type RuleType added in v1.20.1

type RuleType string

RuleType identifies whether the rule is external or internal one INFO: might be stored as a bool, but number of rule types might be enhanced later

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 SystemWideRuleDisable added in v1.18.0

type SystemWideRuleDisable struct {
	OrgID         OrgID        `json:"org_id"`
	UserID        UserID       `json:"user_id"`
	RuleID        RuleID       `json:"rule_id"`
	ErrorKey      ErrorKey     `json:"error_key"`
	Justification string       `json:"justification"`
	CreatedAt     sql.NullTime `json:"created_at"`
	UpdatedAT     sql.NullTime `json:"updated_at"`
}

SystemWideRuleDisable represents a record from rule_disable table

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