Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmeldrum committed Dec 1, 2023
1 parent 560f637 commit 4e48e59
Showing 1 changed file with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ public CommandResult buildTfCommandResult(List<String> jsonLogs) {
.map(this::simplifyApplyCompleteLog)
.toList();

List<Map<String, Object>> errorLogs = getErrorLogs(jsonLogs);
List<Map<String, Object>> errorLogs = jsonLogs.stream()
.map(this::parseTfOutput)
.filter(this::isErrorLog)
.map(this::simplifyApplyErroredLog)
.toList();
;

JobStatus status = CollectionUtils.isEmpty(errorLogs) ? JobStatus.success : JobStatus.error;
return CommandResult.builder()
Expand All @@ -81,16 +86,7 @@ public CommandResult buildTfCommandResult(List<String> jsonLogs) {
.build();

}

private List<Map<String, Object>> getErrorLogs(List<String> jsonLogs) {
return jsonLogs.stream()
.map(this::parseTfOutput)
.filter(this::isErrorLog)
.map(this::simplifyApplyErroredLog)
.toList();
}



private Map<String, Object> parseTfOutput(String json) {
try {
return objectMapper.readValue(json, Map.class);
Expand Down

0 comments on commit 4e48e59

Please sign in to comment.