From 1f862471d9362f2348d4f7c1a40cb42f85acc9ee Mon Sep 17 00:00:00 2001 From: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org> Date: Fri, 27 Jan 2023 14:26:50 +0000 Subject: [PATCH] feat: Create base application files + openAPI spec --- .dockerignore | 5 + .gitignore | 48 ++ CODE_OF_CONDUCT.md | 94 ++++ CONTRIBUTING.md | 33 ++ Jenkinsfile | 212 ++++++++ LICENSE | 482 ++++++++++++++++++ Makefile | 43 ++ NOTICE.md | 40 ++ README.md | 108 ++-- config/.env.sample | 16 + config/application/secret.properties.sample | 3 + config/foundationdb/secret.properties.sample | 9 + config/mariadb/init.d/init.sql | 0 docker-compose.yaml | 55 ++ package.json | 14 + pom.xml | 256 ++++++++++ spec/openapi.yaml | 160 ++++++ src/main/docker/Dockerfile.jvm | 94 ++++ src/main/docker/Dockerfile.legacy-jar | 90 ++++ src/main/docker/Dockerfile.native | 27 + src/main/docker/Dockerfile.native-micro | 30 ++ .../openvsx/resources/GreetingResource.java | 24 + .../resources/META-INF/resources/favicon.ico | Bin 0 -> 1150 bytes src/main/resources/application.properties | 8 + .../resources/GreetingResourceTest.java | 33 ++ src/test/resources/application.properties | 5 + 26 files changed, 1821 insertions(+), 68 deletions(-) create mode 100644 .dockerignore create mode 100644 .gitignore create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 Jenkinsfile create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 NOTICE.md create mode 100644 config/.env.sample create mode 100644 config/application/secret.properties.sample create mode 100644 config/foundationdb/secret.properties.sample create mode 100644 config/mariadb/init.d/init.sql create mode 100644 docker-compose.yaml create mode 100644 package.json create mode 100644 pom.xml create mode 100644 spec/openapi.yaml create mode 100644 src/main/docker/Dockerfile.jvm create mode 100644 src/main/docker/Dockerfile.legacy-jar create mode 100644 src/main/docker/Dockerfile.native create mode 100644 src/main/docker/Dockerfile.native-micro create mode 100644 src/main/java/org/eclipsefoundation/openvsx/resources/GreetingResource.java create mode 100644 src/main/resources/META-INF/resources/favicon.ico create mode 100644 src/main/resources/application.properties create mode 100644 src/test/java/org/eclipsefoundation/openvsx/resources/GreetingResourceTest.java create mode 100644 src/test/resources/application.properties diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..94810d0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +* +!target/*-runner +!target/*-runner.jar +!target/lib/* +!target/quarkus-app/* \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b19cb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,48 @@ +#Maven +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +release.properties + +# Eclipse +.project +.classpath +.settings/ +bin/ + +# IntelliJ +.idea +*.ipr +*.iml +*.iws + +# NetBeans +nb-configuration.xml + +# Visual Studio Code +.vscode +.factorypath + +# OSX +.DS_Store + +# Vim +*.swp +*.swo + +# patch +*.orig +*.rej + +# Local environment +/volumes +.env + +/config/**/*secret.properties +/node_modules +/src/test/resources/schemas +/.apt_generated/ +/.apt_generated_tests/ +config/mariadb/init.d/eclipsefoundation.sql +yarn-error.log diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..007ea8b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,94 @@ +# Community Code of Conduct + +**Version 2.0 +January 1, 2023** + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as community members, contributors, Committers[^1], and Project Leads (collectively "Contributors") pledge to make participation in our projects and our community a harassment-free and inclusive experience for everyone. + +This Community Code of Conduct ("Code") outlines our behavior expectations as members of our community in all Eclipse Foundation activities, both offline and online. It is not intended to govern scenarios or behaviors outside of the scope of Eclipse Foundation activities. Nor is it intended to replace or supersede the protections offered to all our community members under the law. Please follow both the spirit and letter of this Code and encourage other Contributors to follow these principles into our work. Failure to read or acknowledge this Code does not excuse a Contributor from compliance with the Code. + +## Our Standards + +Examples of behavior that contribute to creating a positive and professional environment include: + +- Using welcoming and inclusive language; +- Actively encouraging all voices; +- Helping others bring their perspectives and listening actively. If you find yourself dominating a discussion, it is especially important to encourage other voices to join in; +- Being respectful of differing viewpoints and experiences; +- Gracefully accepting constructive criticism; +- Focusing on what is best for the community; +- Showing empathy towards other community members; +- Being direct but professional; and +- Leading by example by holding yourself and others accountable + +Examples of unacceptable behavior by Contributors include: + +- The use of sexualized language or imagery; +- Unwelcome sexual attention or advances; +- Trolling, insulting/derogatory comments, and personal or political attacks; +- Public or private harassment, repeated harassment; +- Publishing others' private information, such as a physical or electronic address, without explicit permission; +- Violent threats or language directed against another person; +- Sexist, racist, or otherwise discriminatory jokes and language; +- Posting sexually explicit or violent material; +- Sharing private content, such as emails sent privately or non-publicly, or unlogged forums such as IRC channel history; +- Personal insults, especially those using racist or sexist terms; +- Excessive or unnecessary profanity; +- Advocating for, or encouraging, any of the above behavior; and +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +With the support of the Eclipse Foundation employees, consultants, officers, and directors (collectively, the "Staff"), Committers, and Project Leads, the Eclipse Foundation Conduct Committee (the "Conduct Committee") is responsible for clarifying the standards of acceptable behavior. The Conduct Committee takes appropriate and fair corrective action in response to any instances of unacceptable behavior. + +## Scope + +This Code applies within all Project, Working Group, and Interest Group spaces and communication channels of the Eclipse Foundation (collectively, "Eclipse spaces"), within any Eclipse-organized event or meeting, and in public spaces when an individual is representing an Eclipse Foundation Project, Working Group, Interest Group, or their communities. Examples of representing a Project or community include posting via an official social media account, personal accounts, or acting as an appointed representative at an online or offline event. Representation of Projects, Working Groups, and Interest Groups may be further defined and clarified by Committers, Project Leads, or the Staff. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the Conduct Committee via conduct@eclipse-foundation.org. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Without the explicit consent of the reporter, the Conduct Committee is obligated to maintain confidentiality with regard to the reporter of an incident. The Conduct Committee is further obligated to ensure that the respondent is provided with sufficient information about the complaint to reply. If such details cannot be provided while maintaining confidentiality, the Conduct Committee will take the respondent‘s inability to provide a defense into account in its deliberations and decisions. Further details of enforcement guidelines may be posted separately. + +Staff, Committers and Project Leads have the right to report, remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code, or to block temporarily or permanently any Contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. Any such actions will be reported to the Conduct Committee for transparency and record keeping. + +Any Staff (including officers and directors of the Eclipse Foundation), Committers, Project Leads, or Conduct Committee members who are the subject of a complaint to the Conduct Committee will be recused from the process of resolving any such complaint. + +## Responsibility + +The responsibility for administering this Code rests with the Conduct Committee, with oversight by the Executive Director and the Board of Directors. For additional information on the Conduct Committee and its process, please write to <conduct@eclipse-foundation.org>. + +## Investigation of Potential Code Violations + +All conflict is not bad as a healthy debate may sometimes be necessary to push us to do our best. It is, however, unacceptable to be disrespectful or offensive, or violate this Code. If you see someone engaging in objectionable behavior violating this Code, we encourage you to address the behavior directly with those involved. If for some reason, you are unable to resolve the matter or feel uncomfortable doing so, or if the behavior is threatening or harassing, please report it following the procedure laid out below. + +Reports should be directed to <conduct@eclipse-foundation.org>. It is the Conduct Committee’s role to receive and address reported violations of this Code and to ensure a fair and speedy resolution. + +The Eclipse Foundation takes all reports of potential Code violations seriously and is committed to confidentiality and a full investigation of all allegations. The identity of the reporter will be omitted from the details of the report supplied to the accused. Contributors who are being investigated for a potential Code violation will have an opportunity to be heard prior to any final determination. Those found to have violated the Code can seek reconsideration of the violation and disciplinary action decisions. Every effort will be made to have all matters disposed of within 60 days of the receipt of the complaint. + +## Actions + +Contributors who do not follow this Code in good faith may face temporary or permanent repercussions as determined by the Conduct Committee. + +This Code does not address all conduct. It works in conjunction with our [Communication Channel Guidelines](https://www.eclipse.org/org/documents/communication-channel-guidelines/), [Social Media Guidelines](https://www.eclipse.org/org/documents/social_media_guidelines.php), [Bylaws](https://www.eclipse.org/org/documents/eclipse-foundation-be-bylaws-en.pdf), and [Internal Rules](https://www.eclipse.org/org/documents/ef-be-internal-rules.pdf) which set out additional protections for, and obligations of, all contributors. The Foundation has additional policies that provide further guidance on other matters. + +It’s impossible to spell out every possible scenario that might be deemed a violation of this Code. Instead, we rely on one another’s good judgment to uphold a high standard of integrity within all Eclipse Spaces. Sometimes, identifying the right thing to do isn’t an easy call. In such a scenario, raise the issue as early as possible. + +## No Retaliation + +The Eclipse community relies upon and values the help of Contributors who identify potential problems that may need to be addressed within an Eclipse Space. Any retaliation against a Contributor who raises an issue honestly is a violation of this Code. That a Contributor has raised a concern honestly or participated in an investigation, cannot be the basis for any adverse action, including threats, harassment, or discrimination. If you work with someone who has raised a concern or provided information in an investigation, you should continue to treat the person with courtesy and respect. If you believe someone has retaliated against you, report the matter as described by this Code. Honest reporting does not mean that you have to be right when you raise a concern; you just have to believe that the information you are providing is accurate. + +False reporting, especially when intended to retaliate or exclude, is itself a violation of this Code and will not be accepted or tolerated. + +Everyone is encouraged to ask questions about this Code. Your feedback is welcome, and you will get a response within three business days. Write to <conduct@eclipse-foundation.org>. + +## Amendments + +The Eclipse Foundation Board of Directors may amend this Code from time to time and may vary the procedures it sets out where appropriate in a particular case. + +### Attribution + +This Code was inspired by the [Contributor Covenant](https://www.contributor-covenant.org/), version 1.4, available [here](https://www.contributor-covenant.org/version/1/4/code-of-conduct/). + +[^1]: Capitalized terms used herein without definition shall have the meanings assigned to them in the Bylaws. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..134c50a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contributing to eclipse-openvsx-api + +Thanks for your interest in this project. + +## Project description + +* <https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api> + +## Developer resources + +The project maintains the following source code repositories + +* <https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api> +> +## Eclipse Contributor Agreement + +Before your contribution can be accepted by the project team contributors must +electronically sign the Eclipse Contributor Agreement (ECA). + +* <http://www.eclipse.org/legal/ECA.php> + +Commits that are provided by non-committers must have a Signed-off-by field in +the footer indicating that the author is aware of the terms by which the +contribution has been provided to the project. The non-committer must +additionally have an Eclipse Foundation account and must have a signed Eclipse +Contributor Agreement (ECA) on file. + +For more information, please see the Eclipse Committer Handbook: +<https://www.eclipse.org/projects/handbook/#resources-commit> + +## Contact + +Contact the Eclipse Foundation Webdev team via webdev@eclipse-foundation.org. diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..0659393 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,212 @@ +@Library('common-shared') _ + +pipeline { + agent { + kubernetes { + label 'buildenv-agent' + yaml ''' + apiVersion: v1 + kind: Pod + spec: + containers: + - name: buildcontainer + image: eclipsefdn/stack-build-agent:latest + imagePullPolicy: Always + command: + - cat + tty: true + resources: + requests: + cpu: "1" + memory: "4Gi" + limits: + cpu: "2" + memory: "4Gi" + env: + - name: "HOME" + value: "/home/jenkins" + - name: "MAVEN_OPTS" + value: "-Duser.home=/home/jenkins" + volumeMounts: + - name: m2-repo + mountPath: /home/jenkins/.m2/repository + - name: m2-secret-dir + mountPath: /home/jenkins/.m2/settings.xml + subPath: settings.xml + readOnly: true + - mountPath: "/home/jenkins/.m2/settings-security.xml" + name: "m2-secret-dir" + readOnly: true + subPath: "settings-security.xml" + - mountPath: "/home/jenkins/.mavenrc" + name: "m2-dir" + readOnly: true + subPath: ".mavenrc" + - mountPath: "/home/jenkins/.m2/wrapper" + name: "m2-wrapper" + readOnly: false + - mountPath: "/home/jenkins/.cache" + name: "yarn-cache" + readOnly: false + - name: jnlp + resources: + requests: + memory: "1024Mi" + cpu: "500m" + limits: + memory: "1024Mi" + cpu: "1000m" + volumes: + - name: "m2-dir" + configMap: + name: "m2-dir" + - name: m2-secret-dir + secret: + secretName: m2-secret-dir + - name: m2-repo + emptyDir: {} + - name: m2-wrapper + emptyDir: {} + - name: yarn-cache + emptyDir: {} + ''' + } + } + + environment { + APP_NAME = 'eclipse-openvsx-api' + NAMESPACE = 'foundation-internal-webdev-apps' + IMAGE_NAME = 'eclipsefdn/eclipse-openvsx-api' + CONTAINER_NAME = 'app' + ENVIRONMENT = sh( + script: """ + printf "${env.BRANCH_NAME}" + """, + returnStdout: true + ) + TAG_NAME = sh( + script: """ + GIT_COMMIT_SHORT=\$(git rev-parse --short ${env.GIT_COMMIT}) + if [ "${env.ENVIRONMENT}" = "" ]; then + printf \${GIT_COMMIT_SHORT}-${env.BUILD_NUMBER} + else + printf ${env.ENVIRONMENT}-\${GIT_COMMIT_SHORT}-${env.BUILD_NUMBER} + fi + """, + returnStdout: true + ) + } + + options { + buildDiscarder(logRotator(numToKeepStr: '10')) + timeout(time: 30, unit: 'MINUTES') + } + + stages { + stage('Build project') { + steps { + container('buildcontainer') { + readTrusted 'Makefile' + readTrusted 'pom.xml' + readTrusted 'package.json' + sh 'make compile' + stash name: "target", includes: "target/**/*" + } + } + } + + stage('Build docker image') { + agent { + label 'docker-build' + } + steps { + readTrusted 'src/main/docker/Dockerfile.jvm' + unstash 'target' + sh ''' + docker build -f src/main/docker/Dockerfile.jvm --no-cache -t ${IMAGE_NAME}:${TAG_NAME} -t ${IMAGE_NAME}:latest . + ''' + } + } + + stage('Push docker image') { + agent { + label 'docker-build' + } + when { + anyOf { + environment name: 'ENVIRONMENT', value: 'production' + environment name: 'ENVIRONMENT', value: 'staging' + } + } + steps { + withDockerRegistry([credentialsId: '04264967-fea0-40c2-bf60-09af5aeba60f', url: 'https://index.docker.io/v1/']) { + sh ''' + docker push ${IMAGE_NAME}:${TAG_NAME} + docker push ${IMAGE_NAME}:latest + ''' + } + } + } + +/* + stage('Deploy to cluster') { + agent { + kubernetes { + label 'kubedeploy-agent' + yaml ''' + apiVersion: v1 + kind: Pod + spec: + containers: + - name: kubectl + image: eclipsefdn/kubectl:okd-c1 + command: + - cat + tty: true + resources: + limits: + cpu: 1 + memory: 1Gi + volumeMounts: + - mountPath: "/home/default/.kube" + name: "dot-kube" + readOnly: false + - name: jnlp + resources: + limits: + cpu: 1 + memory: 1Gi + volumes: + - name: "dot-kube" + emptyDir: {} + ''' + } + } + + when { + anyOf { + environment name: 'ENVIRONMENT', value: 'production' + environment name: 'ENVIRONMENT', value: 'staging' + } + } + steps { + container('kubectl') { + updateContainerImage([ + namespace: "${env.NAMESPACE}", + selector: "app=${env.APP_NAME},environment=${env.ENVIRONMENT}", + containerName: "${env.CONTAINER_NAME}", + newImageRef: "${env.IMAGE_NAME}:${env.TAG_NAME}" + ]) + } + } + } + */ + } + + post { + always { + deleteDir() /* clean up workspace */ + sendNotifications currentBuild + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..930dbb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,482 @@ +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. + + + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e259db7 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +SHELL = /bin/bash + +pre-setup:; + @echo "Creating environment file from template" + @rm -f .env && envsubst < config/.env.sample > .env + [ -f ./config/mariadb/init.d/eclipsefoundation.sql ] && echo "EF DB dump already exists, skipping fetch" || scp api-vm1:~/webdev/sql/eclipsefoundation.sql ./config/mariadb/init.d/ + +setup:; + @echo "Generating secret files from templates using environment file + variables" + @source .env && rm -f ./config/application/secret.properties && envsubst < config/application/secret.properties.sample > config/application/secret.properties + @source .env && rm -f ./config/foundationdb/secret.properties && envsubst < config/foundationdb/secret.properties.sample > config/foundationdb/secret.properties + +dev-start:; + mvn compile -e quarkus:dev -Dconfig.secret.path=$$PWD/config/application/secret.properties + +clean:; + mvn clean + yarn run clean + +install-yarn:; + yarn install --frozen-lockfile --audit + +compile-test-resources: install-yarn; + yarn run generate-json-schema + +compile-java: compile-test-resources; + mvn compile package + +compile-java-quick: compile-test-resources; + mvn compile package -Dmaven.test.skip=true + +compile: clean compile-java; + +compile-quick: clean compile-java-quick; + +compile-start: compile-quick; + docker compose down + docker compose build + docker compose up -d + +start-spec: compile-test-resources; + yarn run start + \ No newline at end of file diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..5e43f28 --- /dev/null +++ b/NOTICE.md @@ -0,0 +1,40 @@ +# Notices for eclipse-openvsx-api + +This content is produced and maintained by the Eclipse Foundation. Trademarks are the property of their respective owners. + +* Project home: <https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api> + +## Trademarks + +* Eclipse® is a Trademark of the Eclipse Foundation, Inc. +* Eclipse Foundation is a Trademark of the Eclipse Foundation, Inc. + +## Copyright + +All content is the property of the respective authors or their employers. For +more information regarding authorship of content, please consult the listed +source code repository logs. + +## Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v. 2.0 which is available at +<http://www.eclipse.org/legal/epl-2.0>. + +SPDX-License-Identifier: EPL-2.0 + +## Source Code + +The project maintains the following source code repositories: + +* <https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api> + +## Third-party Content + +### Quarkus + +* License: Apache License 2.0 (APL) + +### Auto-value + +* License: Apache License 2.0 (APL) diff --git a/README.md b/README.md index d7d7197..51933fe 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,64 @@ # eclipse-openvsx-api - +This API fetches Eclipse publisher agreement data ## Getting started -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api/-/settings/integrations) - -## Collaborate with your team +### Requirements -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) +* Docker +* mvn +* make +* yarn +* Java 11 > -## Test and Deploy +### Setup -Use the built-in continuous integration in GitLab. +Additional setup instructions will be added as the project develops. -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +#### Build and Start Server -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. +```bash +make compile-start +``` -## Name -Choose a self-explaining name for your project. +#### Live-coding Dev Mode -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. +```bash +make dev-start +``` -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. +#### Generate Spec -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. +```bash +make compile-test-resources +``` -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. +#### Running Tests -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. +```bash +mvn test +``` -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. +#### Render a Live UI Preview of the API Spec -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. +```bash +make start-spec +``` ## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. +1. [Fork](https://docs.gitlab.com/ee/user/project/repository/forking_workflow.html) the [eclipse-openvsx-api](https://gitlab.eclipse.org/eclipsefdn/it/api/eclipse-openvsx-api) repository +2. Clone repository `git clone https://gitlab.eclipse.org/[your_eclipsefdn_username]/eclipse-openvsx-api.git` +3. Create your feature branch: `git checkout -b my-new-feature` +4. Commit your changes: `git commit -m 'Add some feature' -s` +5. Push feature branch: `git push origin my-new-feature` +6. Submit a merge request -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. +### Declared Project Licenses -## License -For open source projects, say how it is licensed. +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v. 2.0 which is available at +<http://www.eclipse.org/legal/epl-2.0>. -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +SPDX-License-Identifier: EPL-2.0 diff --git a/config/.env.sample b/config/.env.sample new file mode 100644 index 0000000..6d01268 --- /dev/null +++ b/config/.env.sample @@ -0,0 +1,16 @@ +export OPENVSXAPI_MYSQL_USERNAME=$MARIADB_USERNAME +export OPENVSXAPI_MYSQL_PASSWORD=$MARIADB_PASSWORD +export OPENVSXAPI_MYSQL_PORT=$MARIADB_PORT +export CONFIG_SECRET_PATH=$PWD/config/secret.properties + +export FOUNDATIONDB_DB_NAME=eclipsefoundation + +export KEYCLOAK_FOUNDATIONDB_REALM_URL=https://auth.eclipse.org/auth/realms/foundation + +# OPENVSX API -> FDB API connection settings. +export OPENVSXAPI_OIDCCLIENT_CLIENT_ID=sample +export OPENVSXAPI_OIDCCLIENT_CLIENT_CREDENTIALS=sample + +# FoundationDB API OIDC connection settings +export FOUNDATION_OIDC_CLIENT_ID=sample +export FOUNDATION_OIDC_CLIENT_CREDENTIALS=sample \ No newline at end of file diff --git a/config/application/secret.properties.sample b/config/application/secret.properties.sample new file mode 100644 index 0000000..876a5a6 --- /dev/null +++ b/config/application/secret.properties.sample @@ -0,0 +1,3 @@ +quarkus.oidc-client.auth-server-url=$KEYCLOAK_FOUNDATIONDB_REALM_URL +quarkus.oidc-client.client-id=$OPENVSXAPI_OIDCCLIENT_CLIENT_ID +quarkus.oidc-client.credentials.secret=$OPENVSXAPI_OIDCCLIENT_CLIENT_CREDENTIALS \ No newline at end of file diff --git a/config/foundationdb/secret.properties.sample b/config/foundationdb/secret.properties.sample new file mode 100644 index 0000000..208d85b --- /dev/null +++ b/config/foundationdb/secret.properties.sample @@ -0,0 +1,9 @@ +quarkus.datasource.jdbc.url=jdbc:mariadb://localhost:$FOUNDATIONDB_DB_PORT/$FOUNDATIONDB_DB_NAME +quarkus.datasource.username=$MARIADB_USERNAME +quarkus.datasource.password=$MARIADB_PASSWORD + +quarkus.oidc.auth-server-url=$KEYCLOAK_FOUNDATIONDB_REALM_URL +quarkus.oidc.client-id=$FOUNDATION_OIDC_CLIENT_ID +quarkus.oidc.credentials.secret=$FOUNDATION_OIDC_CLIENT_CREDENTIALS + +quarkus.http.port=8095 \ No newline at end of file diff --git a/config/mariadb/init.d/init.sql b/config/mariadb/init.d/init.sql new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..88e830e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,55 @@ +version: '3' +services: + application: + build: + dockerfile: ./src/main/docker/Dockerfile.jvm + ports: + - 10111:8090 + environment: + - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties + volumes: + - ./config/application/secret.properties:/var/run/secrets/secret.properties + deploy: + restart_policy: + condition: on-failure + max_attempts: 5 + resources: + limits: + cpus: '0.5' + memory: 192M + reservations: + cpus: '0.001' + memory: 128M + depends_on: + - foundationdb + foundationdb: + image: eclipsefdn/foundationdb-api:production-b43bc82-7 + ports: + - '10112:8095' + environment: + - CONFIG_SECRET_PATH=/var/run/secrets/secret.properties + volumes: + - ./config/foundationdb/secret.properties:/var/run/secrets/secret.properties + deploy: + restart_policy: + condition: on-failure + max_attempts: 5 + resources: + limits: + cpus: '0.5' + memory: 384M + reservations: + cpus: '0.001' + memory: 256M + mariadb: + image: mariadb:latest + command: --max_allowed_packet=100000000 + ports: + - 10113:3306 + environment: + MYSQL_ROOT_PASSWORD: ${MARIADB_PASSWORD} + MYSQL_DATABASE: ${KEYCLOAK_DB} + volumes: + - ./config/mariadb/init.d:/docker-entrypoint-initdb.d + - ./volumes/mariadb:/var/lib/mysql + - ./config/mariadb/conf:/etc/mysql/conf.d diff --git a/package.json b/package.json new file mode 100644 index 0000000..e23656c --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "eclipse-openvsx-api-support", + "version": "1.0.0", + "dependencies": { + "eclipsefdn-api-support": "1.0.0" + }, + "private": true, + "scripts": { + "start": "yarn run generate-json-schema && npx @redocly/openapi-cli preview-docs spec/openapi.yaml -p 8097", + "test": "yarn run generate-json-schema && npx @redocly/openapi-cli lint spec/openapi.yaml", + "generate-json-schema": "yarn run clean && node node_modules/eclipsefdn-api-support/src/openapi2schema.js -s spec/openapi.yaml -t src/test/resources", + "clean": "rm -rf src/test/resources/schemas/" + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..5024ebb --- /dev/null +++ b/pom.xml @@ -0,0 +1,256 @@ +<?xml version="1.0"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.eclipsefoundation</groupId> + <artifactId>eclipse-openvsx-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + <properties> + <compiler-plugin.version>3.8.1</compiler-plugin.version> + <failsafe.useModulePath>false</failsafe.useModulePath> + <maven.compiler.release>11</maven.compiler.release> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> + <quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id> + <quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id> + <quarkus.platform.version>2.11.2.Final</quarkus.platform.version> + <surefire-plugin.version>3.0.0-M5</surefire-plugin.version> + <auto-value.version>1.8.2</auto-value.version> + <hibernate.version>5.5.6.Final</hibernate.version> + <eclipse-api-version>0.7.0-SNAPSHOT</eclipse-api-version> + <fdndb-api-version>1.0-SNAPSHOT</fdndb-api-version> + </properties> + <repositories> + <repository> + <id>eclipsefdn</id> + <url>https://repo.eclipse.org/content/repositories/eclipsefdn/</url> + <releases> + <enabled>true</enabled> + </releases> + <snapshots> + <enabled>true</enabled> + </snapshots> + </repository> + </repositories> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + <dependencies> + + <dependency> + <groupId>org.eclipsefoundation</groupId> + <artifactId>quarkus-core</artifactId> + <version>${eclipse-api-version}</version> + <!-- Can be removed once dependency is removed from base package + https://stackoverflow.com/questions/67510802/logging-in-quarkus-works-in-dev-mode-but-doesnt-output-in-jvm-docker-image --> + <exclusions> + <exclusion> + <groupId>org.jboss.logmanager</groupId> + <artifactId>jboss-logmanager</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.eclipsefoundation</groupId> + <artifactId>foundationdb-api-client</artifactId> + <version>${fdndb-api-version}</version> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jackson</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-oidc-client</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-oidc-client-filter</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-rest-client</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-cache</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-arc</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-hibernate-validator</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-text</artifactId> + <version>1.9</version> + </dependency> + + <!-- Annotation preprocessors - reduce all of the boiler plate --> + <dependency> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value</artifactId> + <version>${auto-value.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value-annotations</artifactId> + <version>${auto-value.version}</version> + </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + <version>3.0.0</version> + </dependency> + + <!-- Testing dependencies only --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>rest-assured</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.rest-assured</groupId> + <artifactId>json-schema-validator</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-junit5-mockito</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipsefoundation</groupId> + <artifactId>quarkus-test-common</artifactId> + <version>${eclipse-api-version}</version> + </dependency> + + <!-- Following H2/devservices deps are made to circumvent need for docker --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-devservices-h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jdbc-h2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <scope>test</scope> + </dependency> + <!-- Flyway specific dependencies, used to setup tables in test --> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-flyway</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <version>${quarkus.platform.version}</version> + <extensions>true</extensions> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>generate-code</goal> + <goal>generate-code-tests</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <version>${compiler-plugin.version}</version> + <configuration> + <annotationProcessorPaths> + <path> + <groupId> + com.google.auto.value</groupId> + <artifactId>auto-value</artifactId> + <version>${auto-value.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <configuration> + <skipTests> + false</skipTests> + <systemPropertyVariables> + <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home> + ${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-failsafe-plugin</artifactId> + <version>${surefire-plugin.version}</version> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + <configuration> + <systemPropertyVariables> + <native.image.path> + ${project.build.directory}/${project.build.finalName}-runner</native.image.path> + <java.util.logging.manager> + org.jboss.logmanager.LogManager</java.util.logging.manager> + <maven.home>${maven.home}</maven.home> + </systemPropertyVariables> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <properties> + <quarkus.package.type> + native</quarkus.package.type> + </properties> + </profile> + </profiles> +</project> \ No newline at end of file diff --git a/spec/openapi.yaml b/spec/openapi.yaml new file mode 100644 index 0000000..1f22b2c --- /dev/null +++ b/spec/openapi.yaml @@ -0,0 +1,160 @@ +openapi: "3.1.0" +info: + version: 1.0.0 + title: Openvsx API + description: Access information on Eclipse Foundation publisher agreements. + license: + name: Eclipse Public License - 2.0 + url: https://www.eclipse.org/legal/epl-2.0/ + +servers: + - url: https://api.eclipse.org/openvsx + description: Production endpoint for Eclipse Foundation publisher agreement data + +paths: + /publisher_agreement: + get: + tags: + - Publisher Agreement + summary: Publisher Agreement + description: Fetch the open-vsx.org publisher agreement for the current user. + security: + - OAuth2: [openvsx_publisher_agreement] + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/PublisherAgreement" + 404: + description: Agreement not found. + 500: + description: Error while retrieving data + post: + tags: + - Publisher Agreement + summary: Create a Publisher Agreement + description: Create an open-vsx.org publisher agreement for the current user. + security: + - OAuth2: [openvsx_publisher_agreement] + requestBody: + description: Required information to sign an open-vsx.org publisher agreement. + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AgreementSigningRequest" + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/PublisherAgreement" + 400: + description: Invalid data + 409: + description: Conflict + 500: + description: Error while processing data + + /publisher_agreement/{ef_username}: + parameters: + - in: path + name: ef_username + required: true + description: The Eclipse username. + schema: + type: string + get: + tags: + - Publisher Agreement + summary: Publisher Agreement for specific user + description: Retrieve the open-vsx.org publisher agreement of a user. The current user can retrieve his own Publisher Agreement but only an admin can retrieve a Publisher Agreement of another user. + security: + - OAuth2: [openvsx_publisher_agreement] + responses: + 200: + description: Success + content: + application/json: + schema: + $ref: "#/components/schemas/PublisherAgreement" + 404: + description: No agreement found for given user. + 500: + description: Error while retrieving data + delete: + tags: + - Publisher Agreement + summary: Delete Publisher Agreement for specific user + description: Delete the open-vsx.org publisher agreement of a user. + security: + - OAuth2: [openvsx_publisher_agreement] + responses: + 204: + description: Accepted + 404: + description: No agreement found for given user. + 500: + description: Error while retrieving data + +components: + securitySchemes: + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: https://accounts.eclipse.org/oauth2/authorize + tokenUrl: https://accounts.eclipse.org/oauth2/token + scopes: + openvsx_publisher_agreement: Submit and revoke your open-vsx.org publisher agreement. + openid: Know who you are on accounts.eclipse.org. + email: View your email address. + profile: View basic information about your account. + + schemas: + PublisherAgreement: + type: object + properties: + PersonID: + type: string + description: The id of the user tied to the publisher agreement. + DocumentID: + type: string + description: The document id. + Version: + type: string + description: The agreement version. + EffectiveDate: + type: string + description: The effective date of the agreement. + ReceivedDate: + type: string + description: The date the agreement was received. + ScannedDocumentBLOB: + type: string + description: The scanned document image. + ScannedDocumentMime: + type: string + description: The scanned document mime type. + ScannedDocumentFileName: + type: string + description: The scanned document file name. + Comments: + type: string + description: Comments on the agreement. + + AgreementSigningRequest: + type: object + required: + - version + - github_handle + properties: + version: + type: string + description: The version number of the document/agreement. + github_handle: + type: string + description: The GitHub username of the user. This must match what the Eclipse Foundation has on file for the user to successfully sign the puglisher agreement. diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm new file mode 100644 index 0000000..c2c9486 --- /dev/null +++ b/src/main/docker/Dockerfile.jvm @@ -0,0 +1,94 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/eclipse-openvsx-api-jvm . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api-jvm +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api-jvm +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 + +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' + + +# We make four distinct layers so if there are application changes the library layers can be re-used +COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/ +COPY --chown=185 target/quarkus-app/*.jar /deployments/ +COPY --chown=185 target/quarkus-app/app/ /deployments/app/ +COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/ + +EXPOSE 8080 +USER 185 +ENV AB_JOLOKIA_OFF="" +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" + diff --git a/src/main/docker/Dockerfile.legacy-jar b/src/main/docker/Dockerfile.legacy-jar new file mode 100644 index 0000000..6651f94 --- /dev/null +++ b/src/main/docker/Dockerfile.legacy-jar @@ -0,0 +1,90 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode +# +# Before building the container image run: +# +# ./mvnw package -Dquarkus.package.type=legacy-jar +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/eclipse-openvsx-api-legacy-jar . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api-legacy-jar +# +# If you want to include the debug port into your docker image +# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005 +# +# Then run the container using : +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api-legacy-jar +# +# This image uses the `run-java.sh` script to run the application. +# This scripts computes the command line to execute your Java application, and +# includes memory/GC tuning. +# You can configure the behavior using the following environment properties: +# - JAVA_OPTS: JVM options passed to the `java` command (example: "-verbose:class") +# - JAVA_OPTS_APPEND: User specified Java options to be appended to generated options +# in JAVA_OPTS (example: "-Dsome.property=foo") +# - JAVA_MAX_MEM_RATIO: Is used when no `-Xmx` option is given in JAVA_OPTS. This is +# used to calculate a default maximal heap memory based on a containers restriction. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xmx` is set to a ratio +# of the container available memory as set here. The default is `50` which means 50% +# of the available memory is used as an upper boundary. You can skip this mechanism by +# setting this value to `0` in which case no `-Xmx` option is added. +# - JAVA_INITIAL_MEM_RATIO: Is used when no `-Xms` option is given in JAVA_OPTS. This +# is used to calculate a default initial heap memory based on the maximum heap memory. +# If used in a container without any memory constraints for the container then this +# option has no effect. If there is a memory constraint then `-Xms` is set to a ratio +# of the `-Xmx` memory as set here. The default is `25` which means 25% of the `-Xmx` +# is used as the initial heap size. You can skip this mechanism by setting this value +# to `0` in which case no `-Xms` option is added (example: "25") +# - JAVA_MAX_INITIAL_MEM: Is used when no `-Xms` option is given in JAVA_OPTS. +# This is used to calculate the maximum value of the initial heap memory. If used in +# a container without any memory constraints for the container then this option has +# no effect. If there is a memory constraint then `-Xms` is limited to the value set +# here. The default is 4096MB which means the calculated value of `-Xms` never will +# be greater than 4096MB. The value of this variable is expressed in MB (example: "4096") +# - JAVA_DIAGNOSTICS: Set this to get some diagnostics information to standard output +# when things are happening. This option, if set to true, will set +# `-XX:+UnlockDiagnosticVMOptions`. Disabled by default (example: "true"). +# - JAVA_DEBUG: If set remote debugging will be switched on. Disabled by default (example: +# true"). +# - JAVA_DEBUG_PORT: Port used for remote debugging. Defaults to 5005 (example: "8787"). +# - CONTAINER_CORE_LIMIT: A calculated core limit as described in +# https://www.kernel.org/doc/Documentation/scheduler/sched-bwc.txt. (example: "2") +# - CONTAINER_MAX_MEMORY: Memory limit given to the container (example: "1024"). +# - GC_MIN_HEAP_FREE_RATIO: Minimum percentage of heap free after GC to avoid expansion. +# (example: "20") +# - GC_MAX_HEAP_FREE_RATIO: Maximum percentage of heap free after GC to avoid shrinking. +# (example: "40") +# - GC_TIME_RATIO: Specifies the ratio of the time spent outside the garbage collection. +# (example: "4") +# - GC_ADAPTIVE_SIZE_POLICY_WEIGHT: The weighting given to the current GC time versus +# previous GC times. (example: "90") +# - GC_METASPACE_SIZE: The initial metaspace size. (example: "20") +# - GC_MAX_METASPACE_SIZE: The maximum metaspace size. (example: "100") +# - GC_CONTAINER_OPTIONS: Specify Java GC to use. The value of this variable should +# contain the necessary JRE command-line options to specify the required GC, which +# will override the default of `-XX:+UseParallelGC` (example: -XX:+UseG1GC). +# - HTTPS_PROXY: The location of the https proxy. (example: "myuser@127.0.0.1:8080") +# - HTTP_PROXY: The location of the http proxy. (example: "myuser@127.0.0.1:8080") +# - NO_PROXY: A comma separated lists of hosts, IP addresses or domains that can be +# accessed directly. (example: "foo.example.com,bar.example.com") +# +### +FROM registry.access.redhat.com/ubi8/openjdk-11:1.11 + +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' + + +COPY target/lib/* /deployments/lib/ +COPY target/*-runner.jar /deployments/quarkus-run.jar + +EXPOSE 8080 +USER 185 +ENV AB_JOLOKIA_OFF="" +ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" +ENV JAVA_APP_JAR="/deployments/quarkus-run.jar" diff --git a/src/main/docker/Dockerfile.native b/src/main/docker/Dockerfile.native new file mode 100644 index 0000000..4893578 --- /dev/null +++ b/src/main/docker/Dockerfile.native @@ -0,0 +1,27 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native -t quarkus/eclipse-openvsx-api . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api +# +### +FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/docker/Dockerfile.native-micro b/src/main/docker/Dockerfile.native-micro new file mode 100644 index 0000000..83eac89 --- /dev/null +++ b/src/main/docker/Dockerfile.native-micro @@ -0,0 +1,30 @@ +#### +# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode. +# It uses a micro base image, tuned for Quarkus native executables. +# It reduces the size of the resulting container image. +# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image. +# +# Before building the container image run: +# +# ./mvnw package -Pnative +# +# Then, build the image with: +# +# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/eclipse-openvsx-api . +# +# Then run the container using: +# +# docker run -i --rm -p 8080:8080 quarkus/eclipse-openvsx-api +# +### +FROM quay.io/quarkus/quarkus-micro-image:1.0 +WORKDIR /work/ +RUN chown 1001 /work \ + && chmod "g+rwX" /work \ + && chown 1001:root /work +COPY --chown=1001:root target/*-runner /work/application + +EXPOSE 8080 +USER 1001 + +CMD ["./application", "-Dquarkus.http.host=0.0.0.0"] diff --git a/src/main/java/org/eclipsefoundation/openvsx/resources/GreetingResource.java b/src/main/java/org/eclipsefoundation/openvsx/resources/GreetingResource.java new file mode 100644 index 0000000..f85612f --- /dev/null +++ b/src/main/java/org/eclipsefoundation/openvsx/resources/GreetingResource.java @@ -0,0 +1,24 @@ +/********************************************************************* +* Copyright (c) 2023 Eclipse Foundation. +* +* This program and the accompanying materials are made +* available under the terms of the Eclipse Public License 2.0 +* which is available at https://www.eclipse.org/legal/epl-2.0/ +* +* Author: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org> +* +* SPDX-License-Identifier: EPL-2.0 +**********************************************************************/ +package org.eclipsefoundation.openvsx.resources; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; + +@Path("/hello") +public class GreetingResource { + + @GET + public String hello() { + return "Hello RESTEasy"; + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/resources/favicon.ico b/src/main/resources/META-INF/resources/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..bb43f009ecaac5bac6feda26839f664145915392 GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x$A1^@s5XP^|L8!TOa(L%QC*<LXo z?g?7LqL1}NB>pS#3+$BO<&EIy;t*kHXJLZr0oe@$^7H?5$aFnjC0}>xiLt!KH$Mf9 z|IsS?|6^1Q{)a2+{&$jA`mZT0c9@rgEeNIuS-)K0>-h@p55Bsp82t}Z()pjRW%j>R z-{yarf$jf%9n1f5s)qml6*T{wh)F*e=H?0yRnlRE>6e}M)lY8X$KS5H4*!7S|Fg8r z|Cd1Zg7lXd*!(Zlv;H5YtoJ`yQTxA%xb$-;86|y?e)%b1gk`6E`)H9n=fke0EB}A~ z@Bt`{8@zh_<p1)Sv;P~2O7;U)G00B-Dla$r`&TCm=l>P{;s0BsQ~r0yr{ly8k%|9n zLu3Cd3kuB!>!0*3QFijT*PGX@{r~XBE!-9($$b0r<-ekU;7qXosb3Z3rhNP6s&Du| z-^B-LcFh0As3e>iWPe?F{C^of{wW~+pm>v=^8J%_&a^kjwrv0Z<>MzLn=qLmH+C16 z{s*RuN|1gK0EVHL?8Hw$9W~7Vg2Epk4pP+muOlM<L`gtM1g0NkhHU@)sj^+qzuD@! z;M5O^f2rHRG#CKVgRCE%{(4?*kZHd8)Ii_$J1G4jyTe{e@xQjP*iK*?wgKq{0c8CU z5n%pHUM4Qva%T}N{R89qBPjig@$f_laB&F1)WP(F%osS#!0<<&f#Cx?1H%JmAZBD> XH~@4Q3I>XS#6j{Pbs+ViXaivYmUJiX literal 0 HcmV?d00001 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..841a003 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,8 @@ +quarkus.http.root-path=/openvsx + +fdndb-api/mp-rest/url=http://localhost:8095 +fdndb-api/mp-rest/scope=javax.inject.Singleton + +quarkus.oidc.enabled=false + +quarkus.log.level=INFO \ No newline at end of file diff --git a/src/test/java/org/eclipsefoundation/openvsx/resources/GreetingResourceTest.java b/src/test/java/org/eclipsefoundation/openvsx/resources/GreetingResourceTest.java new file mode 100644 index 0000000..317b00f --- /dev/null +++ b/src/test/java/org/eclipsefoundation/openvsx/resources/GreetingResourceTest.java @@ -0,0 +1,33 @@ +/********************************************************************* +* Copyright (c) 2023 Eclipse Foundation. +* +* This program and the accompanying materials are made +* available under the terms of the Eclipse Public License 2.0 +* which is available at https://www.eclipse.org/legal/epl-2.0/ +* +* Author: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org> +* +* SPDX-License-Identifier: EPL-2.0 +**********************************************************************/ +package org.eclipsefoundation.openvsx.resources; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +class GreetingResourceTest { + + @Test + void testHelloEndpoint() { + given() + .when().get("/hello") + .then() + .statusCode(200) + .body(is("Hello RESTEasy")); + } + +} \ No newline at end of file diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..8ca4d92 --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,5 @@ +## OIDC Connection/Authentication Info +quarkus.oauth2.enabled=false +quarkus.oidc.enabled=false +quarkus.keycloak.devservices.enabled=false +quarkus.oidc-client.enabled=false \ No newline at end of file -- GitLab