Skip to content

Commit

Permalink
fix(stats): mpt tracking (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Tomsu committed Jan 10, 2020
1 parent cdffa2b commit 1919549
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public class Pipeline {

@JsonProperty String errorMessage;

@JsonProperty Map<String, String> source;

Trigger trigger;

@JsonPOJOBuilder(withPrefix = "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,18 @@ public void processEvent(Event event) {
Holder.Content content = objectMapper.convertValue(event.getContent(), Holder.Content.class);
Holder.Execution execution = content.getExecution();

// TODO(ttomsu, louisjimenez): Add MPTv1 and v2 execution type detection.
Execution.Type executionType =
Execution.Type.valueOf(
parseEnum(Execution.Type.getDescriptor(), execution.getType().toUpperCase()));

if ("templatedPipeline".equalsIgnoreCase(execution.getSource().getType())) {
if ("v1".equalsIgnoreCase(execution.getSource().getVersion())) {
executionType = Execution.Type.MANAGED_PIPELINE_TEMPLATE_V1;
} else if ("v2".equalsIgnoreCase(execution.getSource().getVersion())) {
executionType = Execution.Type.MANAGED_PIPELINE_TEMPLATE_V2;
}
}

Status executionStatus =
Status.valueOf(parseEnum(Status.getDescriptor(), execution.getStatus().toUpperCase()));

Expand Down Expand Up @@ -274,6 +281,7 @@ public static class Execution {
@Builder.Default private final String type = "UNKNOWN";
@Builder.Default private final String status = "UNKNOWN";
@Builder.Default private final Trigger trigger = Trigger.builder().build();
@Builder.Default private final Source source = Source.builder().build();
@Builder.Default private final List<Stage> stages = new ArrayList<>();

@JsonPOJOBuilder(withPrefix = "")
Expand All @@ -291,6 +299,18 @@ public static class Trigger {
public static class TriggerBuilder {}
}

@Getter
@Builder
@JsonDeserialize(builder = Source.SourceBuilder.class)
public static class Source {

private final String type;
private final String version;

@JsonPOJOBuilder(withPrefix = "")
public static class SourceBuilder {}
}

@Getter
@Builder
@JsonDeserialize(builder = Stage.StageBuilder.class)
Expand Down

0 comments on commit 1919549

Please sign in to comment.