Skip to content

Commit

Permalink
check backward compatibility (#74)
Browse files Browse the repository at this point in the history
* check backward compatibility

* revert name
  • Loading branch information
ananthdurai authored May 8, 2023
1 parent 13f426e commit 2958585
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Binary file added .DS_Store
Binary file not shown.
18 changes: 13 additions & 5 deletions src/main/java/org/schemata/SchemataExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,23 @@ public int document()
}

@Command(description = "Check if schema is backward compatible")
public boolean isBackwardCompatible() {
public int isBackwardCompatible() {
var checker = getSchemaCompatibilityChecker();
return checker.check(basePath, path).isCompatible();
return checker.check(basePath, path).isCompatible() ? 0 : 1;
}

@Command(description = "Print the backward compatibility summary with incompatible fields")
public Set<Summary> compatibilitySummary() {
var checker = getSchemaCompatibilityChecker();
return checker.check(basePath, path).summary();
public int compatibilitySummary() {
var checker = getSchemaCompatibilityChecker().check(basePath, path);
if (checker.isCompatible()) {
System.out.println("Schema is backward compatible");
return 0;
} else {
System.out.println("Schema is not backward compatible");
System.out.println("Incompatible fields:");
checker.summary().forEach(System.out::println);
return 1;
}
}

public SchemaParser getSchemaParser() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/schema/product.proto
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ message ProductEvent {

ActivityType activity_type = 3
[(field_core).description = "Lifecycle event type for the Product table"];
}
}

0 comments on commit 2958585

Please sign in to comment.