Skip to content

Commit 3429bfe

Browse files
committed
Merge branch '873-service-plan-schemas' into 2.x
2 parents e86d2e8 + 78718ff commit 3429bfe

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/DefaultApplications.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ public final class DefaultApplications implements Applications {
149149

150150
private static final int CF_STAGING_TIME_EXPIRED = 170007;
151151

152+
private static final String[] ENTRY_FIELDS_CRASH = {"index", "reason", "exit_description"};
153+
154+
private static final String[] ENTRY_FIELDS_NORMAL = {"instances", "memory", "state", "environment_json"};
155+
152156
private static final Comparator<LogMessage> LOG_MESSAGE_COMPARATOR = Comparator.comparing(LogMessage::getTimestamp);
153157

154158
private static final Duration LOG_MESSAGE_TIMESPAN = Duration.ofMillis(500);
@@ -665,7 +669,7 @@ private static ApplicationEvent convertToApplicationEvent(EventResource resource
665669
}
666670
return ApplicationEvent.builder()
667671
.actor(entity.getActorName())
668-
.description(eventDescription(getMetadataRequest(entity), "instances", "memory", "state", "environment_json"))
672+
.description(eventDescription(getMetadataRequest(entity), getEntryNames(entity.getType())))
669673
.id(ResourceUtils.getId(resource))
670674
.event(entity.getType())
671675
.time(timestamp)
@@ -851,6 +855,10 @@ private static String getDomainId(List<DomainSummary> availableDomains, String d
851855
.orElseThrow(() -> new IllegalArgumentException(String.format("Domain %s not found", domainName)));
852856
}
853857

858+
private static String[] getEntryNames(String type) {
859+
return type.contains("crash") ? ENTRY_FIELDS_CRASH : ENTRY_FIELDS_NORMAL;
860+
}
861+
854862
private static Map<String, Object> getEnvironment(AbstractApplicationResource resource) {
855863
return ResourceUtils.getEntity(resource).getEnvironmentJsons();
856864
}
@@ -880,6 +888,9 @@ private static Map<String, Object> getMetadataRequest(EventEntity entity) {
880888
return metadata.get("request")
881889
.map(m -> (Map<String, Object>) m)
882890
.orElse(Collections.emptyMap());
891+
} else if (metadata.get("instance") != null) {
892+
return metadata.entrySet().stream()
893+
.collect(Collectors.toMap(Map.Entry::getKey, v -> v.getValue().orElse("")));
883894
} else {
884895
return Collections.emptyMap();
885896
}

0 commit comments

Comments
 (0)