├── .gitattributes ├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ ├── CI.yml │ ├── add-untriaged.yml │ └── backport.yml ├── .gitignore ├── .whitesource ├── CONTRIBUTING.md ├── LICENSE.txt ├── MAINTAINERS.md ├── NOTICE.txt ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src ├── main └── java │ └── org │ └── example │ └── path │ └── to │ └── plugin │ └── RenamePlugin.java ├── test └── java │ └── org │ └── example │ └── path │ └── to │ └── plugin │ ├── RenamePluginIT.java │ └── RenameTests.java └── yamlRestTest ├── java └── org │ └── example │ └── path │ └── to │ └── plugin │ └── RenameClientYamlTestSuiteIT.java └── resources └── rest-api-spec └── test └── 10_basic.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.bat text eol=crlf 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @AmiStrn @dblock @saratvemulapalli @reta 2 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | labels: 8 | - "dependabot" 9 | - "dependencies" 10 | - package-ecosystem: "gradle" 11 | directory: "/" 12 | schedule: 13 | interval: "weekly" 14 | labels: 15 | - "dependabot" 16 | - "dependencies" 17 | -------------------------------------------------------------------------------- /.github/workflows/CI.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test Plugin Template 2 | 3 | on: 4 | push: 5 | branches: 6 | - "*" 7 | pull_request: 8 | branches: 9 | - "*" 10 | 11 | jobs: 12 | build: 13 | strategy: 14 | matrix: 15 | os: 16 | - ubuntu-latest 17 | - macOS-latest 18 | - windows-latest 19 | java: 20 | - 21 21 | - 23 22 | name: Build and Test Plugin Template 23 | runs-on: ${{ matrix.os }} 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | - name: Set up JDK ${{ matrix.java }} 28 | uses: actions/setup-java@v4 29 | with: 30 | java-version: ${{ matrix.java }} 31 | distribution: temurin 32 | - name: Build and Run Tests 33 | run: | 34 | ./gradlew build 35 | - name: Publish plugin ZIP to staging repository 36 | run: | 37 | ./gradlew publishPluginZipPublicationToZipStagingRepository 38 | -------------------------------------------------------------------------------- /.github/workflows/add-untriaged.yml: -------------------------------------------------------------------------------- 1 | name: Apply 'untriaged' label during issue lifecycle 2 | 3 | on: 4 | issues: 5 | types: [opened, reopened, transferred] 6 | 7 | jobs: 8 | apply-label: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/github-script@v7 12 | with: 13 | script: | 14 | github.rest.issues.addLabels({ 15 | issue_number: context.issue.number, 16 | owner: context.repo.owner, 17 | repo: context.repo.repo, 18 | labels: ['untriaged'] 19 | }) 20 | -------------------------------------------------------------------------------- /.github/workflows/backport.yml: -------------------------------------------------------------------------------- 1 | name: Backport 2 | on: 3 | pull_request_target: 4 | types: 5 | - closed 6 | - labeled 7 | 8 | jobs: 9 | backport: 10 | if: ${{ contains(github.event.label.name, 'backport') }} 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: write 14 | pull-requests: write 15 | name: Backport 16 | steps: 17 | - name: GitHub App token 18 | id: github_app_token 19 | uses: tibdex/github-app-token@v2.1.0 20 | with: 21 | app_id: ${{ secrets.APP_ID }} 22 | private_key: ${{ secrets.APP_PRIVATE_KEY }} 23 | installation_id: 22958780 24 | 25 | - name: Backport 26 | uses: VachaShah/backport@v2.2.0 27 | with: 28 | github_token: ${{ steps.github_app_token.outputs.token }} 29 | head_template: backport/backport-<%= number %>-to-<%= base %> -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # intellij files 3 | .idea/ 4 | *.iml 5 | *.ipr 6 | *.iws 7 | build-idea/ 8 | out/ 9 | 10 | # include shared intellij config 11 | !.idea/inspectionProfiles/Project_Default.xml 12 | !.idea/runConfigurations/Debug_OpenSearch.xml 13 | 14 | # These files are generated in the main tree by IntelliJ 15 | benchmarks/src/main/generated/* 16 | 17 | # eclipse files 18 | .project 19 | .classpath 20 | .settings 21 | build-eclipse/ 22 | 23 | # netbeans files 24 | nb-configuration.xml 25 | nbactions.xml 26 | 27 | # gradle stuff 28 | .gradle/ 29 | build/ 30 | bin/ 31 | 32 | # vscode stuff 33 | .vscode/ 34 | 35 | # testing stuff 36 | **/.local* 37 | .vagrant/ 38 | /logs/ 39 | 40 | # osx stuff 41 | .DS_Store 42 | 43 | # default folders in which the create_bwc_index.py expects to find old es versions in 44 | /backwards 45 | /dev-tools/backwards 46 | 47 | # needed in case docs build is run...maybe we can configure doc build to generate files under build? 48 | html_docs 49 | 50 | # random old stuff that we should look at the necessity of... 51 | /tmp/ 52 | eclipse-build 53 | 54 | # projects using testfixtures 55 | testfixtures_shared/ 56 | 57 | # These are generated from .ci/jobs.t 58 | .ci/jobs/ 59 | -------------------------------------------------------------------------------- /.whitesource: -------------------------------------------------------------------------------- 1 | { 2 | "scanSettings": { 3 | "configMode": "AUTO", 4 | "configExternalURL": "", 5 | "projectToken": "", 6 | "baseBranches": [] 7 | }, 8 | "scanSettingsSAST": { 9 | "enableScan": false, 10 | "scanPullRequests": false, 11 | "incrementalScan": true, 12 | "baseBranches": [], 13 | "snippetSize": 10 14 | }, 15 | "checkRunSettings": { 16 | "vulnerableCheckRunConclusionLevel": "failure", 17 | "displayMode": "diff", 18 | "useMendCheckNames": true 19 | }, 20 | "checkRunSettingsSAST": { 21 | "checkRunConclusionLevel": "failure", 22 | "severityThreshold": "high" 23 | }, 24 | "issueSettings": { 25 | "minSeverityLevel": "LOW", 26 | "issueType": "DEPENDENCY" 27 | }, 28 | "issueSettingsSAST": { 29 | "minSeverityLevel": "high", 30 | "issueType": "repo" 31 | }, 32 | "remediateSettings": { 33 | "workflowRules": { 34 | "enabled": true 35 | } 36 | }, 37 | "imageSettings":{ 38 | "imageTracing":{ 39 | "enableImageTracingPR": false, 40 | "addRepositoryCoordinate": false, 41 | "addDockerfilePath": false, 42 | "addMendIdentifier": false 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *main* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | ## Developer Certificate of Origin 43 | 44 | OpenSearch is an open source product released under the Apache 2.0 license (see either [the Apache site](https://www.apache.org/licenses/LICENSE-2.0) or the [LICENSE.txt file](LICENSE.txt)). The Apache 2.0 license allows you to freely use, modify, distribute, and sell your own products that include Apache 2.0 licensed software. 45 | 46 | We respect intellectual property rights of others and we want to make sure all incoming contributions are correctly attributed and licensed. A Developer Certificate of Origin (DCO) is a lightweight mechanism to do that. 47 | 48 | The DCO is a declaration attached to every contribution made by every developer. In the commit message of the contribution, the developer simply adds a `Signed-off-by` statement and thereby agrees to the DCO, which you can find below or at [DeveloperCertificate.org](http://developercertificate.org/). 49 | 50 | ``` 51 | Developer's Certificate of Origin 1.1 52 | 53 | By making a contribution to this project, I certify that: 54 | 55 | (a) The contribution was created in whole or in part by me and I 56 | have the right to submit it under the open source license 57 | indicated in the file; or 58 | 59 | (b) The contribution is based upon previous work that, to the 60 | best of my knowledge, is covered under an appropriate open 61 | source license and I have the right under that license to 62 | submit that work with modifications, whether created in whole 63 | or in part by me, under the same open source license (unless 64 | I am permitted to submit under a different license), as 65 | Indicated in the file; or 66 | 67 | (c) The contribution was provided directly to me by some other 68 | person who certified (a), (b) or (c) and I have not modified 69 | it. 70 | 71 | (d) I understand and agree that this project and the contribution 72 | are public and that a record of the contribution (including 73 | all personal information I submit with it, including my 74 | sign-off) is maintained indefinitely and may be redistributed 75 | consistent with this project or the open source license(s) 76 | involved. 77 | ``` 78 | 79 | We require that every contribution to OpenSearch is signed with a Developer Certificate of Origin. Additionally, please use your real name. We do not accept anonymous contributors nor those utilizing pseudonyms. 80 | 81 | Each commit must include a DCO which looks like this 82 | 83 | ``` 84 | Signed-off-by: Jane Smith 85 | ``` 86 | 87 | You may type this line on your own when writing your commit messages. However, if your user.name and user.email are set in your git configs, you can use `-s` or `– – signoff` to add the `Signed-off-by` line to the end of the commit message. 88 | 89 | ## Finding contributions to work on 90 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 91 | 92 | 93 | ## Code of Conduct 94 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 95 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 96 | opensource-codeofconduct@amazon.com with any additional questions or comments. 97 | 98 | 99 | ## Security issue notifications 100 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 101 | 102 | ## License Headers 103 | 104 | New files in your code contributions should contain the following license header. If you are modifying existing files with license headers, or including new files that already have license headers, do not remove or modify them without guidance. 105 | 106 | ``` 107 | /* 108 | * Copyright OpenSearch Contributors 109 | * SPDX-License-Identifier: Apache-2.0 110 | */ 111 | ``` 112 | 113 | ## Licensing 114 | 115 | See the [LICENSE](LICENSE.txt) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 116 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | This document contains a list of maintainers in this repo. See [opensearch-project/.github/RESPONSIBILITIES.md](https://github.com/opensearch-project/.github/blob/main/RESPONSIBILITIES.md#maintainer-responsibilities) that explains what the role of maintainer means, what maintainers do in this and other repos, and how they should be doing it. If you're interested in contributing, and becoming a maintainer, see [CONTRIBUTING](CONTRIBUTING.md). 4 | 5 | ## Current Maintainers 6 | 7 | | Maintainer | GitHub ID | Affiliation | 8 | | ------------------------ | ------------------------------------------------------- | ----------- | 9 | | Amitai Stern | [AmiStrn](https://github.com/AmiStrn) | Logz.io | 10 | | Daniel "dB." Doubrovkine | [dblock](https://github.com/dblock) | Independent | 11 | | Sarat Vemulapalli | [saratvemulapalli](https://github.com/saratvemulapalli) | Amazon | 12 | | Andriy Redko | [reta](https://github.com/reta) | Independent | 13 | -------------------------------------------------------------------------------- /NOTICE.txt: -------------------------------------------------------------------------------- 1 | OpenSearch (https://opensearch.org/) 2 | Copyright OpenSearch Contributors 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Template for creating OpenSearch Plugins 2 | This Repo is a GitHub Template repository ([Learn more about that](https://docs.github.com/articles/creating-a-repository-from-a-template/)). 3 | Using it would create a new repo that is the boilerplate code required for an [OpenSearch Plugin](https://opensearch.org/blog/technical-posts/2021/06/my-first-steps-in-opensearch-plugins/). 4 | This plugin on its own would not add any functionality to OpenSearch, but it is still ready to be installed. 5 | It comes packaged with: 6 | - Integration tests of two types: Yaml and IntegTest. 7 | - Empty unit tests file 8 | - Notice and License files (Apache License, Version 2.0) 9 | - A `build.gradle` file supporting this template's current state. 10 | 11 | --- 12 | --- 13 | 1. [Create your plugin repo using this template](#create-your-plugin-repo-using-this-template) 14 | - [Official plugins](#official-plugins) 15 | - [Thirdparty plugins](#thirdparty-plugins) 16 | 2. [Fix up the template to match your new plugin requirements](#fix-up-the-template-to-match-your-new-plugin-requirements) 17 | - [Plugin Name](#plugin-name) 18 | - [Plugin Path](#plugin-path) 19 | - [Update the `build.gradle` file](#update-the-buildgradle-file) 20 | - [Update the tests](#update-the-tests) 21 | - [Running the tests](#running-the-tests) 22 | - [Running testClusters with the plugin installed](#running-testclusters-with-the-plugin-installed) 23 | - [Cleanup template code](#cleanup-template-code) 24 | - [Editing the CI workflow](#Editing-the-CI-workflow) 25 | 3. [License](#license) 26 | 4. [Copyright](#copyright) 27 | --- 28 | --- 29 | 30 | ## Create your plugin repo using this template 31 | Click on "Use this Template" 32 | 33 | ![Use this Template](https://docs.github.com/assets/images/help/repository/use-this-template-button.png) 34 | 35 | Name the repository, and provide a description. 36 | 37 | Depending on the plugin relationship with the OpenSearch organization we currently recommend the following naming conventions and optional follow-up checks: 38 | 39 | ### Official plugins 40 | 41 | For the **official plugins** that live within the OpenSearch organization (i.e. they are included in [OpenSearch/plugins/](https://github.com/opensearch-project/OpenSearch/tree/main/plugins) or [OpenSearch/modules/](https://github.com/opensearch-project/OpenSearch/tree/main/modules) folder), and **which share the same release cycle as OpenSearch** itself: 42 | 43 | - Do not include the word `plugin` in the repo name (e.g. [job-scheduler](https://github.com/opensearch-project/job-scheduler)) 44 | - Use lowercase repo names 45 | - Use spinal case for repo names (e.g. [job-scheduler](https://github.com/opensearch-project/job-scheduler)) 46 | - Do not include the word `OpenSearch` or `OpenSearch Dashboards` in the repo name 47 | - Provide a meaningful description, e.g. `An OpenSearch Dashboards plugin to perform real-time and historical anomaly detection on OpenSearch data`. 48 | 49 | ### Thirdparty plugins 50 | 51 | For the **3rd party plugins** that are maintained as independent projects in separate GitHub repositories **with their own release cycles** the recommended naming convention should follow the same rules as official plugins with some exceptions and few follow-up checks: 52 | 53 | - Inclusion of the words like `OpenSearch` or `OpenSearch Dashboard` (and in reasonable cases even `plugin`) are welcome because they can increase the chance of discoverability of the repository 54 | - Check the plugin versioning policy is documented and help users know which versions of the plugin are compatible and recommended for specific versions of OpenSearch 55 | - Review [CONTRIBUTING.md](CONTRIBUTING.md) document which is by default tailored to the needs of Amazon Web Services developer teams. You might want to update or further customize specific parts related to: 56 | - **Code of Conduct** (if you do not already have CoC policy then there are several options to start with, such as [Contributor Covenant](https://www.contributor-covenant.org/)), 57 | - **Security Policy** (you should let users know how they can safely report security vulnerabilities), 58 | - Check if you need explicit part about **Trademarks and Attributions** (if you use any registered or non-registered trademarks we recommend following applicable "trademark-use" documents provided by respective trademark owners) 59 | 60 | ## Fix up the template to match your new plugin requirements 61 | 62 | This is the file tree structure of the source code, as you can see there are some things you will want to change. 63 | 64 | ``` 65 | `-- src 66 | |-- main 67 | | `-- java 68 | | `-- org 69 | | `-- example 70 | | `-- path 71 | | `-- to 72 | | `-- plugin 73 | | `-- RenamePlugin.java 74 | |-- test 75 | | `-- java 76 | | `-- org 77 | | `-- example 78 | | `-- path 79 | | `-- to 80 | | `-- plugin 81 | | |-- RenamePluginIT.java 82 | | `-- RenameTests.java 83 | `-- yamlRestTest 84 | |-- java 85 | | `-- org 86 | | `-- example 87 | | `-- path 88 | | `-- to 89 | | `-- plugin 90 | | `-- RenameClientYamlTestSuiteIT.java 91 | `-- resources 92 | `-- rest-api-spec 93 | `-- test 94 | `-- 10_basic.yml 95 | 96 | ``` 97 | 98 | ### Plugin Name 99 | Now that you have named the repo, you can change the plugin class `RenamePlugin.java` to have a meaningful name, keeping the `Plugin` suffix. 100 | Change `RenamePluginIT.java`, `RenameTests.java`, and `RenameClientYamlTestSuiteIT.java` accordingly, keeping the `PluginIT`, `Tests`, and `ClientYamlTestSuiteIT` suffixes. 101 | 102 | ### Plugin Path 103 | You will need to change these paths in the source tree: 104 | 105 | 1) Package Path 106 | ``` 107 | `-- org 108 | `-- example 109 | ``` 110 | Let's call this our *package path*. In Java, package naming convention is to use a domain name in order to create a unique package name. 111 | This is normally your organization's domain. 112 | 113 | 2) Plugin Path 114 | ``` 115 | `-- path 116 | `-- to 117 | `-- plugin 118 | ``` 119 | Let's call this our *plugin path*, as the plugin class would be installed in OpenSearch under that path. 120 | This can be an existing path in OpenSearch, or it can be a unique path for your plugin. We recommend changing it to something meaningful. 121 | 122 | 3) Change all these path occurrences to match your chosen path and naming by following [this](#update-the-buildgradle-file) section 123 | 124 | ### Update the `build.gradle` file 125 | 126 | Update the following section, using the new repository name and description, plugin class name, package and plugin paths: 127 | 128 | ``` 129 | def pluginName = 'rename' // Can be the same as new repo name except including words `plugin` or `OpenSearch` is discouraged 130 | def pluginDescription = 'Custom plugin' // Can be same as new repo description 131 | def packagePath = 'org.example' // The package name for your plugin (convention is to use your organization's domain name) 132 | def pathToPlugin = 'path.to.plugin' // The path you chose for the plugin 133 | def pluginClassName = 'RenamePlugin' // The plugin class name 134 | ``` 135 | 136 | Next update the version of OpenSearch you want the plugin to be installed into. Change the following param: 137 | ``` 138 | ext { 139 | opensearch_version = "1.0.0-beta1" // <-- change this to the version your plugin requires 140 | } 141 | ``` 142 | 143 | - Run `./gradlew preparePluginPathDirs` in the terminal 144 | - Move the java classes into the new directories (will require to edit the `package` name in the files as well) 145 | - Delete the old directories (the `org.example` directories) 146 | 147 | ### Update the tests 148 | Notice that in the tests we are checking that the plugin was installed by sending a GET `/_cat/plugins` request to the cluster and expecting `rename` to be in the response. 149 | In order for the tests to pass you must change `rename` in `RenamePluginIT.java` and in `10_basic.yml` to be the `pluginName` you defined in the `build.gradle` file in the previous section. 150 | 151 | ### Running the tests 152 | You may need to install OpenSearch and build a local artifact for the integration tests and build tools ([Learn more here](https://github.com/opensearch-project/opensearch-plugins/blob/main/BUILDING.md)): 153 | 154 | ``` 155 | ~/OpenSearch (main)> git checkout 1.0.0-beta1 -b beta1-release 156 | ~/OpenSearch (main)> ./gradlew publishToMavenLocal -Dbuild.version_qualifier=beta1 -Dbuild.snapshot=false 157 | ``` 158 | 159 | Now you can run all the tests like so: 160 | ``` 161 | ./gradlew check 162 | ``` 163 | 164 | ### Running testClusters with the plugin installed 165 | ``` 166 | ./gradlew run 167 | ``` 168 | 169 | Then you can see that your plugin has been installed by running: 170 | ``` 171 | curl -XGET 'localhost:9200/_cat/plugins' 172 | ``` 173 | 174 | ### Cleanup template code 175 | - You can now delete the unused paths - `path/to/plugin`. 176 | - Remove this from the `build.gradle`: 177 | 178 | ``` 179 | tasks.register("preparePluginPathDirs") { 180 | mustRunAfter clean 181 | doLast { 182 | def newPath = pathToPlugin.replace(".", "/") 183 | mkdir "src/main/java/$packagePath/$newPath" 184 | mkdir "src/test/java/$packagePath/$newPath" 185 | mkdir "src/yamlRestTest/java/$packagePath/$newPath" 186 | } 187 | } 188 | ``` 189 | 190 | - Last but not least, add your own `README.md` instead of this one 191 | 192 | ### Editing the CI workflow 193 | You may want to edit the CI of your new repo. 194 | 195 | In your new GitHub repo, head over to `.github/workflows/CI.yml`. This file describes the workflow for testing new push or pull-request actions on the repo. 196 | Currently, it is configured to build the plugin and run all the tests in it. 197 | 198 | You may need to alter the dependencies required by your new plugin. 199 | Also, the **OpenSearch version** in the `Build OpenSearch` and in the `Build and Run Tests` steps should match your plugins version in the `build.gradle` file. 200 | 201 | To view more complex CI examples you may want to checkout the workflows in official OpenSearch plugins, such as [anomaly-detection](https://github.com/opensearch-project/anomaly-detection/blob/main/.github/workflows/test_build_multi_platform.yml). 202 | 203 | ## Your Plugin's License 204 | Source code files in this template contains the following header: 205 | ``` 206 | /* 207 | * SPDX-License-Identifier: Apache-2.0 208 | * 209 | * The OpenSearch Contributors require contributions made to 210 | * this file be licensed under the Apache-2.0 license or a 211 | * compatible open source license. 212 | */ 213 | ``` 214 | This plugin template is indeed open-sourced while you might choose to use it to create a proprietary plugin. 215 | Be sure to update your plugin to meet any licensing requirements you may be subject to. 216 | 217 | ## License 218 | This code is licensed under the Apache 2.0 License. See [LICENSE.txt](LICENSE.txt). 219 | 220 | ## Copyright 221 | Copyright OpenSearch Contributors. See [NOTICE](NOTICE.txt) for details. 222 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | import org.opensearch.gradle.test.RestIntegTestTask 2 | 3 | apply plugin: 'java' 4 | apply plugin: 'idea' 5 | apply plugin: 'eclipse' 6 | apply plugin: 'opensearch.opensearchplugin' 7 | apply plugin: 'opensearch.yaml-rest-test' 8 | apply plugin: 'opensearch.pluginzip' 9 | 10 | def pluginName = 'rename' 11 | def pluginDescription = 'Custom plugin' 12 | def packagePath = 'org.example' 13 | def pathToPlugin = 'path.to.plugin' 14 | def pluginClassName = 'RenamePlugin' 15 | group = "RenameGroup" 16 | 17 | java { 18 | targetCompatibility = JavaVersion.VERSION_21 19 | sourceCompatibility = JavaVersion.VERSION_21 20 | } 21 | 22 | tasks.register("preparePluginPathDirs") { 23 | mustRunAfter clean 24 | doLast { 25 | def newPath = pathToPlugin.replace(".", "/") 26 | mkdir "src/main/java/$packagePath/$newPath" 27 | mkdir "src/test/java/$packagePath/$newPath" 28 | mkdir "src/yamlRestTest/java/$packagePath/$newPath" 29 | } 30 | } 31 | 32 | publishing { 33 | publications { 34 | pluginZip(MavenPublication) { publication -> 35 | pom { 36 | name = pluginName 37 | description = pluginDescription 38 | licenses { 39 | license { 40 | name = "The Apache License, Version 2.0" 41 | url = "http://www.apache.org/licenses/LICENSE-2.0.txt" 42 | } 43 | } 44 | developers { 45 | developer { 46 | name = "OpenSearch" 47 | url = "https://github.com/opensearch-project/opensearch-plugin-template-java" 48 | } 49 | } 50 | } 51 | } 52 | } 53 | } 54 | 55 | opensearchplugin { 56 | name pluginName 57 | description pluginDescription 58 | classname "${packagePath}.${pathToPlugin}.${pluginClassName}" 59 | licenseFile rootProject.file('LICENSE.txt') 60 | noticeFile rootProject.file('NOTICE.txt') 61 | } 62 | 63 | // This requires an additional Jar not published as part of build-tools 64 | loggerUsageCheck.enabled = false 65 | 66 | // No need to validate pom, as we do not upload to maven/sonatype 67 | validateNebulaPom.enabled = false 68 | 69 | buildscript { 70 | ext { 71 | opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") 72 | } 73 | 74 | repositories { 75 | mavenLocal() 76 | maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } 77 | mavenCentral() 78 | maven { url "https://plugins.gradle.org/m2/" } 79 | } 80 | 81 | dependencies { 82 | classpath "org.opensearch.gradle:build-tools:${opensearch_version}" 83 | } 84 | } 85 | 86 | repositories { 87 | mavenLocal() 88 | maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } 89 | mavenCentral() 90 | maven { url "https://plugins.gradle.org/m2/" } 91 | } 92 | 93 | test { 94 | include '**/*Tests.class' 95 | } 96 | 97 | task integTest(type: RestIntegTestTask) { 98 | description = "Run tests against a cluster" 99 | testClassesDirs = sourceSets.test.output.classesDirs 100 | classpath = sourceSets.test.runtimeClasspath 101 | } 102 | tasks.named("check").configure { dependsOn(integTest) } 103 | 104 | integTest { 105 | // The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable 106 | if (System.getProperty("test.debug") != null) { 107 | jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' 108 | } 109 | } 110 | 111 | testClusters.integTest { 112 | testDistribution = "INTEG_TEST" 113 | 114 | // This installs our plugin into the testClusters 115 | plugin(project.tasks.bundlePlugin.archiveFile) 116 | } 117 | 118 | run { 119 | useCluster testClusters.integTest 120 | } 121 | 122 | // updateVersion: Task to auto update version to the next development iteration 123 | task updateVersion { 124 | onlyIf { System.getProperty('newVersion') } 125 | doLast { 126 | ext.newVersion = System.getProperty('newVersion') 127 | println "Setting version to ${newVersion}." 128 | // String tokenization to support -SNAPSHOT 129 | ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true) 130 | } 131 | } 132 | 133 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # SPDX-License-Identifier: Apache-2.0 3 | # 4 | # The OpenSearch Contributors require contributions made to 5 | # this file be licensed under the Apache-2.0 license or a 6 | # compatible open source license. 7 | # 8 | 9 | org.gradle.caching=true 10 | org.gradle.warning.mode=none 11 | org.gradle.parallel=true 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opensearch-project/opensearch-plugin-template-java/438bf81b5c82a5ddbef1b5723590a99e39408537/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # SPDX-License-Identifier: Apache-2.0 3 | # 4 | # The OpenSearch Contributors require contributions made to 5 | # this file be licensed under the Apache-2.0 license or a 6 | # compatible open source license. 7 | # 8 | 9 | distributionBase=GRADLE_USER_HOME 10 | distributionPath=wrapper/dists 11 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip 12 | zipStoreBase=GRADLE_USER_HOME 13 | zipStorePath=wrapper/dists 14 | distributionSha256Sum=2ab88d6de2c23e6adae7363ae6e29cbdd2a709e992929b48b6530fd0c7133bd6 15 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | # SPDX-License-Identifier: Apache-2.0 19 | # 20 | 21 | ############################################################################## 22 | # 23 | # Gradle start up script for POSIX generated by Gradle. 24 | # 25 | # Important for running: 26 | # 27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 28 | # noncompliant, but you have some other compliant shell such as ksh or 29 | # bash, then to run this script, type that shell name before the whole 30 | # command line, like: 31 | # 32 | # ksh Gradle 33 | # 34 | # Busybox and similar reduced shells will NOT work, because this script 35 | # requires all of these POSIX shell features: 36 | # * functions; 37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 39 | # * compound commands having a testable exit status, especially «case»; 40 | # * various built-in commands including «command», «set», and «ulimit». 41 | # 42 | # Important for patching: 43 | # 44 | # (2) This script targets any POSIX shell, so it avoids extensions provided 45 | # by Bash, Ksh, etc; in particular arrays are avoided. 46 | # 47 | # The "traditional" practice of packing multiple parameters into a 48 | # space-separated string is a well documented source of bugs and security 49 | # problems, so this is (mostly) avoided, by progressively accumulating 50 | # options in "$@", and eventually passing that to Java. 51 | # 52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 54 | # see the in-line comments for details. 55 | # 56 | # There are tweaks for specific operating systems such as AIX, CygWin, 57 | # Darwin, MinGW, and NonStop. 58 | # 59 | # (3) This script is generated from the Groovy template 60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 61 | # within the Gradle project. 62 | # 63 | # You can find Gradle at https://github.com/gradle/gradle/. 64 | # 65 | ############################################################################## 66 | 67 | # Attempt to set APP_HOME 68 | 69 | # Resolve links: $0 may be a link 70 | app_path=$0 71 | 72 | # Need this for daisy-chained symlinks. 73 | while 74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 75 | [ -h "$app_path" ] 76 | do 77 | ls=$( ls -ld "$app_path" ) 78 | link=${ls#*' -> '} 79 | case $link in #( 80 | /*) app_path=$link ;; #( 81 | *) app_path=$APP_HOME$link ;; 82 | esac 83 | done 84 | 85 | # This is normally unused 86 | # shellcheck disable=SC2034 87 | APP_BASE_NAME=${0##*/} 88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 90 | ' "$PWD" ) || exit 91 | 92 | # Use the maximum available, or set MAX_FD != -1 to use that value. 93 | MAX_FD=maximum 94 | 95 | warn () { 96 | echo "$*" 97 | } >&2 98 | 99 | die () { 100 | echo 101 | echo "$*" 102 | echo 103 | exit 1 104 | } >&2 105 | 106 | # OS specific support (must be 'true' or 'false'). 107 | cygwin=false 108 | msys=false 109 | darwin=false 110 | nonstop=false 111 | case "$( uname )" in #( 112 | CYGWIN* ) cygwin=true ;; #( 113 | Darwin* ) darwin=true ;; #( 114 | MSYS* | MINGW* ) msys=true ;; #( 115 | NONSTOP* ) nonstop=true ;; 116 | esac 117 | 118 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 119 | 120 | 121 | # Determine the Java command to use to start the JVM. 122 | if [ -n "$JAVA_HOME" ] ; then 123 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 124 | # IBM's JDK on AIX uses strange locations for the executables 125 | JAVACMD=$JAVA_HOME/jre/sh/java 126 | else 127 | JAVACMD=$JAVA_HOME/bin/java 128 | fi 129 | if [ ! -x "$JAVACMD" ] ; then 130 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 131 | 132 | Please set the JAVA_HOME variable in your environment to match the 133 | location of your Java installation." 134 | fi 135 | else 136 | JAVACMD=java 137 | if ! command -v java >/dev/null 2>&1 138 | then 139 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 140 | 141 | Please set the JAVA_HOME variable in your environment to match the 142 | location of your Java installation." 143 | fi 144 | fi 145 | 146 | # Increase the maximum file descriptors if we can. 147 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 148 | case $MAX_FD in #( 149 | max*) 150 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 151 | # shellcheck disable=SC2039,SC3045 152 | MAX_FD=$( ulimit -H -n ) || 153 | warn "Could not query maximum file descriptor limit" 154 | esac 155 | case $MAX_FD in #( 156 | '' | soft) :;; #( 157 | *) 158 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 159 | # shellcheck disable=SC2039,SC3045 160 | ulimit -n "$MAX_FD" || 161 | warn "Could not set maximum file descriptor limit to $MAX_FD" 162 | esac 163 | fi 164 | 165 | # Collect all arguments for the java command, stacking in reverse order: 166 | # * args from the command line 167 | # * the main class name 168 | # * -classpath 169 | # * -D...appname settings 170 | # * --module-path (only if needed) 171 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 172 | 173 | # For Cygwin or MSYS, switch paths to Windows format before running java 174 | if "$cygwin" || "$msys" ; then 175 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 176 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 177 | 178 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 179 | 180 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 181 | for arg do 182 | if 183 | case $arg in #( 184 | -*) false ;; # don't mess with options #( 185 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 186 | [ -e "$t" ] ;; #( 187 | *) false ;; 188 | esac 189 | then 190 | arg=$( cygpath --path --ignore --mixed "$arg" ) 191 | fi 192 | # Roll the args list around exactly as many times as the number of 193 | # args, so each arg winds up back in the position where it started, but 194 | # possibly modified. 195 | # 196 | # NB: a `for` loop captures its iteration list before it begins, so 197 | # changing the positional parameters here affects neither the number of 198 | # iterations, nor the values presented in `arg`. 199 | shift # remove old arg 200 | set -- "$@" "$arg" # push replacement arg 201 | done 202 | fi 203 | 204 | 205 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 206 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 207 | 208 | # Collect all arguments for the java command: 209 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 210 | # and any embedded shellness will be escaped. 211 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 212 | # treated as '${Hostname}' itself on the command line. 213 | 214 | set -- \ 215 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 216 | -classpath "$CLASSPATH" \ 217 | org.gradle.wrapper.GradleWrapperMain \ 218 | "$@" 219 | 220 | # Stop when "xargs" is not available. 221 | if ! command -v xargs >/dev/null 2>&1 222 | then 223 | die "xargs is not available" 224 | fi 225 | 226 | # Use "xargs" to parse quoted args. 227 | # 228 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 229 | # 230 | # In Bash we could simply go: 231 | # 232 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 233 | # set -- "${ARGS[@]}" "$@" 234 | # 235 | # but POSIX shell has neither arrays nor command substitution, so instead we 236 | # post-process each arg (as a line of input to sed) to backslash-escape any 237 | # character that might be a shell metacharacter, then use eval to reverse 238 | # that process (while maintaining the separation between arguments), and wrap 239 | # the whole thing up as a single "set" statement. 240 | # 241 | # This will of course break if any of these variables contains a newline or 242 | # an unmatched quote. 243 | # 244 | 245 | eval "set -- $( 246 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 247 | xargs -n1 | 248 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 249 | tr '\n' ' ' 250 | )" '"$@"' 251 | 252 | exec "$JAVACMD" "$@" 253 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was generated by the Gradle 'init' task. 3 | * 4 | * The settings file is used to specify which projects to include in your build. 5 | * 6 | * Detailed information about configuring a multi-project build in Gradle can be found 7 | * in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html 8 | */ 9 | 10 | rootProject.name = 'plugin-template' 11 | -------------------------------------------------------------------------------- /src/main/java/org/example/path/to/plugin/RenamePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | * 4 | * The OpenSearch Contributors require contributions made to 5 | * this file be licensed under the Apache-2.0 license or a 6 | * compatible open source license. 7 | */ 8 | package org.example.path.to.plugin; 9 | 10 | import org.opensearch.plugins.Plugin; 11 | 12 | 13 | public class RenamePlugin extends Plugin { 14 | // Implement the relevant Plugin Interfaces here 15 | } 16 | -------------------------------------------------------------------------------- /src/test/java/org/example/path/to/plugin/RenamePluginIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | * 4 | * The OpenSearch Contributors require contributions made to 5 | * this file be licensed under the Apache-2.0 license or a 6 | * compatible open source license. 7 | */ 8 | package org.example.path.to.plugin; 9 | 10 | import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; 11 | import org.apache.hc.core5.http.ParseException; 12 | import org.apache.hc.core5.http.io.entity.EntityUtils; 13 | import org.opensearch.client.Request; 14 | import org.opensearch.client.Response; 15 | import org.opensearch.plugins.Plugin; 16 | import org.opensearch.test.OpenSearchIntegTestCase; 17 | 18 | import java.io.IOException; 19 | import java.nio.charset.StandardCharsets; 20 | import java.util.Collection; 21 | import java.util.Collections; 22 | 23 | import static org.hamcrest.Matchers.containsString; 24 | 25 | @ThreadLeakScope(ThreadLeakScope.Scope.NONE) 26 | @OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE) 27 | public class RenamePluginIT extends OpenSearchIntegTestCase { 28 | 29 | @Override 30 | protected Collection> nodePlugins() { 31 | return Collections.singletonList(RenamePlugin.class); 32 | } 33 | 34 | public void testPluginInstalled() throws IOException, ParseException { 35 | Response response = getRestClient().performRequest(new Request("GET", "/_cat/plugins")); 36 | String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); 37 | 38 | logger.info("response body: {}", body); 39 | assertThat(body, containsString("rename")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/org/example/path/to/plugin/RenameTests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | * 4 | * The OpenSearch Contributors require contributions made to 5 | * this file be licensed under the Apache-2.0 license or a 6 | * compatible open source license. 7 | */ 8 | package org.example.path.to.plugin; 9 | 10 | import org.opensearch.test.OpenSearchTestCase; 11 | 12 | public class RenameTests extends OpenSearchTestCase { 13 | // Add unit tests for your plugin 14 | } 15 | -------------------------------------------------------------------------------- /src/yamlRestTest/java/org/example/path/to/plugin/RenameClientYamlTestSuiteIT.java: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | * 4 | * The OpenSearch Contributors require contributions made to 5 | * this file be licensed under the Apache-2.0 license or a 6 | * compatible open source license. 7 | */ 8 | package org.example.path.to.plugin; 9 | 10 | import com.carrotsearch.randomizedtesting.annotations.Name; 11 | import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; 12 | import org.opensearch.test.rest.yaml.ClientYamlTestCandidate; 13 | import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase; 14 | 15 | 16 | public class RenameClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase { 17 | 18 | public RenameClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) { 19 | super(testCandidate); 20 | } 21 | 22 | @ParametersFactory 23 | public static Iterable parameters() throws Exception { 24 | return OpenSearchClientYamlSuiteTestCase.createParameters(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/yamlRestTest/resources/rest-api-spec/test/10_basic.yml: -------------------------------------------------------------------------------- 1 | "Test that the plugin is loaded in OpenSearch": 2 | - do: 3 | cat.plugins: 4 | local: true 5 | h: component 6 | 7 | - match: 8 | $body: /^rename\n$/ 9 | --------------------------------------------------------------------------------