# Contributing to Kong :monkey_face: Hello, and welcome! Whether you are looking for help, trying to report a bug, thinking about getting involved in the project, or about to submit a patch, this document is for you! It intends to be both an entry point for newcomers to the community (with various technical backgrounds), and a guide/reference for contributors and maintainers. Please have a look at our [Community Pledge](./COMMUNITY_PLEDGE.md) to understand how we work with our open-source contributors! Consult the Table of Contents below, and jump to the desired section. # Table of Contents * [Contributing to Kong :monkey_face:](#contributing-to-kong-monkey_face) * [Where to seek for help?](#where-to-seek-for-help) * [Enterprise Edition](#enterprise-edition) * [Community Edition](#community-edition) * [Where to report bugs?](#where-to-report-bugs) * [Where to submit feature requests?](#where-to-submit-feature-requests) * [Contributing](#contributing) * [Improving the documentation](#improving-the-documentation) * [Proposing a new plugin](#proposing-a-new-plugin) * [Submitting a patch](#submitting-a-patch) * [Git branches](#git-branches) * [Commit atomicity](#commit-atomicity) * [Commit message format](#commit-message-format) * [Type](#type) * [Scope](#scope) * [Subject](#subject) * [Body](#body) * [Footer](#footer) * [Examples](#examples) * [Static linting](#static-linting) * [Writing tests](#writing-tests) * [Writing changelog](#writing-changelog) * [Writing performant code](#writing-performant-code) * [Adding Changelog](#adding-changelog) * [Contributor Badge](#contributor-badge) * [Code style](#code-style) * [Table of Contents - Code style](#table-of-contents---code-style) * [Modules](#modules) * [Variables](#variables) * [Tables](#tables) * [Strings](#strings) * [Functions](#functions) * [Conditional expressions](#conditional-expressions) ## Where to seek for help? ### Enterprise Edition If you are a Kong Enterprise customer, you may contact the Enterprise Support channels by opening an Enterprise support ticket on [https://support.konghq.com](https://support.konghq.com/). If you are experiencing a P1 issue, please call the [24/7 Enterprise Support phone line](https://support.konghq.com/hc/en-us/articles/115004921808-Telephone-Support) for immediate assistance, as published in the Customer Success Reference Guide. If you are interested in becoming a Kong Enterprise customer, please visit https://konghq.com/kong-enterprise-edition/ or contact us at [sales@konghq.com](mailto:sales@konghq.com). [Back to TOC](#table-of-contents) ### Community Edition For questions about the use of the Community Edition, please use [GitHub Discussions](https://github.com/Kong/kong/discussions). You can also join our [Community Slack](http://kongcommunity.slack.com/) for real-time conversations around Kong Gateway. **Please avoid opening GitHub issues for general questions or help**, as those should be reserved for actual bug reports. The Kong community is welcoming and more than willing to assist you on those channels! Our public forum, [Kong Nation](https://discuss.konghq.com) is great for asking questions, giving advice, and staying up-to-date with the latest announcements. [Back to TOC](#table-of-contents) ## Where to report bugs? Feel free to [submit an issue](https://github.com/Kong/kong/issues/new/choose) on the GitHub repository, we would be grateful to hear about it! Please make sure that you respect the GitHub issue template, and include: 1. A summary of the issue 2. A list of steps to help reproduce the issue 3. The version of Kong that you encountered the issue with 4. Your Kong configuration, or the parts that are relevant to your issue If you wish, you are more than welcome to propose a patch to fix the issue! See the [Submit a patch](#submitting-a-patch) section for more information on how to best do so. [Back to TOC](#table-of-contents) ## Where to submit feature requests? You can [submit an issue](https://github.com/Kong/kong/issues/new/choose) for feature requests. Please make sure to add as much detail as you can when doing so. You are also welcome to propose patches adding new features. See the section on [Submitting a patch](#submitting-a-patch) for details. [Back to TOC](#table-of-contents) ## Contributing In addition to code enhancements and bug fixes, you can contribute by - Reporting a bug (see the [report bugs](#where-to-report-bugs) section) - Helping other members of the community on the support channels - Fixing a typo in the code - Fixing a typo in the documentation at https://docs.konghq.com (see the [documentation contribution](#improving-the-documentation) section) - Providing your feedback on the proposed features and designs - Reviewing Pull Requests If you wish to contribute code (features or bug fixes), see the [Submitting a patch](#submitting-a-patch) section. [Back to TOC](#table-of-contents) ### Improving the documentation The documentation hosted at https://docs.konghq.com is open source and built with [Jekyll](https://jekyllrb.com/). You are very welcome to propose changes to it (correct typos, add examples or clarifications...) and contribute to the [Kong Hub](https://docs.konghq.com/hub/)! The repository is also hosted on GitHub at: https://github.com/Kong/docs.konghq.com/ [Back to TOC](#table-of-contents) ### Proposing a new plugin We **do not** generally accept new plugins into this repository. The plugins that are currently part of it form the foundational set of plugins which is available to all installations of Kong Gateway. Specialized functionality should be implemented in plugins residing in separate repository. If you are interested in writing a new plugin for your own needs, you should begin by reading the [Plugin Development Guide](https://docs.konghq.com/latest/plugin-development). If you already wrote a plugin, and are thinking about making it available to the community, we strongly encourage you to host it on a publicly available repository (like GitHub), and distribute it via [LuaRocks](https://luarocks.org/search?q=kong). A good resource on how to do so is the [Distribution Section](https://docs.konghq.com/latest/plugin-development/distribution/#distributing-your-plugin) of the Plugin Development Guide. To give visibility to your plugin, we advise that you: 1. Add your plugin to the [Kong Hub](https://docs.konghq.com/hub/) 2. Create a post in the [Announcements category of Kong Nation](https://discuss.konghq.com/c/announcements) [Back to TOC](#table-of-contents) ### Submitting a patch Feel free to contribute fixes or minor features by opening a Pull Request. Small contributions are more likely to be merged quicker than changes which require a lot of time to review. If you are planning to develop a larger feature, please talk to us first in the [GitHub Discussions](https://github.com/Kong/kong/discussions) section! When contributing, please follow the guidelines provided in this document. They will cover topics such as the different Git branches we use, the commit message format to use, or the appropriate code style. Once you have read them, and you feel that you are ready to submit your Pull Request, be sure to verify a few things: - Your commit history is clean: changes are atomic and the git message format was respected - Rebase your work on top of the base branch (seek help online on how to use `git rebase`; this is important to ensure your commit history is clean and linear) - The static linting is succeeding: run `make lint`, or `luacheck .` (see the development documentation for additional details) - The tests are passing: run `make test`, `make test-all`, or whichever is appropriate for your change - Do not update `CHANGELOG.md` inside your Pull Request. This file is automatically regenerated and maintained during the release process. If the above guidelines are respected, your Pull Request has all its chances to be considered and will be reviewed by a maintainer. If you are asked to update your patch by a reviewer, please do so! Remember: **You are responsible for pushing your patch forward**. If you contributed it, you are probably the one in need of it. You must be ready to apply changes to it if necessary. If your Pull Request was accepted and fixes a bug, adds functionality, or makes it significantly easier to use or understand Kong, congratulations! You are now an official contributor to Kong. Get in touch with us to receive your very own [Contributor Badge](#contributor-badge)! Your change will be included in the subsequent release and its changelog, and we will not forget to include your name if you are an external contributor. :wink: [Back to TOC](#table-of-contents) #### Git branches If you have write access to the GitHub repository, please follow the following naming scheme when pushing your branch(es): - `feat/foo-bar` for new features - `fix/foo-bar` for bug fixes - `tests/foo-bar` when the change concerns only the test suite - `refactor/foo-bar` when refactoring code without any behavior change - `style/foo-bar` when addressing some style issue - `docs/foo-bar` for updates to the README.md, this file, or similar documents - `chore/foo-bar` when the change does not concern the functional source - `perf/foo-bar` for performance improvements [Back to TOC](#table-of-contents) #### Commit atomicity When submitting patches, it is important that you organize your commits in logical units of work. You are free to propose a patch with one or many commits, as long as their atomicity is respected. This means that no unrelated changes should be included in a commit. For example: you are writing a patch to fix a bug, but in your endeavour, you spot another bug. **Do not fix both bugs in the same commit!** Finish your work on the initial bug, propose your patch, and come back to the second bug later on. This is also valid for unrelated style fixes, refactors, etc... You should use your best judgment when facing such decisions. A good approach for this is to put yourself in the shoes of the person who will review your patch: will they understand your changes and reasoning just by reading your commit history? Will they find unrelated changes in a particular commit? They shouldn't! Writing meaningful commit messages that follow our commit message format will also help you respect this mantra (see the below section). [Back to TOC](#table-of-contents) #### Commit message format To maintain a healthy Git history, we ask of you that you write your commit messages as follows: - The tense of your message must be **present** - Your message must be prefixed by a type, and a scope - The header of your message should not be longer than 50 characters - A blank line should be included between the header and the body - The body of your message should not contain lines longer than 72 characters We strive to adapt the [conventional-commits](https://www.conventionalcommits.org/en/v1.0.0/) format. Here is a template of what your commit message should look like: ``` ():