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 ¶
- func ForeignKey(plugin *yaml.Node) string
- func HasForeignKeys(plugin *yaml.Node) bool
- type AddPluginPatch
- type DeckPluginFile
- type Plugger
- func (ts *Plugger) AddPlugin(plugin map[string]interface{}, overwrite bool) error
- func (ts *Plugger) AddPlugins(plugins []map[string]interface{}, overwrite bool) error
- func (ts *Plugger) GetData() map[string]interface{}
- func (ts *Plugger) GetYamlData() *yaml.Node
- func (ts *Plugger) SetData(data map[string]interface{})
- func (ts *Plugger) SetSelectors(selectors []string) error
- func (ts *Plugger) SetYamlData(data *yaml.Node)
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.
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 ¶
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 ¶
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) GetYamlData ¶
func (ts *Plugger) GetYamlData() *yaml.Node
GetYamlData returns the (modified) document.
func (*Plugger) SetData ¶
SetData sets the Yaml document to operate on. Cannot be set to nil (panic).
func (*Plugger) SetSelectors ¶
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).