├── .gitignore ├── .editorconfig ├── template ├── plugin │ ├── schema.lua │ ├── handler.lua │ ├── api.lua │ └── daos.lua └── priority.lua ├── .luacheckrc ├── create.sh ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | *.rock 2 | .DS_Store 3 | servroot 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | 9 | [*.lua] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [kong/templates/nginx*] 14 | indent_style = space 15 | indent_size = 4 16 | 17 | [*.template] 18 | indent_style = space 19 | indent_size = 4 20 | 21 | [Makefile] 22 | indent_style = tab 23 | -------------------------------------------------------------------------------- /template/plugin/schema.lua: -------------------------------------------------------------------------------- 1 | -- This is generated code, DO NOT UPDATE! 2 | -- If you have a fix, head over to https://github.com/Kong/priority-updater and 3 | -- send a PR on the original template files 4 | 5 | -- capture original plugin name, and new priority from filename 6 | local plugin_name, priority = ({...})[1]:match("^kong%.plugins%.([^%.]-)_(%d+)%.schema$") 7 | if not plugin_name or not priority then 8 | error("Plugin file must be named '..../kong/plugins/_/schema.lua', got: " .. tostring(({...})[1])) 9 | end 10 | 11 | return require("kong.plugins." .. plugin_name .. ".schema") 12 | -------------------------------------------------------------------------------- /.luacheckrc: -------------------------------------------------------------------------------- 1 | -- Configuration file for LuaCheck 2 | -- see: https://luacheck.readthedocs.io/en/stable/ 3 | -- 4 | -- To run do: `luacheck .` from the repo 5 | 6 | std = "ngx_lua" 7 | unused_args = false 8 | redefined = false 9 | max_line_length = false 10 | 11 | 12 | globals = { 13 | "_KONG", 14 | "kong", 15 | "ngx.IS_CLI", 16 | } 17 | 18 | 19 | not_globals = { 20 | "string.len", 21 | "table.getn", 22 | } 23 | 24 | 25 | ignore = { 26 | "6.", -- ignore whitespace warnings 27 | } 28 | 29 | 30 | include_files = { 31 | "**/*.lua", 32 | "*.rockspec", 33 | ".busted", 34 | ".luacheckrc", 35 | } 36 | 37 | exclude_files = { 38 | --"spec/fixtures/invalid-module.lua", 39 | --"spec-old-api/fixtures/invalid-module.lua", 40 | } 41 | 42 | 43 | files["spec/**/*.lua"] = { 44 | std = "ngx_lua+busted", 45 | } 46 | -------------------------------------------------------------------------------- /template/plugin/handler.lua: -------------------------------------------------------------------------------- 1 | -- This is generated code, DO NOT UPDATE! 2 | -- If you have a fix, head over to https://github.com/Kong/priority-updater and 3 | -- send a PR on the original template files 4 | 5 | -- capture original plugin name, and new priority from filename 6 | local plugin_name, priority = ({...})[1]:match("^kong%.plugins%.([^%.]-)_(%d+)%.handler$") 7 | if not plugin_name or not priority then 8 | error("Plugin file must be named '..../kong/plugins/_/handler.lua', got: " .. tostring(({...})[1])) 9 | end 10 | 11 | local original_handler = require("kong.plugins." .. plugin_name .. ".handler") 12 | 13 | -- create new plugin. 14 | -- we copy contents and metatable. So only plugins which would store something 15 | -- in 'self' might not work properly, but these we do not have, so should be fine 16 | local new_plugin = {} 17 | for k,v in pairs(original_handler) do 18 | new_plugin[k] = v 19 | end 20 | setmetatable(new_plugin, getmetatable(original_handler)) 21 | 22 | -- set the new priority 23 | new_plugin.PRIORITY = tonumber(priority) 24 | new_plugin.VERSION = "0.4" 25 | 26 | return new_plugin 27 | -------------------------------------------------------------------------------- /template/plugin/api.lua: -------------------------------------------------------------------------------- 1 | -- This is generated code, DO NOT UPDATE! 2 | -- If you have a fix, head over to https://github.com/Kong/priority-updater and 3 | -- send a PR on the original template files 4 | 5 | -- capture original plugin name, and new priority from filename 6 | local this_module_name = ({...})[1] 7 | local plugin_name, priority = this_module_name:match("^kong%.plugins%.([^%.]-)_(%d+)%.api$") 8 | if not plugin_name or not priority then 9 | error("Plugin file must be named '..../kong/plugins/_/api.lua', got: " .. tostring(({...})[1])) 10 | end 11 | 12 | local module_name = "kong.plugins." .. plugin_name .. ".api" 13 | 14 | 15 | 16 | -- Error out indicating to the loader this module was not found 17 | local function this_module_wasnt_found() 18 | -- clear LuaJIT temp userdata. If we leave the userdata, then a next call to 19 | -- `require` will return that userdata, and cause subsequent failures 20 | -- see https://www.freelists.org/post/luajit/require-not-clearing-userdata-value 21 | package.loaded[this_module_name] = nil 22 | -- error must match exactly, since the loader validates it 23 | return error("module '" .. this_module_name .. "' not found") 24 | end 25 | 26 | 27 | 28 | if package.loaded[module_name] then 29 | -- the api file should be loaded only once, so error out 30 | this_module_wasnt_found() 31 | end 32 | 33 | -- if this fails the error indicates the original plugin didn't have the file 34 | local success, api = pcall(require, module_name) 35 | if not success then 36 | this_module_wasnt_found() 37 | end 38 | 39 | -- what if the original plugin is loaded after this one? 40 | package.loaded[module_name] = {} -- make it empty! no new endpoints will be added, by anyone after us 41 | 42 | return api 43 | -------------------------------------------------------------------------------- /template/plugin/daos.lua: -------------------------------------------------------------------------------- 1 | -- This is generated code, DO NOT UPDATE! 2 | -- If you have a fix, head over to https://github.com/Kong/priority-updater and 3 | -- send a PR on the original template files 4 | 5 | -- capture original plugin name, and new priority from filename 6 | local this_module_name = ({...})[1] 7 | local plugin_name, priority = this_module_name:match("^kong%.plugins%.([^%.]-)_(%d+)%.daos$") 8 | if not plugin_name or not priority then 9 | error("Plugin file must be named '..../kong/plugins/_/daos.lua', got: " .. tostring(({...})[1])) 10 | end 11 | 12 | local module_name = "kong.plugins." .. plugin_name .. ".daos" 13 | 14 | 15 | 16 | -- Error out indicating to the loader this module was not found 17 | local function this_module_wasnt_found() 18 | -- clear LuaJIT temp userdata. If we leave the userdata, then a next call to 19 | -- `require` will return that userdata, and cause subsequent failures 20 | -- see https://www.freelists.org/post/luajit/require-not-clearing-userdata-value 21 | package.loaded[this_module_name] = nil 22 | -- error must match exactly, since the loader validates it 23 | return error("module '" .. this_module_name .. "' not found") 24 | end 25 | 26 | 27 | 28 | if package.loaded[module_name] then 29 | -- the api file should be loaded only once, so error out 30 | this_module_wasnt_found() 31 | end 32 | 33 | -- if this fails the error indicates the original plugin didn't have the file 34 | local success, daos = pcall(require, module_name) 35 | if not success then 36 | this_module_wasnt_found() 37 | end 38 | 39 | -- what if the original plugin is loaded after this one? 40 | package.loaded[module_name] = {} -- make it empty! no new daos will be added, by anyone after us 41 | 42 | return daos 43 | -------------------------------------------------------------------------------- /create.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ "$1" == "--help" ]; then 4 | echo "Utility to create Kong plugins with alternative priority." 5 | echo 6 | echo "It will create a NEW plugin identical to the original one," 7 | echo "but with the new priority." 8 | echo 9 | echo "Usage:" 10 | echo " ${BASH_SOURCE[0]} \"PLUGIN_NAME\" \"NEW_PRIORITY\"" 11 | echo 12 | echo " PLUGIN_NAME : name of existing plugin to re-prioritize" 13 | echo " NEW_PRIORITY : the priority the new plugin should have" 14 | echo 15 | echo "The new plugin will have the old name with priority attached." 16 | echo "This new name is mandatory and cannot be changed." 17 | echo 18 | echo "Example:" 19 | echo " ${BASH_SOURCE[0]} \"request-termination\" \"15\"" 20 | echo 21 | echo "Will create:" 22 | echo " kong-plugin-request-termination_15-0.1-1.rock" 23 | echo 24 | echo "It can be installed using:" 25 | echo " luarocks install kong-plugin-request-termination_15-0.1-1.rock" 26 | echo 27 | 28 | exit 0 29 | fi 30 | 31 | PLUGINNAME="$1" 32 | PRIORITY="$2" 33 | 34 | if [ "$PLUGINNAME" == "" ]; then 35 | echo "Missing plugin name, rerun with '--help' for info." 36 | 37 | exit 1 38 | fi 39 | 40 | if [ "$PRIORITY" == "" ]; then 41 | echo "Missing plugin priority, rerun with '--help' for info." 42 | exit 1 43 | fi 44 | 45 | docker -v > /dev/null 2>&1 46 | if [ $? -ne 0 ]; then 47 | echo "Utility 'docker' was not found, please make sure it is installed" 48 | echo "and available in the system path." 49 | echo 50 | exit 1 51 | fi 52 | 53 | rm ./template/plugin/*.rock > /dev/null 2>&1 54 | rm ./template/plugin/*.rockspec > /dev/null 2>&1 55 | 56 | docker run \ 57 | --rm \ 58 | --user root \ 59 | --volume "$PWD/template:/template" \ 60 | --workdir="/template/plugin" \ 61 | -e KONG_PRIORITY_NAME="$PLUGINNAME" \ 62 | -e KONG_PRIORITY="$PRIORITY" \ 63 | kong:3.2.2 \ 64 | /usr/local/openresty/luajit/bin/luajit ../priority.lua 65 | 66 | mv ./template/plugin/*.rock ./ > /dev/null 2>&1 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # priority-updater 2 | 3 | Tool to quickly create a plugin with an updated priority. 4 | 5 | # Status 6 | 7 | > early development 8 | 9 | # Description 10 | 11 | Kong plugin priorities are static, in source. Occasionally there is a use-case 12 | for a different priority setting, in which case the user is advised to create a 13 | copy of the original plugin and modify the source. 14 | 15 | This utility makes this process a lot easier. It creates a wrapper plugin that 16 | takes the original plugin and adjusts the priority. 17 | 18 | There are two main uses: 19 | 20 | 1. Executing plugins in a different order 21 | 2. Running the same plugin functionality twice or more (create indentical 22 | plugins with slightly different priorities) 23 | 24 | # WARNING! 25 | 26 | _Do NOT upload the generated plugins to LuaRocks since that would pollute 27 | the LuaRocks repository with loads of useless/duplicate plugins._ 28 | 29 | # Usage 30 | 31 | 1. Create a wrapper for the 'request-transformer' with priority '999': 32 | ```shell 33 | ./create.sh "request-transformer" 999 34 | ``` 35 | New rock is generated: `kong-plugin-request-transformer_999-0.1-1.all.rock`. 36 | The new plugin name is `request-transformer_999` (the old name with the 37 | appended new priority) 38 | 39 | 2. Copy the resulting `.rock` file to the target system. Or use the 40 | [docker tools](https://github.com/Kong/docker-kong/tree/master/customize) 41 | to inject it into a Kong docker image. 42 | 43 | 3. Install the plugin on your Kong system using LuaRocks 44 | 45 | ```shell 46 | luarocks install kong-plugin-request-transformer_999-0.1-1.all.rock 47 | ``` 48 | 49 | 4. Use your new plugin with Kong (use the NEW name with priority!) 50 | 51 | 52 | ```shell 53 | curl -X POST http://kong:8001/plugins \ 54 | --data "name=request-transformer_999" \ 55 | --data "config.remove.headers=x-toremove, x-another-one" 56 | ``` 57 | 58 | # Requirements/Prerequisites 59 | 60 | The utility is a `bash` script that uses a `docker` build container. Hence only 61 | those are required to run it. 62 | 63 | # Implementation details 64 | 65 | - The plugin does not contain any functional code, but shares everything with 66 | the original: 67 | - if the original code gets updated, the wrapper will use the updated code. 68 | - the new plugin shares the same management API endpoints and data (DAO's). 69 | - There is no performance penalty for using the wrapper. 70 | - One caveat: If a plugin uses its own table to store state (eg. updates 71 | values in `self`), then that is the only part that is NOT shared. Afaik there 72 | are currently no such plugins. 73 | 74 | # History/Changelog 75 | 76 | Note: the version is the version of the generated wrapper code, and independent 77 | of the original code. If the Lua code of the wrapper changes, then also change 78 | the version at: 79 | - the generated wrapper in `priority.lua`, the `WRAPPER_VERSION` constant 80 | - the VERSION in `handler.lua` 81 | 82 | ### 0.4 14-Apr-2020 83 | - Fix: workaround for a [LuaJIT bug](https://www.freelists.org/post/luajit/require-not-clearing-userdata-value). 84 | 85 | ### 0.3 14-Dec-2020 86 | - Fix: fix in version 0.2 was incomplete, the new error could be the existing 87 | plugins name, instead of the new name. 88 | 89 | ### 0.2 04-Dec-2020 90 | - Fix: plugins with `daos.lua` or `api.lua` would fail on more recent versions 91 | of Kong because it checks the exact error message. 92 | 93 | ### 0.1 12-Jun-2019 94 | - Initial version 95 | -------------------------------------------------------------------------------- /template/priority.lua: -------------------------------------------------------------------------------- 1 | local exec = require("pl.utils").execute 2 | local writefile = require("pl.utils").writefile 3 | 4 | local WRAPPER_VERSION = "0.4" -- version of the wrapper code, will reflect in the rockspec 5 | 6 | io.stdout:setvbuf("no") 7 | io.stderr:setvbuf("no") 8 | 9 | 10 | local function stderr(...) 11 | io.stderr:write(...) 12 | io.stderr:write("\n") 13 | end 14 | 15 | 16 | local function stdout(...) 17 | io.stdout:write(...) 18 | io.stdout:write("\n") 19 | end 20 | 21 | 22 | local function fail(msg) 23 | stderr(msg) 24 | os.exit(1) 25 | end 26 | 27 | 28 | local function header(msg) 29 | local fill1 = math.floor((80 - 2 - #msg)/2) 30 | local fill2 = 80 - 2 - #msg - fill1 31 | stdout( 32 | ("*"):rep(80).."\n".. 33 | "*"..(" "):rep(fill1)..msg..(" "):rep(fill2).."*\n".. 34 | ("*"):rep(80) 35 | ) 36 | end 37 | 38 | 39 | local platforms = { 40 | { 41 | check = "apt -v", -- check for ubuntu 42 | commands = { -- run before anything else in build container 43 | "apt update", 44 | "apt install -y zip", 45 | }, 46 | }, { 47 | check = "apk -V", -- check for alpine 48 | commands = { -- run before anything else in build container 49 | "apk update", 50 | "apk add zip", 51 | }, 52 | }, { 53 | check = "yum --version", -- check for CentOS 54 | commands = { -- run before anything else in build container 55 | "yum -y install zip", 56 | }, 57 | }, 58 | } 59 | 60 | 61 | local function prep_platform() 62 | for _, platform in ipairs(platforms) do 63 | local ok = exec(platform.check) 64 | if not ok then 65 | stdout(("platform test '%s' was negative"):format(platform.check)) 66 | else 67 | stdout(("platform test '%s' was positive"):format(platform.check)) 68 | for _, cmd in ipairs(platform.commands) do 69 | stdout(cmd) 70 | local ok = exec(cmd) 71 | if not ok then 72 | fail(("failed executing '%s'"):format(cmd)) 73 | end 74 | end 75 | return true 76 | end 77 | end 78 | stderr("WARNING: no platform match!") 79 | end 80 | 81 | 82 | 83 | 84 | 85 | -- ********************************************************** 86 | -- Do the actual work 87 | -- ********************************************************** 88 | header("Set up platform") 89 | assert(prep_platform()) 90 | 91 | local plugin = os.getenv("KONG_PRIORITY_NAME") 92 | local priority = os.getenv("KONG_PRIORITY") 93 | local plugin_name = tostring(plugin) .. "_" .. tostring(priority) 94 | local rockspec = "kong-plugin-" .. plugin_name .. "-" .. WRAPPER_VERSION .. "-1.rockspec" 95 | 96 | header("Building: "..plugin_name) 97 | assert(writefile(rockspec,[[ 98 | local pluginName = "]] .. plugin_name .. [[" 99 | 100 | package = "kong-plugin-" .. pluginName 101 | version = "]] .. WRAPPER_VERSION .. [[-1" 102 | 103 | supported_platforms = {"linux", "macosx"} 104 | source = { 105 | url = "http://github.com/not/really/used.git", 106 | tag = "0.1" 107 | } 108 | 109 | description = { 110 | summary = "Kong is a scalable and customizable API Management platform", 111 | homepage = "http://konghq.com", 112 | } 113 | 114 | build = { 115 | type = "builtin", 116 | modules = { 117 | ["kong.plugins."..pluginName..".handler"] = "./handler.lua", 118 | ["kong.plugins."..pluginName..".schema"] = "./schema.lua", 119 | ["kong.plugins."..pluginName..".daos"] = "./daos.lua", 120 | ["kong.plugins."..pluginName..".api"] = "./api.lua", 121 | } 122 | } 123 | ]])) 124 | 125 | assert(exec("luarocks make")) 126 | 127 | header("Packing: "..plugin_name) 128 | assert(exec("luarocks pack kong-plugin-" .. plugin_name)) 129 | os.remove(rockspec) 130 | 131 | header("Done creating: " .. "kong-plugin-" .. plugin_name .. "-" .. WRAPPER_VERSION .. "-1.all.rock") 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------