Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pdk) introduce the Plugin Development Kit #3556

Merged
merged 20 commits into from
Jun 19, 2018
Merged

feat(pdk) introduce the Plugin Development Kit #3556

merged 20 commits into from
Jun 19, 2018

Conversation

thibaultcha
Copy link
Member

@thibaultcha thibaultcha commented Jun 18, 2018

The Plugin Development Kit (or "PDK") is a set of functions (SDK) and variables that will ease the task of writing Kong plugins. The first version of the PDK mainly consists of several "stateless" modules to retrieve and manipulate the request and response. A few other minor utilities such as logging or context storing.

The documentation is included in the source, and will be published on the documentation website shortly.

Overview

Name Type Description
kong.version string Human-readable current Kong version (e.g. "0.13.0")
kong.version_num number Parsable current Kong version (e.g. 0130)
kong.pdk_major_version number The current PDK's major version number
kong.pdk_version string Human-readable current PDK version (semver, so ..)
1st class utilities
kong.configuration table Current node configuration
kong.dao instance Instance of Kong's legacy DAO
kong.db instance Instance of Kong's DAO
kong.dns instance Instance of Kong's DNS resolver
kong.ipc instance Instance of Kong's worker_events module
kong.cache instance Instance of Kong's DB cache
Minor utilities
kong.table table Utilities for Lua tables
kong.log table Instance of Kong logging factory with various utilities
Request/Response
kong.ctx table Current request context data
kong.client table Client information module
kong.request table Client request module
kong.service table properties of the connection to the Service
kong.service.request table manipulation of the request to the Service
kong.service.response table manipulation of the response from the Service
kong.response table Client response module

@thibaultcha thibaultcha changed the title feat(sdk) introduce Plugin Development Kit feat(sdk) introduce the Plugin Development Kit Jun 18, 2018
@thibaultcha thibaultcha changed the title feat(sdk) introduce the Plugin Development Kit feat(pdk) introduce the Plugin Development Kit Jun 18, 2018
@thibaultcha thibaultcha force-pushed the feat/pdk branch 5 times, most recently from 64f97cf to 1b0a9c8 Compare June 19, 2018 04:09
@thibaultcha
Copy link
Member Author

Green builds on internal build environment 👍 Bypassing Travis-ci.org

thibaultcha and others added 20 commits June 18, 2018 21:50
* Introduce the `kong.pdk` module, a skeleton/loader for the PDK
* Introduce Test::Nginx utils
* Introduce Test::Nginx certificates
This kit is based on the existing `kong/tools/ip.lua` module.
The goal of this module is to expose a private interface to the core, in
order to manipulate the `kong` global, which is comprised of the PDK
(Plugin Development Kit), and various other legacy singletons (DAO,
cache, DNS resolver, etc...)
This fix visibility issues of `kong` global variable.
@thibaultcha thibaultcha deleted the feat/pdk branch June 19, 2018 04:52
function _IP.is_trusted() return false end

elseif trust_all_ipv4 and trust_all_ipv6 then
function _IP.is_trusted() return true end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code is hard to read, and not in line with the rest of the codebase (see else clause below), can we update this to:

_IP.is_trusted = function() return true end

Copy link
Member

@bungle bungle Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, though changing that single line to another presentation of the same thing is more or less just syntax juggling. This is just copy-pasted from here:
https://github.com/Kong/kong/blob/master/kong/tools/ip.lua

(but I agree for consistency, one syntax should be used)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, though changing that single line to another presentation of the same thing is more or less just syntax juggling.

👍, not worth it imho.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course it is syntax juggling, since it is style related. The original file didn't have this style issue though. Will send a pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants