Skip to content

Commit

Permalink
handle both restart and replace params
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Aug 29, 2023
1 parent 6de65f7 commit e566c57
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/io/cryostat/recordings/Recordings.java
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ public LinkedRecordingDescriptor createRecording(
@RestForm String recordingName,
@RestForm String events,
@RestForm Optional<String> replace,
// restart param is deprecated, only 'replace' should be used and takes priority if both
// are provided
@RestForm Optional<Boolean> restart,
@RestForm Optional<Long> duration,
@RestForm Optional<Boolean> toDisk,
@RestForm Optional<Long> maxAge,
Expand Down Expand Up @@ -554,6 +557,15 @@ public LinkedRecordingDescriptor createRecording(
labels.putAll(
mapper.readValue(rawMetadata.get(), Metadata.class).labels);
}
RecordingReplace replacement = RecordingReplace.ALWAYS;
if (replace.isPresent()) {
replacement = RecordingReplace.fromString(replace.get());
} else if (restart.isPresent()) {
replacement =
restart.get()
? RecordingReplace.ALWAYS
: RecordingReplace.NEVER;
}
IConstrainedMap<String> recordingOptions = optionsBuilder.build();
return recordingHelper.startRecording(
target,
Expand All @@ -562,7 +574,7 @@ public LinkedRecordingDescriptor createRecording(
template.getRight(),
new Metadata(labels),
archiveOnStop.orElse(false),
RecordingReplace.fromString(replace.orElse("always")),
replacement,
connection);
});

Expand Down

0 comments on commit e566c57

Please sign in to comment.