-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding constructor with optional comments indices args #674
Changes from 1 commit
38248a4
6a15e38
6dbc9f6
939cbd4
25692f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ data class DataSources( | |
val alertsHistoryIndexPattern: String? = "<.opendistro-alerting-alert-history-{now/d}-1>", // AlertIndices.ALERT_HISTORY_INDEX_PATTERN | ||
|
||
/** Configures a custom index alias to store comments associated with alerts.*/ | ||
val commentsIndex: String = ".opensearch-alerting-comments-history-write", // AlertIndices.COMMENTS_HISTORY_WRITE_INDEX | ||
val commentsIndex: String? = ".opensearch-alerting-comments-history-write", // AlertIndices.COMMENTS_HISTORY_WRITE_INDEX | ||
|
||
/** Configures a custom index pattern for commentsIndex alias.*/ | ||
val commentsIndexPattern: String? = "<.opensearch-alerting-comments-history-{now/d}-1>", // AlertIndices.COMMENTS_HISTORY_INDEX_PATTERN | ||
|
@@ -56,9 +56,6 @@ data class DataSources( | |
require(alertsIndex.isNotEmpty()) { | ||
"Alerts index cannot be empty" | ||
} | ||
require(commentsIndex.isNotEmpty()) { | ||
"Comments index cannot be empty" | ||
} | ||
if (queryIndexMappingsByType.isNotEmpty()) { | ||
require(queryIndex != ScheduledJob.DOC_LEVEL_QUERIES_INDEX) { | ||
"Custom query index mappings are configurable only if a custom query index is configured too." | ||
|
@@ -89,6 +86,29 @@ data class DataSources( | |
findingsEnabled = sin.readOptionalBoolean() | ||
) | ||
|
||
@Throws(IOException::class) | ||
constructor( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comments index should be using readOptionalString(), writeOptionalString, null check in parsing etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updating readOptional and writeOptional, parse adds an empty string placeholder for any comments that don't exist in the XContent, so leaving that be |
||
queryIndex: String, | ||
findingsIndex: String, | ||
findingsIndexPattern: String?, | ||
alertsIndex: String, | ||
alertsHistoryIndex: String?, | ||
alertsHistoryIndexPattern: String?, | ||
queryIndexMappingsByType: Map<String, Map<String, String>>, | ||
findingsEnabled: Boolean? | ||
) : this( | ||
queryIndex = queryIndex, | ||
findingsIndex = findingsIndex, | ||
findingsIndexPattern = findingsIndexPattern, | ||
alertsIndex = alertsIndex, | ||
alertsHistoryIndex = alertsHistoryIndex, | ||
alertsHistoryIndexPattern = alertsHistoryIndexPattern, | ||
commentsIndex = null, | ||
commentsIndexPattern = null, | ||
queryIndexMappingsByType = queryIndexMappingsByType, | ||
findingsEnabled = findingsEnabled | ||
) | ||
|
||
@Suppress("UNCHECKED_CAST") | ||
fun asTemplateArg(): Map<String, Any?> { | ||
return mapOf( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we expecting IoException?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing