Documentation
¶
Index ¶
Constants ¶
const (
// WellKnownInitialHash is the hash of an empty configuration.
WellKnownInitialHash = "00000000000000000000000000000000"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigurationChangeDetector ¶
type ConfigurationChangeDetector interface {
HasConfigurationChanged(
ctx context.Context,
oldSHA, newSHA []byte,
targetConfigEmpty bool,
lastDBLessConfigHash string,
compareDBLessConfigHash bool,
statusClient StatusClient,
) (bool, error)
}
ConfigurationChangeDetector tells whether a configuration push is necessary.
type FlatEntityError ¶
type FlatEntityError struct {
// Name is the name of the Kong entity.
Name string `json:"entity_name,omitempty" yaml:"entity_name,omitempty"`
// ID is the ID of the Kong entity.
ID string `json:"entity_id,omitempty" yaml:"entity_id,omitempty"`
// Tags are the tags of the Kong entity.
Tags []string `json:"entity_tags,omitempty" yaml:"entity_tags,omitempty"`
// Type is the type of the Kong entity.
Type string `json:"entity_type,omitempty" yaml:"entity_type,omitempty"`
// Errors are the errors associated with the Kong entity.
Errors []FlatError `json:"errors,omitempty" yaml:"errors,omitempty"`
}
FlatEntityError represents a single Kong entity with one or more invalid fields.
func ParseFlatEntityErrors ¶
func ParseFlatEntityErrors(body []byte, logger logr.Logger) ([]FlatEntityError, error)
ParseFlatEntityErrors takes a Kong /config error response body and returns its flattened entity errors. Entities without Kubernetes metadata tags are returned too: callers decide whether to attribute them.
type FlatError ¶
type FlatError struct {
// Field is the name of the entity's field that has an error.
// Optional: Field can be empty if the error is associated with the whole entity.
Field string `json:"field,omitempty" yaml:"field,omitempty"`
// Message is the error associated with Field (for single-value fields) or with a whole entity when Type is "entity".
Message string `json:"message,omitempty" yaml:"message,omitempty"`
// Messages are the errors associated with Field for multi-value fields. The array index in Messages matches the
// array index in the input.
Messages []string `json:"messages,omitempty" yaml:"messages,omitempty"`
// Type tells whether the error is associated with a single field or a whole entity.
Type FlatErrorType `json:"type,omitempty" yaml:"type,omitempty"`
}
FlatError represents an error for a single field within a Kong entity or a whole entity.
type FlatErrorType ¶
type FlatErrorType string
FlatErrorType tells whether a FlatError is associated with a single field or a whole entity.
const ( // FlatErrorTypeField is an error associated with a single field. FlatErrorTypeField FlatErrorType = "field" // FlatErrorTypeEntity is an error associated with a whole entity. FlatErrorTypeEntity FlatErrorType = "entity" )
type KongGatewayConfigurationChangeDetector ¶
type KongGatewayConfigurationChangeDetector struct {
// contains filtered or unexported fields
}
KongGatewayConfigurationChangeDetector detects changes in Kong Gateway configuration. Besides comparing SHA hashes, it also checks if the Kong Gateway has no configuration yet or if the configuration to be pushed is empty.
func NewKongGatewayConfigurationChangeDetector ¶
func NewKongGatewayConfigurationChangeDetector(logger logr.Logger) *KongGatewayConfigurationChangeDetector
NewKongGatewayConfigurationChangeDetector creates a Kong Gateway configuration change detector.
func (*KongGatewayConfigurationChangeDetector) HasConfigurationChanged ¶
func (d *KongGatewayConfigurationChangeDetector) HasConfigurationChanged( ctx context.Context, oldSHA, newSHA []byte, targetConfigEmpty bool, lastDBLessConfigHash string, compareDBLessConfigHash bool, statusClient StatusClient, ) (bool, error)
HasConfigurationChanged verifies whether configuration has changed by comparing old and new config's SHAs. In case the SHAs are equal, it still can return true if a client is considered crashed or just booted up based on its status, or if the hash reported by Kong differs from the hash observed after the last successful push. In case the status indicates an empty config and the desired config is also empty this will return false to prevent continuously sending empty configuration to Gateway.
type KonnectConfigurationChangeDetector ¶
type KonnectConfigurationChangeDetector struct{}
KonnectConfigurationChangeDetector detects changes in Konnect configuration by comparing SHA hashes only.
func NewKonnectConfigurationChangeDetector ¶
func NewKonnectConfigurationChangeDetector() *KonnectConfigurationChangeDetector
NewKonnectConfigurationChangeDetector creates a Konnect configuration change detector.
func (*KonnectConfigurationChangeDetector) HasConfigurationChanged ¶
func (d *KonnectConfigurationChangeDetector) HasConfigurationChanged( _ context.Context, oldSHA, newSHA []byte, _ bool, _ string, _ bool, _ StatusClient, ) (bool, error)
HasConfigurationChanged verifies whether configuration has changed by comparing old and new config's SHAs.
type ResponseParsingError ¶
type ResponseParsingError struct {
// contains filtered or unexported fields
}
ResponseParsingError is an error type that is returned when the response from Kong is not in the expected format.
func NewResponseParsingError ¶
func NewResponseParsingError(responseBody []byte) ResponseParsingError
NewResponseParsingError creates a ResponseParsingError for the given response body.
func (ResponseParsingError) Error ¶
func (e ResponseParsingError) Error() string
Error implements the Error interface.
func (ResponseParsingError) ResponseBody ¶
func (e ResponseParsingError) ResponseBody() []byte
ResponseBody returns the raw HTTP response body from Kong that could not be parsed.