Skip to content

Commit

Permalink
DATAGO-90245 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rudraneel-chakraborty committed Dec 4, 2024
1 parent b1379c1 commit 4afb13a
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.util.CollectionUtils;

import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -48,19 +49,21 @@ public CommandResult buildTfStateFileDeletionFailureResult(RuntimeException root
.build();
}

public CommandResult buildTfCommandResult(List<String> jsonLogs) {
public CommandResult buildTfCommandResult(List<String> logsInJsonFormat) {

if (CollectionUtils.isEmpty(jsonLogs)) {
if (CollectionUtils.isEmpty(logsInJsonFormat)) {
throw new IllegalArgumentException("No terraform logs were collected. Unable to process response.");
}

List<Map<String, Object>> successLogs = jsonLogs.stream()
// Copy the list to avoid modifying the original and to avoid concurrent modification exceptions
List<String> jsonLogsCopy = new ArrayList<>(logsInJsonFormat);
List<Map<String, Object>> successLogs = jsonLogsCopy.stream()
.map(this::parseTfOutput)
.filter(this::isApplyCompleteLog)
.map(this::simplifyApplyCompleteLog)
.toList();

List<Map<String, Object>> errorLogs = jsonLogs.stream()
List<Map<String, Object>> errorLogs = jsonLogsCopy.stream()
.map(this::parseTfOutput)
.filter(this::isErrorLog)
.map(this::simplifyApplyErroredLog)
Expand Down

0 comments on commit 4afb13a

Please sign in to comment.