sendconfig

package
v2.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2023 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WellKnownInitialHash is the hash of an empty configuration.
	WellKnownInitialHash = "00000000000000000000000000000000"
)

Variables

This section is empty.

Functions

func PerformUpdate

func PerformUpdate(
	ctx context.Context,
	log logrus.FieldLogger,
	client *adminapi.Client,
	config Config,
	targetContent *file.Content,
	promMetrics *metrics.CtrlFuncMetrics,
	updateStrategyResolver UpdateStrategyResolver,
	configChangeDetector ConfigurationChangeDetector,
) ([]byte, []failures.ResourceFailure, error)

PerformUpdate writes `targetContent` to Kong Admin API specified by `kongConfig`.

Types

type Config added in v2.9.0

type Config struct {
	// Currently, this assumes that all underlying clients are using the same version
	// hence this shared field in here.
	Version semver.Version

	// InMemory tells whether a Kong Gateway Admin APIs should be communicated in DB-less mode.
	// It's not relevant for Konnect client.
	InMemory bool

	// Concurrency defines how many concurrent goroutines should be used when syncing configuration in DB-mode.
	Concurrency int

	// FilterTags are tags used to manage and filter entities in Kong.
	FilterTags []string

	// SkipCACertificates disables CA certificates, to avoid fighting over configuration in multi-workspace
	// environments. See https://github.com/Kong/deck/pull/617
	SkipCACertificates bool

	// EnableReverseSync indicates that reverse sync should be enabled for
	// updates to the data-plane.
	EnableReverseSync bool
}

Config gathers parameters that are needed for sending configuration to Kong Admin APIs.

func (*Config) Init added in v2.9.0

func (c *Config) Init(
	ctx context.Context,
	logger logr.Logger,
	kongClients []*adminapi.Client,
)

Init sets up variables that need external calls.

type ConfigError added in v2.9.0

type ConfigError struct {
	Code      int               `json:"code,omitempty" yaml:"code,omitempty"`
	Flattened []FlatEntityError `json:"flattened_errors,omitempty" yaml:"flattened_errors,omitempty"`
	Message   string            `json:"message,omitempty" yaml:"message,omitempty"`
	Name      string            `json:"name,omitempty" yaml:"name,omitempty"`
}

ConfigError is an error response from Kong's DB-less /config endpoint.

type ConfigErrorFields added in v2.9.0

type ConfigErrorFields struct {
}

ConfigErrorFields is the structure under the "fields" key in a /config error response.

type ConfigService added in v2.9.0

type ConfigService interface {
	ReloadDeclarativeRawConfig(
		ctx context.Context,
		config io.Reader,
		checkHash bool,
		flattenErrors bool,
	) ([]byte, error)
}

type ConfigurationChangeDetector added in v2.9.0

type ConfigurationChangeDetector interface {
	// 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 based on its status.
	HasConfigurationChanged(ctx context.Context, oldSHA, newSHA []byte, client KonnectAwareClient, statusClient StatusClient) (bool, error)
}

type DefaultConfigurationChangeDetector added in v2.9.0

type DefaultConfigurationChangeDetector struct {
	// contains filtered or unexported fields
}

func NewDefaultClientConfigurationChangeDetector added in v2.9.0

func NewDefaultClientConfigurationChangeDetector(log logrus.FieldLogger) *DefaultConfigurationChangeDetector

func (*DefaultConfigurationChangeDetector) HasConfigurationChanged added in v2.9.0

func (d *DefaultConfigurationChangeDetector) HasConfigurationChanged(
	ctx context.Context,
	oldSHA, newSHA []byte,
	client KonnectAwareClient,
	statusClient StatusClient,
) (bool, error)

type DefaultUpdateStrategyResolver added in v2.9.0

type DefaultUpdateStrategyResolver struct {
	// contains filtered or unexported fields
}

func NewDefaultUpdateStrategyResolver added in v2.9.0

func NewDefaultUpdateStrategyResolver(config Config, log logrus.FieldLogger) DefaultUpdateStrategyResolver

func (DefaultUpdateStrategyResolver) ResolveUpdateStrategy added in v2.9.0

func (r DefaultUpdateStrategyResolver) ResolveUpdateStrategy(
	client UpdateClient,
) UpdateStrategy

ResolveUpdateStrategy returns an UpdateStrategy based on the client and configuration. The UpdateStrategy can be either UpdateStrategyDBMode or UpdateStrategyInMemory. Both of them implement different ways to populate Kong instances with data-plane configuration.

type FlatEntityError added in v2.9.0

type FlatEntityError struct {
	Name   string           `json:"entity_name,omitempty" yaml:"entity_name,omitempty"`
	ID     string           `json:"entity_id,omitempty" yaml:"entity_id,omitempty"`
	Tags   []string         `json:"entity_tags,omitempty" yaml:"entity_tags,omitempty"`
	Errors []FlatFieldError `json:"errors,omitempty" yaml:"errors,omitempty"`
}

FlatEntityError represents a single Kong entity with one or more invalid fields.

type FlatFieldError added in v2.9.0

type FlatFieldError struct {
	Field string `json:"field,omitempty" yaml:"field,omitempty"`
	// Message is the error associated with Field for single-value fields.
	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"`
}

FlatFieldError represents an error for a single field within a Kong entity.

type InMemoryClient added in v2.9.0

type InMemoryClient interface {
	BaseRootURL() string
	ReloadDeclarativeRawConfig(ctx context.Context, config io.Reader, checkHash bool, flattenErrors bool) ([]byte, error)
}

type KonnectAwareClient added in v2.9.0

type KonnectAwareClient interface {
	IsKonnect() bool
}

type ResourceError added in v2.9.0

type ResourceError struct {
	Name       string
	Namespace  string
	Kind       string
	APIVersion string
	UID        string
	Problems   map[string]string
}

ResourceError is a Kong configuration error associated with a Kubernetes resource.

type StatusClient added in v2.9.0

type StatusClient interface {
	Status(context.Context) (*kong.Status, error)
}

type UpdateClient added in v2.9.0

type UpdateClient interface {
	IsKonnect() bool
	KonnectRuntimeGroup() string
	AdminAPIClient() *kong.Client
}

type UpdateStrategy added in v2.9.0

type UpdateStrategy interface {
	// Update applies targetConfig to the data-plane.
	Update(ctx context.Context, targetContent *file.Content) (
		err error,
		resourceErrors []ResourceError,
		resourceErrorsParseErr error,
	)

	// MetricsProtocol returns a string describing the update strategy type to be used in metrics.
	MetricsProtocol() metrics.Protocol
}

UpdateStrategy is the way we approach updating data-plane's configuration, depending on its type.

type UpdateStrategyDBMode added in v2.9.0

type UpdateStrategyDBMode struct {
	// contains filtered or unexported fields
}

UpdateStrategyDBMode implements the UpdateStrategy interface. It updates Kong's data-plane configuration using decK's syncer.

func NewUpdateStrategyDBMode added in v2.9.0

func NewUpdateStrategyDBMode(
	client *kong.Client,
	dumpConfig dump.Config,
	version semver.Version,
	concurrency int,
) UpdateStrategyDBMode

func (UpdateStrategyDBMode) MetricsProtocol added in v2.9.0

func (s UpdateStrategyDBMode) MetricsProtocol() metrics.Protocol

func (UpdateStrategyDBMode) Update added in v2.9.0

func (s UpdateStrategyDBMode) Update(ctx context.Context, targetContent *file.Content) (
	err error,
	resourceErrors []ResourceError,
	resourceErrorsParseErr error,
)

type UpdateStrategyInMemory added in v2.9.0

type UpdateStrategyInMemory struct {
	// contains filtered or unexported fields
}

UpdateStrategyInMemory implements the UpdateStrategy interface. It updates Kong's data-plane configuration using its `POST /config` endpoint that is used by ConfigService.ReloadDeclarativeRawConfig.

func NewUpdateStrategyInMemory added in v2.9.0

func NewUpdateStrategyInMemory(
	configService ConfigService,
	log logrus.FieldLogger,
) UpdateStrategyInMemory

func (UpdateStrategyInMemory) MetricsProtocol added in v2.9.0

func (s UpdateStrategyInMemory) MetricsProtocol() metrics.Protocol

func (UpdateStrategyInMemory) Update added in v2.9.0

func (s UpdateStrategyInMemory) Update(ctx context.Context, targetState *file.Content) (
	err error,
	resourceErrors []ResourceError,
	resourceErrorsParseErr error,
)

type UpdateStrategyResolver added in v2.9.0

type UpdateStrategyResolver interface {
	ResolveUpdateStrategy(client UpdateClient) UpdateStrategy
}

Jump to

Keyboard shortcuts

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