Skip to content

Commit

Permalink
Backwards compatibility on LstProvenance
Browse files Browse the repository at this point in the history
  • Loading branch information
jkschneider committed Aug 9, 2023
1 parent 528b04f commit a829964
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public Tree preVisit(Tree tree, ExecutionContext ctx) {
if (lstProvenance == null) {
return tree;
}
if(acc.seenProvenance.add(lstProvenance)) {
if (acc.seenProvenance.add(lstProvenance)) {
provenanceTable.insertRow(ctx, new LstProvenanceTable.Row(lstProvenance.getBuildToolType(),
lstProvenance.getBuildToolVersion(), lstProvenance.getLstSerializerVersion(),
lstProvenance.getTimestampUtc().toEpochMilli(), lstProvenance.getTimestampUtc().atZone(UTC).toString()));
lstProvenance.getTimestampUtc() == null ? null : lstProvenance.getTimestampUtc().toEpochMilli(),
lstProvenance.getTimestampUtc() == null ? null : lstProvenance.getTimestampUtc().atZone(UTC).toString()));
}
return tree;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import lombok.EqualsAndHashCode;
import lombok.Value;
import lombok.With;
import org.openrewrite.internal.lang.Nullable;

import java.time.Instant;
import java.util.UUID;
Expand All @@ -31,6 +32,11 @@ public class LstProvenance implements Marker {
Type buildToolType;
String buildToolVersion;
String lstSerializerVersion;

/**
* Nullable for backwards compatibility with older LSTs.
*/
@Nullable
Instant timestampUtc;

public enum Type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.openrewrite.Column;
import org.openrewrite.DataTable;
import org.openrewrite.Recipe;
import org.openrewrite.internal.lang.Nullable;
import org.openrewrite.marker.LstProvenance;

@JsonIgnoreType
Expand Down Expand Up @@ -47,10 +48,12 @@ public static class Row {

@Column(displayName = "Timestamp (epoch millis)",
description = "UTC timestamp describing when the LST was produced, in milliseconds since the unix epoch.")
long timestampEpochMillis;
@Nullable
Long timestampEpochMillis;

@Column(displayName = "Timestamp",
description = "UTC timestamp describing when the LST was produced, in ISO-8601 format. e.g.: \"2023‐08‐07T22:24:06+00:00 UTC+00:00\"")
@Nullable
String timestampUtc;
}
}

0 comments on commit a829964

Please sign in to comment.