plugins

package
v0.1.48 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Package plugins provides a way to manage plugins in a declarative Kong configuration file. The targets are selected using JSONpath selectors. The default is to add the plugins to the main `plugins` array. Nested plugins cannot have references to other entities (eg. a plugin nested in a route cannot reference a service). This is a limitation of the Kong configuration file format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForeignKey

func ForeignKey(plugin *yaml.Node) string

ForeignKey returns a key combining all foreign key values of the given plugin. If the plugin has no foreign keys, it returns an empty string.

func HasForeignKeys

func HasForeignKeys(plugin *yaml.Node) bool

HasForeignKeys returns true if the given Plugin node has foreign keys (eg. service, route, consumer, consumer_group). These plugins cannot be nested.

Types

type AddPluginPatch

type AddPluginPatch struct {
	Selectors []string                 // JSONpath selectors
	Plugins   []map[string]interface{} // plugin objects to add
	Overwrite bool                     // overwrite existing plugins
}

AddPluginPatch represents a single-patch that adds plugins to a set of objects.

func (*AddPluginPatch) Apply

func (patch *AddPluginPatch) Apply(yamlData *yaml.Node) error

Apply applies the patch to the yaml.Node given.

func (*AddPluginPatch) Parse

func (patch *AddPluginPatch) Parse(patchData map[string]interface{}, source string) error

Parse parses a patch. It will return an error if the patch is invalid. 'source' will be used to format the error in case of an error.

type DeckPluginFile

type DeckPluginFile struct {
	VersionMajor int // 0 if not present
	VersionMinor int // 0 if not present
	Plugins      []AddPluginPatch
}

DeckPluginFile represents a list of Add-Plugin patches.

func (*DeckPluginFile) Apply

func (pluginFile *DeckPluginFile) Apply(yamlData *yaml.Node) error

Apply applies the set of patches on the yaml.Node given.

func (*DeckPluginFile) ParseFile

func (pluginFile *DeckPluginFile) ParseFile(filename string) error

ParseFile parses a pluginfile. Any non-object in the 'patches' array will be ignored. If the array doesn't exist, it returns an empty array.

type Plugger

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

Plugger is the main struct for managing plugins.

func (*Plugger) AddPlugin

func (ts *Plugger) AddPlugin(plugin map[string]interface{}, overwrite bool) error

AddPlugin adds the given plugin config to any entity selected, unless the entity already has a plugin with the same name, in which case it is skipped. If 'overwrite' is true, then the existing plugin is overwritten.

func (*Plugger) AddPlugins

func (ts *Plugger) AddPlugins(plugins []map[string]interface{}, overwrite bool) error

AddPlugins adds the given plugin configs to any entity selected, unless the entity already has a plugin with the same name, in which case it is skipped. If 'overwrite' is true, then the existing plugin is overwritten. If foreign keys are specified, then they are only aloowed in the main plugin array, and they will be compared by plugin name AND their scopes.

func (*Plugger) GetData

func (ts *Plugger) GetData() map[string]interface{}

GetData returns the (modified) document.

func (*Plugger) GetYamlData

func (ts *Plugger) GetYamlData() *yaml.Node

GetYamlData returns the (modified) document.

func (*Plugger) SetData

func (ts *Plugger) SetData(data map[string]interface{})

SetData sets the Yaml document to operate on. Cannot be set to nil (panic).

func (*Plugger) SetSelectors

func (ts *Plugger) SetSelectors(selectors []string) error

SetSelectors sets the selectors to use. If empty (or nil), the default selectors are set.

func (*Plugger) SetYamlData

func (ts *Plugger) SetYamlData(data *yaml.Node)

SetYamlData sets the Yaml document to operate on. Cannot be set to nil (panic).

Jump to

Keyboard shortcuts

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