├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── bin ├── schema-manager-deploy.sh ├── schema-manager-status-check.sh └── schema-manager-validate-pr.sh ├── doc ├── configurations.md └── images │ ├── SchemaManager-DeploymentModes.png │ └── SchemaManager-PrValidationFlow.png ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── amazonaws │ │ └── schemamanager │ │ ├── AvroSchemaSM.java │ │ ├── ISchemaManagerRunner.java │ │ ├── SchemaManagerBuildValidator.java │ │ ├── SchemaManagerMain.java │ │ ├── SchemaManagerMode.java │ │ ├── SchemaManagerPrValidator.java │ │ ├── SchemaManagerRunnerFactory.java │ │ ├── SchemaManagerTask.java │ │ ├── analyze │ │ ├── ISchemaAnalyzer.java │ │ ├── SchemaAnalyzerFactory.java │ │ ├── SchemaAnalyzerImpl.java │ │ ├── ValidationError.java │ │ └── types │ │ │ ├── CheckChangesRequest.java │ │ │ ├── CheckChangesResponse.java │ │ │ ├── CompatibilityError.java │ │ │ └── SchemaPair.java │ │ ├── properties │ │ ├── AnalyzerConfig.java │ │ ├── AppConfig.java │ │ ├── AppConfigHelper.java │ │ ├── IRepoClientConfig.java │ │ ├── LocalRepoClientConfig.java │ │ ├── RegistryClientConfig.java │ │ ├── RepoClientConfig.java │ │ └── ReporterConfig.java │ │ ├── registry │ │ ├── IRegistryClient.java │ │ ├── RegistryClientFactory.java │ │ ├── SchemaRegistryClient.java │ │ └── Subject.java │ │ ├── repo │ │ ├── BitBucketRepoClient.java │ │ ├── FileSystemRepoClient.java │ │ ├── IRepoClient.java │ │ ├── RepoClientFactory.java │ │ ├── RepoUtils.java │ │ └── datatypes │ │ │ ├── DefaultSchemaMetadata.java │ │ │ ├── RepoSchema.java │ │ │ └── RepoSchemaMetadata.java │ │ ├── reports │ │ ├── ISchemaManagerReporter.java │ │ ├── ReportRecord.java │ │ ├── SchemaManagerReporterFactory.java │ │ ├── SchemaManagerReporterImpl.java │ │ └── SchemaManagerReporterS3.java │ │ └── utils │ │ └── ProtobufParser.java └── resources │ ├── conf │ ├── deployer_config.yml │ ├── pr_validation_config.yml │ └── reporter_config.yml │ └── sample_conf.yml └── test ├── java └── com │ └── amazonaws │ └── schemamanager │ ├── TestAvroSchema.java │ ├── TestSchemaManagerMain.java │ └── registry │ └── TestSchemaRegistryClientIT.java └── resources ├── deployer_config.yml ├── pr_validation_config.yml └── reporter_config.yml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Execution Mode 16 | 2. Configuration details 17 | 3. See error 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Available Workarounds** 23 | Describe how to avoid the issue 24 | 25 | **Screenshots** 26 | If applicable, add screenshots to help explain your problem. 27 | 28 | **Logs** 29 | If applicable, add logs to help explain your problem. 30 | 31 | **Environment (please complete the following information):** 32 | - OS: [e.g. MacOS, Linux, Windows] 33 | - Version [e.g. 22] 34 | - Java Version 35 | - Schema Registry Provider 36 | - Schema Type [Avro, Protobuf, JSON] 37 | 38 | **Additional context** 39 | Add any other context about the problem here. 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | .DS_Store 3 | .classpath 4 | .project 5 | .settings 6 | .metadata 7 | .vscode 8 | .idea 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /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 | 43 | ## Finding contributions to work on 44 | 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. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | 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. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Schema Manager 2 | 3 | ## Overview 4 | 5 | Enterprises building event-driven systems or data buses using streaming technologies like Apache Kafka or Kinesis Data Streams, leverage schemas. Schemas (Apache Avro, Protobuf) define data payloads between these disparate systems/applications, ensuring that producers and consumers understand the data. Schema Registries store schemas and enforce compatibility between each schema version. Validating and deploying schemas to a schema registry is often decoupled from development of applications that use the schema. This leads to manual build and deploy processes of schemas between source repository and schema registry. 6 | Schema Manager automates this synchronization. Schema Manager assists enterprises in validating and deploying schemas between Schema Registries and source control repositories. 7 | 8 | 9 | ### Features 10 | 11 | - Local development validation 12 | - Pull Request validation 13 | - Build validation 14 | - Diff between Git-based repository and runtime SR instance, including compatibility tests 15 | - Deploy changes from the schema repository to the Schema Registry instance 16 | 17 | 18 | ### Road Map Features 19 | 20 | - Glue Schema Registry implementation 21 | - Full Protobuf and Json support 22 | - Dynamic reporting schema support 23 | 24 | ## Setup 25 | 26 | 1. Clone the project from the repository 27 | `git clone /amak-schema-manager.git` 28 | 2. `cd amak-schema-manager` 29 | 3. Build: `mvn clean install -DskipTests` 30 | 4. `chmod +x target/bin/*.sh` 31 | 5. Update `conf/*` relevant files with the environment specific endpoints for BitBucket, Schema Regsitry, etc. 32 | 33 | Copy `target/*` to a target environment. Or execute from this directory. 34 | 35 | ## Getting Started 36 | This guide assumes that you have an S3 bucket created and have access to this S3 bucket from the machine that will be executing Schema Manager. Necessary permissions are Put and Get 37 | 38 | ### Step 1 39 | Configure config file. Using the given [parameters](/doc/configurations.md) update the config file to match your needed setup. 40 | 41 | ### Step 2 42 | Now that your configuration file is created, you are ready to run Schema Manager. Below are the three modes to run schema manager in: 43 | 44 | #### Pull Request Validation (PR validation) 45 | In this mode, Schema Manager will validate a schema against both the master branch version of the schema and what is currently deployed in Schema Registry with the schema that is being purposed inside of the pull request. This ensures that the proposed schema is compatible and that the master branch and schema registry remain in-sync. 46 | 47 | #### Schema Deployer 48 | In this mode, Schema Manager can consume and deploy all schemas found inside of a repository to a Schema Registry. This mode is useful for tasks like migrating schemas to new environments or clusters. 49 | 50 | #### Status Check 51 | In this mode, Schema Manager verifies or does a status check on the schemas specified in the configuration and compares the repository schemas to what is inside of Schema Registry. It will output any differences between the two sources. 52 | 53 | ### Step 3 54 | Once the mode is chosen you can either call java class directly with the parameters or create a shell script with the necessary parameters to pass. 55 | Examples: 56 | - [Deployer Config](/bin/schema-manager-deploy.sh) 57 | - [PR Validator](/bin/schema-manager-validate-pr.sh) 58 | - [Status Check](/bin/schema-manager-status-check.sh) 59 | 60 | ### Step 4 61 | Review logs for errors and warnings. Any error in processing of a schema or Schema Manager's inability to do so will be logged. If you did not have errors you can check your s3 bucket for the data generated. 62 | 63 | # Security 64 | 65 | See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information. 66 | 67 | 68 | # License 69 | [Apache-2.0 LICENSE](LICENSE) 70 | 71 | 72 | -------------------------------------------------------------------------------- /bin/schema-manager-deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(dirname "$0") 4 | 5 | java -cp "$BASEDIR/../schemamanager-0.0.1-SNAPSHOT.jar:$BASEDIR/../lib/*" \ 6 | com.amazonaws.schemamanager.SchemaManagerMain -m full -c $BASEDIR/../conf/deployer_config.yml -------------------------------------------------------------------------------- /bin/schema-manager-status-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(dirname "$0") 4 | 5 | java -cp "$BASEDIR/../schemamanager-0.0.1-SNAPSHOT.jar:$BASEDIR/../lib/*" \ 6 | com.amazonaws.schemamanager.SchemaManagerMain -m full -c $BASEDIR/../conf/reporter_config.yml -------------------------------------------------------------------------------- /bin/schema-manager-validate-pr.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | BASEDIR=$(dirname "$0") 4 | 5 | java -cp "$BASEDIR/../schemamanager-0.0.1-SNAPSHOT.jar:$BASEDIR/../lib/*" \ 6 | com.amazonaws.schemamanager.SchemaManagerMain -m pr -c $BASEDIR/../conf/pr_validation_config.yml -------------------------------------------------------------------------------- /doc/configurations.md: -------------------------------------------------------------------------------- 1 | ## Setup Conf file 2 | - Application Name – Name of schema manager application that will be deployed 3 | - Application instance ID 4 | - Environment – Environment where application is to be deployed 5 | - Repo Client Class - Type of repository and the associated class where schemas will live. This tells the application what type of repo client to build while executing 6 | - Registry Client Class – Type of Registry that the schema will be published to or evaluated against. Currently supported is Confluent Schema Registry. 7 | - Reporter Class – Type of reporting mechanism (S3) where the data output from the application is sent 8 | - Analyzer Class – Type of analyzer for the application to use 9 | - Deploy - Boolean to say if you want the schemas in the repository to be deployed into the schema registry. If not provided, defaults to false 10 | ### Repo Client Properties 11 | - Repo Endpoint – URL of the repository to use for schemas. 12 | - Base Info – Base of the URL where schema manager should begin its traversing. Default scopes are important to pay attention to when setting base info 13 | - Path Prefix – Specific paths for Schema Manager to walk 14 | - Credentials – Credentials for Schema Manager to use to authenticate to Repository 15 | - Subject Name Pattern – Pattern for Schema Manager to use to identify subjects 16 | - Schema Name Pattern – Patter for Schema Manager to use to identify schemas 17 | ### Local Repo Client Properties 18 | - Base Info – Base of schema directory Schema Manager should use to walk on the local file system. 19 | ### Registry Client Properties 20 | - Registry Endpoint – URL of the Registry endpoint. 21 | ### Analyzer Properties 22 | - Default Compatibility – Default compatibility for schema manager to use if no other default at the schema, subject, or directory level are provided. Options are NONE, BACKWARD, BACKWARD_TRANSITIVE, FORWARD, FORWARD_TRANSITIVE, FULL, FULL_TRANSITIVE. Read more about compatibility types [here](https://docs.confluent.io/platform/current/schema-registry/avro.html) 23 | - Allow Schema Name Duplicates - if allowed schemas sharing the same name are allowed to exist within the same registry 24 | ### Reporter Properties 25 | - Bucket Name – Name of S3 bucket where data from Schema Manager should be written 26 | - Prefix Directory – Name of Directory for Schema Manager to write data to 27 | - File Name Pattern – Pattern Schema Manager should use when creating objects inside of the bucket. 28 | -------------------------------------------------------------------------------- /doc/images/SchemaManager-DeploymentModes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/schema-manager/2b448aec7dc1b10b9dcefdc699a4c84286f805d3/doc/images/SchemaManager-DeploymentModes.png -------------------------------------------------------------------------------- /doc/images/SchemaManager-PrValidationFlow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/awslabs/schema-manager/2b448aec7dc1b10b9dcefdc699a4c84286f805d3/doc/images/SchemaManager-PrValidationFlow.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | com.amazonaws 6 | schemamanager 7 | 0.1.0 8 | SchemaManager 9 | 10 | 1.8 11 | 1.8 12 | UTF-8 13 | 1.7.30 14 | 6.1.1 15 | 7.7.1 16 | 17 | 18 | 19 | 20 | confluent 21 | https://packages.confluent.io/maven/ 22 | 23 | 24 | jcenter 25 | https://jcenter.bintray.com/ 26 | 27 | 28 | 29 | 30 | 31 | io.confluent 32 | kafka-schema-registry-client 33 | ${confluent_sr_version} 34 | 35 | 36 | io.confluent 37 | kafka-schema-registry 38 | ${confluent_sr_version} 39 | 40 | 41 | io.confluent 42 | kafka-avro-serializer 43 | ${confluent_sr_version} 44 | 45 | 46 | io.confluent 47 | kafka-protobuf-serializer 48 | ${confluent_sr_version} 49 | 50 | 51 | io.confluent 52 | kafka-json-serializer 53 | ${confluent_sr_version} 54 | 55 | 56 | org.yaml 57 | snakeyaml 58 | 2.0 59 | 60 | 61 | commons-cli 62 | commons-cli 63 | 1.4 64 | 65 | 66 | commons-io 67 | commons-io 68 | 2.8.0 69 | 70 | 71 | org.apache.commons 72 | commons-lang3 73 | 3.12.0 74 | 75 | 76 | org.slf4j 77 | slf4j-api 78 | ${slf4jVersion} 79 | compile 80 | 81 | 82 | org.slf4j 83 | slf4j-simple 84 | ${slf4jVersion} 85 | 86 | 87 | org.junit.jupiter 88 | junit-jupiter-engine 89 | 5.4.0 90 | test 91 | 92 | 93 | org.eclipse.jgit 94 | org.eclipse.jgit 95 | 6.6.1.202309021850-r 96 | 97 | 98 | org.eclipse.jgit 99 | org.eclipse.jgit.ssh.jsch 100 | 5.11.0.202103091610-r 101 | 102 | 103 | com.amazonaws 104 | aws-java-sdk-s3 105 | 1.12.261 106 | 107 | 108 | 109 | 110 | 111 | 112 | maven-dependency-plugin 113 | 114 | 115 | install 116 | 117 | copy-dependencies 118 | 119 | 120 | ${project.build.directory}/lib 121 | 122 | 123 | 124 | 125 | 126 | maven-resources-plugin 127 | 128 | 129 | copy-resources-conf 130 | 131 | validate 132 | 133 | copy-resources 134 | 135 | 136 | ${project.build.directory}/conf 137 | 138 | 139 | src/main/resources/conf 140 | true 141 | 142 | 143 | 144 | 145 | 146 | copy-bin 147 | validate 148 | 149 | copy-resources 150 | 151 | 152 | ${project.build.directory}/bin 153 | 154 | 155 | bin 156 | true 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | org.codehaus.mojo 165 | exec-maven-plugin 166 | 1.2.1 167 | 168 | 169 | soft-link 170 | install 171 | 172 | exec 173 | 174 | 175 | cp 176 | 177 | ${project.build.directory}/${artifactId}-${version}.jar 178 | ${project.build.directory}/${artifactId}.jar 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/schemamanager/AvroSchemaSM.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.schemamanager; 2 | 3 | import java.util.Map; 4 | import java.util.Objects; 5 | 6 | import org.apache.avro.Schema; 7 | import org.apache.avro.Schema.Parser; 8 | 9 | import io.confluent.kafka.schemaregistry.avro.AvroSchema; 10 | 11 | /** 12 | * Represents an Avro Schema that also holds known references in a Map. 13 | */ 14 | public class AvroSchemaSM extends AvroSchema { 15 | 16 | private static Schema.Parser parser; 17 | 18 | public AvroSchemaSM(String schemaObj) { 19 | super(schemaObj); 20 | } 21 | 22 | @Override 23 | protected Parser getParser() { 24 | return getStaticParser(); 25 | } 26 | 27 | private static Parser getStaticParser() { 28 | if (parser != null) 29 | return parser; 30 | 31 | parser = new Schema.Parser(); 32 | parser.setValidateDefaults(true); 33 | parser.setValidate(true); 34 | return parser; 35 | } 36 | 37 | public static void initParser(Map knownTypes) { 38 | parser = new Schema.Parser(); 39 | parser.addTypes(knownTypes); 40 | parser.setValidateDefaults(true); 41 | } 42 | 43 | public static Map getTypes() { 44 | return parser.getTypes(); 45 | } 46 | 47 | @Override 48 | public String name() { 49 | String name = super.name(); 50 | if (name == null && this.rawSchema() != null) { 51 | name = this.rawSchema().getFullName(); 52 | } 53 | return name; 54 | } 55 | 56 | @Override 57 | public boolean equals(Object o) { 58 | if (this == o) { 59 | return true; 60 | } 61 | if (o == null || !(o instanceof AvroSchema)) { 62 | return false; 63 | } 64 | // if (o == null || getClass() != o.getClass()) { 65 | // return false; 66 | // } 67 | AvroSchema that = (AvroSchema) o; 68 | // Can't use schemaObj as it doesn't compare field doc, aliases, etc. 69 | return Objects.equals( 70 | canonicalString(), that.canonicalString()) 71 | && Objects.equals(references(), that.references()) 72 | && Objects.equals(version(), that.version()); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/schemamanager/ISchemaManagerRunner.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.schemamanager; 2 | 3 | public interface ISchemaManagerRunner { 4 | public void run() throws Exception; 5 | } 6 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/schemamanager/SchemaManagerBuildValidator.java: -------------------------------------------------------------------------------- 1 | package com.amazonaws.schemamanager; 2 | 3 | public class SchemaManagerBuildValidator implements ISchemaManagerRunner{ 4 | 5 | public void run() { 6 | 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/com/amazonaws/schemamanager/SchemaManagerMain.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [yyyy] [name of copyright owner] 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | 18 | package com.amazonaws.schemamanager; 19 | 20 | import java.io.IOException; 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | import org.apache.commons.cli.CommandLine; 25 | import org.apache.commons.cli.CommandLineParser; 26 | import org.apache.commons.cli.DefaultParser; 27 | import org.apache.commons.cli.HelpFormatter; 28 | import org.apache.commons.cli.MissingOptionException; 29 | import org.apache.commons.cli.Option; 30 | import org.apache.commons.cli.Options; 31 | import org.apache.commons.cli.ParseException; 32 | 33 | import com.amazonaws.schemamanager.properties.AppConfigHelper; 34 | 35 | public class SchemaManagerMain { 36 | 37 | private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(SchemaManagerMain.class); 38 | 39 | private static final String PROP_NAME_HELP_SHORT = "h"; 40 | private static final String PROP_NAME_HELP_FULL = "help"; 41 | 42 | private static final String PROP_NAME_CONFIG_FILE_SHORT = "c"; 43 | private static final String PROP_NAME_CONFIG_FILE_FULL = "config-file"; 44 | private static final String PROP_NAME_MODE_SHORT = "m"; 45 | private static final String PROP_NAME_MODE_FULL = "mode"; 46 | 47 | private static SchemaManagerMode mode; 48 | 49 | public static void main(String[] args) throws Exception{ 50 | int result = init(args); 51 | if (result > 0) throw new RuntimeException("SchemaManager error code: " + result); 52 | if (result == 0) return; 53 | 54 | ISchemaManagerRunner schemaManager = null; 55 | switch(mode) { 56 | case PR_VALIDATION:{ 57 | schemaManager = new SchemaManagerPrValidator(); 58 | break; 59 | } 60 | case BUILD_VALIDATION:{ 61 | throw new Exception("Build validation is not implemented yet"); 62 | } 63 | case FULL: { 64 | schemaManager = new SchemaManagerTask(); 65 | break; 66 | // throw new Exception("Full mode is not implemented yet"); 67 | } 68 | default:{ 69 | printHelp(options); 70 | } 71 | } 72 | 73 | schemaManager.run(); 74 | } 75 | 76 | private static Options options; 77 | private static int init(String[] args) { 78 | options = new Options(); 79 | options.addOption(Option.builder(PROP_NAME_HELP_SHORT) 80 | .argName(PROP_NAME_HELP_SHORT) 81 | .longOpt(PROP_NAME_HELP_FULL) 82 | .desc("prints this message") 83 | .build() 84 | ); 85 | options.addOption(Option.builder(PROP_NAME_CONFIG_FILE_SHORT) 86 | .argName(PROP_NAME_CONFIG_FILE_SHORT) 87 | .longOpt(PROP_NAME_CONFIG_FILE_FULL) 88 | .hasArg(true) 89 | .desc("YAML property file with Schema Manager configuration. " 90 | + "For sample, see sample_config.yml under src/main/resources.") 91 | .build() 92 | ); 93 | options.addOption(Option.builder(PROP_NAME_MODE_SHORT) 94 | .argName(PROP_NAME_MODE_SHORT) 95 | .longOpt(PROP_NAME_MODE_FULL) 96 | .hasArg(true) 97 | .desc("define a scenario. Valid values are: `full` - for integrated full sync execution with reporting; " 98 | + "`pr` - validate Pull Requests; `build` - run to validate post PR merge integrity and generate artifacts. " 99 | + "Default (if not provided) is `full`.") 100 | .build() 101 | ); 102 | 103 | CommandLineParser parser = new DefaultParser(); 104 | try { 105 | // parse the command line arguments 106 | CommandLine line = parser.parse( options, args ); 107 | if (line.hasOption(PROP_NAME_HELP_SHORT)) { 108 | printHelp(options); 109 | return 0; 110 | }else if (!line.hasOption(PROP_NAME_CONFIG_FILE_SHORT)){ 111 | printHelp(options); 112 | List