kongstate

package
v2.10.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const ImplicitPort = "implicitPort"

Variables

This section is empty.

Functions

func PrettyPrintServiceList added in v2.4.0

func PrettyPrintServiceList(services map[string]*corev1.Service) string

PrettyPrintServiceList makes a clean printable list of a map of Kubernetes services for the purpose of logging (errors, info, e.t.c.).

func RawConfigToConfiguration

func RawConfigToConfiguration(config apiextensionsv1.JSON) (kong.Configuration, error)

func SecretToConfiguration

func SecretToConfiguration(
	s SecretGetter,
	reference configurationv1.SecretValueFromSource, namespace string) (
	kong.Configuration, error,
)

Types

type ACLGroup

type ACLGroup struct {
	kong.ACLGroup
}

ACLGroup represents an ACL associated with a consumer. Due to ACL implementation in Kong being similar to credentials, ACLs are treated as credentials, too.

func NewACLGroup

func NewACLGroup(config interface{}) (*ACLGroup, error)

type BasicAuth

type BasicAuth struct {
	kong.BasicAuth
}

BasicAuth represents a basic authentication credential.

func NewBasicAuth

func NewBasicAuth(config interface{}) (*BasicAuth, error)

func (*BasicAuth) SanitizedCopy

func (c *BasicAuth) SanitizedCopy() *BasicAuth

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type Certificate

type Certificate struct {
	kong.Certificate
}

Certificate represents the certificate object in Kong.

func (*Certificate) SanitizedCopy

func (c *Certificate) SanitizedCopy() *Certificate

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type Consumer

type Consumer struct {
	kong.Consumer
	Plugins    []kong.Plugin
	KeyAuths   []*KeyAuth
	HMACAuths  []*HMACAuth
	JWTAuths   []*JWTAuth
	BasicAuths []*BasicAuth
	ACLGroups  []*ACLGroup

	Oauth2Creds []*Oauth2Credential
	MTLSAuths   []*MTLSAuth

	K8sKongConsumer configurationv1.KongConsumer
}

Consumer holds a Kong consumer and its plugins and credentials.

func (*Consumer) SanitizedCopy

func (c *Consumer) SanitizedCopy() *Consumer

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

func (*Consumer) SetCredential

func (c *Consumer) SetCredential(credType string, credConfig interface{}, tags []*string, kongVersion semver.Version) error

type HMACAuth

type HMACAuth struct {
	kong.HMACAuth
}

HMACAuth represents a HMAC credential.

func NewHMACAuth

func NewHMACAuth(config interface{}) (*HMACAuth, error)

func (*HMACAuth) SanitizedCopy

func (c *HMACAuth) SanitizedCopy() *HMACAuth

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type JWTAuth

type JWTAuth struct {
	kong.JWTAuth
}

JWTAuth represents a JWT credential.

func NewJWTAuth

func NewJWTAuth(config interface{}) (*JWTAuth, error)

func (*JWTAuth) SanitizedCopy

func (c *JWTAuth) SanitizedCopy() *JWTAuth

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type KeyAuth

type KeyAuth struct {
	kong.KeyAuth
}

KeyAuth represents a key-auth credential.

func NewKeyAuth

func NewKeyAuth(config interface{}) (*KeyAuth, error)

func (*KeyAuth) SanitizedCopy

func (c *KeyAuth) SanitizedCopy() *KeyAuth

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type KongState

type KongState struct {
	Services       []Service
	Upstreams      []Upstream
	Certificates   []Certificate
	CACertificates []kong.CACertificate
	Licenses       []kong.License
	Plugins        []Plugin
	Consumers      []Consumer
	Version        semver.Version
}

KongState holds the configuration that should be applied to Kong.

func (*KongState) FillConsumersAndCredentials

func (ks *KongState) FillConsumersAndCredentials(log logrus.FieldLogger, s store.Storer)

func (*KongState) FillIDs added in v2.10.0

func (ks *KongState) FillIDs(logger logrus.FieldLogger)

FillIDs iterates over the KongState and fills in the ID field for each entity that supports the FillID method (these are Service, Route and Consumer). It makes their IDs deterministic, enabling their correct identification in external systems (e.g. Konnect Analytics).

func (*KongState) FillOverrides

func (ks *KongState) FillOverrides(log logrus.FieldLogger, s store.Storer)

func (*KongState) FillPlugins

func (ks *KongState) FillPlugins(log logrus.FieldLogger, s store.Storer)

func (*KongState) SanitizedCopy

func (ks *KongState) SanitizedCopy() *KongState

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type MTLSAuth

type MTLSAuth struct {
	kong.MTLSAuth
}

MTLSAuth represents an MTLS auth credential.

func NewMTLSAuth

func NewMTLSAuth(config interface{}) (*MTLSAuth, error)

type Oauth2Credential

type Oauth2Credential struct {
	kong.Oauth2Credential
}

Oauth2Credential represents an OAuth2 client configuration including credentials.

func NewOauth2Credential

func NewOauth2Credential(config interface{}) (*Oauth2Credential, error)

func (*Oauth2Credential) SanitizedCopy

func (c *Oauth2Credential) SanitizedCopy() *Oauth2Credential

SanitizedCopy returns a shallow copy with sensitive values redacted best-effort.

type Plugin

type Plugin struct {
	kong.Plugin
}

Plugin represetns a plugin Object in Kong.

type PortDef

type PortDef struct {
	Mode PortMode

	// Name is the port name as stated in the Kubernetes service. Must be set iff Mode == PortModeName.
	Name string

	// Number is the port number. Must be set iff PortMode == PortModeNumber.
	Number int32
}

func (*PortDef) CanonicalString

func (p *PortDef) CanonicalString() string

type PortMode

type PortMode int
const (
	// PortModeImplicit means that the Ingress does not specify the Kubernetes Service port, and that KIC should expect
	// the Service to have only one port defined.
	PortModeImplicit PortMode = iota
	// PortModeNumber means that the Ingress specifies the Service port by raw port number.
	PortModeByNumber PortMode = iota
	// PortModeNumber means that the Ingress specifies the Service port by its name field.
	PortModeByName PortMode = iota
)

type Route

type Route struct {
	kong.Route

	Ingress          util.K8sObjectInfo
	Plugins          []kong.Plugin
	ExpressionRoutes bool
}

Route represents a Kong Route and holds a reference to the Ingress rule.

type SecretGetter

type SecretGetter interface {
	GetSecret(namespace, name string) (*corev1.Secret, error)
}

type Service

type Service struct {
	kong.Service
	Namespace string
	Routes    []Route
	Plugins   []kong.Plugin

	Backends    []ServiceBackend
	K8sServices map[string]*corev1.Service

	// Parent is the parent object of this Service.
	// It is expected to be a Kubernetes object which translation resulted in creating this Kong Service.
	// For example, if this Service was created as a result of translating a Kubernetes Ingress, then
	// Parent is expected to be the Ingress object itself.
	Parent client.Object
}

Service represents a service in Kong and holds routes associated with the service and other k8s metadata.

type ServiceBackend

type ServiceBackend struct {
	Name      string
	Namespace string
	PortDef   PortDef
	Weight    *int32
}

type ServiceBackends added in v2.4.0

type ServiceBackends []ServiceBackend

type Services added in v2.4.0

type Services []*Service

Services is a list of kongstate.Service objects with sorting enabled based on a lexographical comparison of the underlying kong.Service names which are always expected to be unique.

func (Services) Len added in v2.4.0

func (s Services) Len() int

func (Services) Less added in v2.4.0

func (s Services) Less(i, j int) bool

func (Services) Swap added in v2.4.0

func (s Services) Swap(i, j int)

type Target

type Target struct {
	kong.Target
}

Target is a wrapper around Target object in Kong.

type Upstream

type Upstream struct {
	kong.Upstream
	Targets []Target
	// Service this upstream is asosciated with.
	Service Service
}

Upstream is a wrapper around Upstream object in Kong.

Jump to

Keyboard shortcuts

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