Documentation ¶
Index ¶
- Constants
- Variables
- func CompressPayload(payload []byte) ([]byte, error)
- func UncompressPayload(payload []byte) ([]byte, error)
- type Change
- type ChangeDetail
- type ChangeID
- type ChangeMetadata
- type ChangeSeverity
- type ChangeTracker
- type CompatChangeRegistry
- type ConfigTableFieldCondition
- type ConfigTableFieldUpdate
- type ConfigTableUpdates
- type Content
- type DataPlaneConfig
- type KongCACertificateLoader
- type KongCertificateLoader
- type KongConfigurationLoader
- type KongConsumerLoader
- type KongPluginLoader
- type KongRouteLoader
- type KongSNILoader
- type KongServiceLoader
- type KongTargetLoader
- type KongUpstreamLoader
- type Loader
- type Map
- type Mutator
- type MutatorOpts
- type ParametersLoader
- type Processor
- type ResourceInfo
- type TrackedChanges
- type UpdateType
- type VersionCompatibility
- type VersionCompatibilityOpts
- type VersionLoader
- type VersionedConfigUpdates
- type WSVersionCompatibility
Constants ¶
const ( // MaxChanges is the maximum number of changes tracked by ChangeTracker. MaxChanges = 128 // MaxResourcesPerChange is the maximum number of resource that // ChangeTracker will record for a specific change. MaxResourcesPerChange = 128 )
const KongGatewayCompatibilityVersion = "3.0.0"
Variables ¶
var ChangeRegistry = newCompatChangeRegistry()
ChangeRegistry holds all changes.
var ErrRegistryEntryNotFound = errors.New("not found")
Functions ¶
func CompressPayload ¶
func UncompressPayload ¶
Types ¶
type Change ¶
type Change struct { // Metadata holds metadata associated with a change. Metadata ChangeMetadata // SemverRange is the version range for which this change must be executed to // guarantee compatibility. SemverRange string // Update holds a declarative definition of the change that must be // applied to a specific schema. Update ConfigTableUpdates }
Change is a configuration change that is done automatically by the control-plane in order to achieve compatibility with a Kong data-plane.
type ChangeDetail ¶
type ChangeDetail struct { ID ChangeID Resources []ResourceInfo }
ChangeDetail is a change ID that applies to multiple resources.
type ChangeID ¶
type ChangeID string
ChangeID is a globally unique identifier for each compatibility change definition.
type ChangeMetadata ¶
type ChangeMetadata struct { // ID identifies a change uniquely. Required. ID ChangeID // Severity identifies the severity of a change. Required. // Read Severities defined in this package for more details. Severity ChangeSeverity // Description is a human-readable sentence describing the impact of the // change. Required. Description string // Resolution is a human-readable sentence describing the path to // resolution. Required. Resolution string // DocumentationURL is an optional web URL that further details the // change or its resolution. DocumentationURL string }
ChangeMetadata holds metadata for a specific change.
type ChangeSeverity ¶
type ChangeSeverity string
const ( // ChangeSeverityWarning is a configuration warning. // This is used to highlight the use of a deprecated configuration field. // This severity implies that there is no change in functionality of the // gateway. ChangeSeverityWarning ChangeSeverity = "warning" // ChangeSeverityError is a configuration error. // This is used to highlight a compatibility change that result in the // behavior of the gateway to be different from what the intention of the // user. ChangeSeverityError ChangeSeverity = "error" )
type ChangeTracker ¶
type ChangeTracker struct {
// contains filtered or unexported fields
}
ChangeTracker tracks changes for a given configuration. Tracking is bounded i.e. it there is an upper limits to the amount of changes that are tracked. Tracking changes or resources beyond MaxChanges or MaxResourcesPerChange is a no-op. Duplicated changes are de-duplicated. ChangeTracker is not thread-safe.
func NewChangeTracker ¶
func NewChangeTracker() *ChangeTracker
NewChangeTracker returns a new ChangeTracker.
func (*ChangeTracker) Get ¶
func (c *ChangeTracker) Get() TrackedChanges
Get returns all the changes tracked up until this point. The response is sorted alphabetically and deterministic.
func (*ChangeTracker) Track ¶
func (c *ChangeTracker) Track(id ChangeID) error
Track tracks a change with id. The change is not associated with any resource. If ChangeTracker's capacity has been reached, the call is a no-op.
func (*ChangeTracker) TrackForResource ¶
func (c *ChangeTracker) TrackForResource(id ChangeID, r ResourceInfo) error
TrackForResource tracks a change with id for resource referenced by r. If ChangeTracker's capacity has been reached, the call is a no-op.
type CompatChangeRegistry ¶
type CompatChangeRegistry interface { // Register registers a change. // If a change is already registers or if a change is invalid, // it returns an error. Register(c Change) error // GetMetadata returns ChangeMetadata for an id. // It returns ErrRegistryEntryNotFound if a change with id has not been previously // registered. GetMetadata(id ChangeID) (ChangeMetadata, error) // GetUpdates returns configuration updates for all registered // changes. The order of updates within a version is not deterministic. GetUpdates() VersionedConfigUpdates }
CompatChangeRegistry holds compatibility changes. Implementations may not be thread safe.
type ConfigTableFieldCondition ¶
type ConfigTableFieldCondition struct { // Field is a top-level or nested field; use dot notation for nested fields. Field string // Condition is an expression for matching criteria. // uses gjson path syntax; https://github.com/tidwall/gjson#path-syntax Condition string // Updates is an array of updates to perform based on the matched criteria. Updates []ConfigTableFieldUpdate }
type ConfigTableFieldUpdate ¶
type ConfigTableFieldUpdate struct { // Field to perform update or delete operation on; if Value is nil or // ValueFromField is empty the field will be removed. Field string // Value when specified is the value applied to the key referenced in the // member Field. Value interface{} // ValueFromField when specified represents the name of the key whose value is // retrieved and applied to the key referenced in the member Field. ValueFromField string }
type ConfigTableUpdates ¶
type ConfigTableUpdates struct { // Name is the name of the configuration or field depending on UpdateType. Name string // UpdateType is the type of update being performed; currently plugins only. Type UpdateType // RemoveFields will remove fields from the configuration table. // // Values contained within this array are associated with a field name inside // the configuration table. The value can be a top-level field or a nested // field which is separated using the dot notation. RemoveFields []string // RemoveElementsFromArray will remove an array element from a field in the // configuration table. // // Values contained within this array are associated with a field and a // condition. If the condition matches for the given field, the array in which // the match occurred (e.g. index) will be removed from the configuration // table. RemoveElementsFromArray []ConfigTableFieldCondition // FieldUpdates will create/update a field to a new value in the configuration // table. // // Values contained within this array are associated with a field, a // condition, and an array of updates to perform. New fields can be created, // original fields can be updated, and specific fields can be removed // depending on the version compatibility requirement of the data plane // version being targeted. FieldUpdates []ConfigTableFieldCondition // Remove indicates whether the whole entity should be removed or not. Remove bool // ChangeID is a unique identifier for every schema update. ChangeID ChangeID // DisableChangeTracking takes in JSON encoded string representation of // UpdateType denoted by Type defined above. // This callback gives an opportunity to the change to dynamically disable // change tracking. // // An example use-case is when a newly added field with a backwards-compatible // default value is dropped from the configuration. In this case, the user // doesn't need to be notified of a benign change. // When unspecified, the change is always emitted. DisableChangeTracking func(rawJSON string) bool }
type Content ¶
func ReconfigurePayload ¶
func ReconfigurePayload(c DataPlaneConfig) (Content, error)
type DataPlaneConfig ¶
type DataPlaneConfig Map
type KongCACertificateLoader ¶
type KongCACertificateLoader struct {
Client admin.CACertificateServiceClient
}
func (*KongCACertificateLoader) Mutate ¶
func (l *KongCACertificateLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongCACertificateLoader) Name ¶
func (l KongCACertificateLoader) Name() string
type KongCertificateLoader ¶
type KongCertificateLoader struct {
Client admin.CertificateServiceClient
}
func (*KongCertificateLoader) Mutate ¶
func (l *KongCertificateLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongCertificateLoader) Name ¶
func (l KongCertificateLoader) Name() string
type KongConfigurationLoader ¶
type KongConfigurationLoader struct {
// contains filtered or unexported fields
}
func (*KongConfigurationLoader) Register ¶
func (l *KongConfigurationLoader) Register(mutator Mutator) error
type KongConsumerLoader ¶
type KongConsumerLoader struct {
Client admin.ConsumerServiceClient
}
func (*KongConsumerLoader) Mutate ¶
func (l *KongConsumerLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
Mutate reads the Consumer data from CP persistence store and populates the read data into config.
func (KongConsumerLoader) Name ¶
func (l KongConsumerLoader) Name() string
type KongPluginLoader ¶
type KongPluginLoader struct {
Client admin.PluginServiceClient
}
func (*KongPluginLoader) Mutate ¶
func (l *KongPluginLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongPluginLoader) Name ¶
func (l KongPluginLoader) Name() string
type KongRouteLoader ¶
type KongRouteLoader struct {
Client admin.RouteServiceClient
}
func (*KongRouteLoader) Mutate ¶
func (l *KongRouteLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongRouteLoader) Name ¶
func (l KongRouteLoader) Name() string
type KongSNILoader ¶
type KongSNILoader struct {
Client admin.SNIServiceClient
}
func (*KongSNILoader) Mutate ¶
func (l *KongSNILoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongSNILoader) Name ¶
func (l KongSNILoader) Name() string
type KongServiceLoader ¶
type KongServiceLoader struct {
Client admin.ServiceServiceClient
}
func (*KongServiceLoader) Mutate ¶
func (l *KongServiceLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongServiceLoader) Name ¶
func (l KongServiceLoader) Name() string
type KongTargetLoader ¶
type KongTargetLoader struct {
Client admin.TargetServiceClient
}
func (*KongTargetLoader) Mutate ¶
func (l *KongTargetLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongTargetLoader) Name ¶
func (l KongTargetLoader) Name() string
type KongUpstreamLoader ¶
type KongUpstreamLoader struct {
Client admin.UpstreamServiceClient
}
func (*KongUpstreamLoader) Mutate ¶
func (l *KongUpstreamLoader) Mutate(ctx context.Context, opts MutatorOpts, config DataPlaneConfig, ) error
func (KongUpstreamLoader) Name ¶
func (l KongUpstreamLoader) Name() string
type Mutator ¶
type Mutator interface { Name() string Mutate(context.Context, MutatorOpts, DataPlaneConfig) error }
type MutatorOpts ¶
type MutatorOpts struct {
ClusterID string
}
type ParametersLoader ¶
type ParametersLoader struct {
ClusterID string
}
func NewParametersLoader ¶
func NewParametersLoader(clusterID string) (*ParametersLoader, error)
NewParametersLoader creates a parameters configuration loader. It requires a valid UUID.
func (*ParametersLoader) Mutate ¶
func (l *ParametersLoader) Mutate(_ context.Context, _ MutatorOpts, config DataPlaneConfig, ) error
Mutate updates the config parameters, a map of key:value pairs.
func (ParametersLoader) Name ¶
func (l ParametersLoader) Name() string
Name returns the name of the loader.
type Processor ¶
type Processor func(uncompressedPayload string, dataPlaneVersion versioning.Version, tracker *ChangeTracker, logger *zap.Logger) (string, error)
type ResourceInfo ¶
ResourceInfo serves as a pointer to a resource of Type and ID within the entire configuration of Kong gateway.
func (ResourceInfo) Valid ¶
func (r ResourceInfo) Valid() error
type TrackedChanges ¶
type TrackedChanges struct { // Changes are resource-specific changes. ChangeDetails []ChangeDetail }
TrackedChanges contains all changes recorded by ChangeTracker.
type UpdateType ¶
type UpdateType uint8
const ( // Plugin is the UpdateType referring to plugins' config schema updates // e.g.: `$.config_table.plugins[?(@.name == '(PLUGIN_NAME)')].config`. Plugin UpdateType = iota // CorePlugin is the UpdateType referring to plugins's core schema updates // e.g.: `$.config_table.plugins[?(@.name == '(PLUGIN_NAME)')]`. CorePlugin Service Route Upstream )
func (UpdateType) ConfigTableKey ¶
func (u UpdateType) ConfigTableKey() string
func (UpdateType) String ¶
func (u UpdateType) String() string
type VersionCompatibility ¶
type VersionCompatibility interface { AddConfigTableUpdates(configTableUpdates VersionedConfigUpdates) error ProcessConfigTableUpdates(dataPlaneVersionStr string, compressedPayload []byte) ([]byte, TrackedChanges, error) }
type VersionLoader ¶
type VersionLoader struct{}
func (*VersionLoader) Mutate ¶
func (l *VersionLoader) Mutate(_ context.Context, _ MutatorOpts, config DataPlaneConfig, ) error
func (VersionLoader) Name ¶
func (l VersionLoader) Name() string
type VersionedConfigUpdates ¶
type VersionedConfigUpdates map[string][]ConfigTableUpdates
type WSVersionCompatibility ¶
type WSVersionCompatibility struct {
// contains filtered or unexported fields
}
func NewVersionCompatibilityProcessor ¶
func NewVersionCompatibilityProcessor(opts VersionCompatibilityOpts) (*WSVersionCompatibility, error)
func (*WSVersionCompatibility) AddConfigTableUpdates ¶
func (vc *WSVersionCompatibility) AddConfigTableUpdates(payloadUpdates VersionedConfigUpdates) error
func (*WSVersionCompatibility) ProcessConfigTableUpdates ¶
func (vc *WSVersionCompatibility) ProcessConfigTableUpdates(dataPlaneVersionStr string, compressedPayload []byte, ) ([]byte, TrackedChanges, error)