Skip to content

Commit

Permalink
bumping ktlint and resolving conflicts (#1792)
Browse files Browse the repository at this point in the history
Signed-off-by: Sean Li <[email protected]>
  • Loading branch information
sejli authored Feb 6, 2024
1 parent 41ab3eb commit 34f6490
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 26 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ configurations.all {
force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}"
force "org.mockito:mockito-core:${versions.mockito}"
force "org.yaml:snakeyaml:${versions.snakeyaml}"
force "org.slf4j:slf4j-api:2.0.0"
}
}

Expand Down Expand Up @@ -187,7 +188,7 @@ dependencies {
testImplementation "org.mockito:mockito-junit-jupiter:${versions.mockito}"
testImplementation "com.google.code.gson:gson:2.8.9"

ktlint "com.pinterest:ktlint:0.45.0"
ktlint "com.pinterest:ktlint:0.47.1"
}

javadoc.enabled = false // turn off javadoc as it barfs on Kotlin code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class ObservabilityPlugin : Plugin(), ActionPlugin {
): List<RestHandler> {
return listOf(
ObservabilityRestHandler(),
ObservabilityStatsRestHandler(),
ObservabilityStatsRestHandler()
)
}

Expand Down
15 changes: 10 additions & 5 deletions src/main/kotlin/org/opensearch/observability/metrics/Metrics.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,24 @@ enum class Metrics(val metricName: String, val counter: Counter<*>) {
OBSERVABILITY_EXCEPTIONS_VERSION_CONFLICT_ENGINE_EXCEPTION("exception.version_conflict_engine", RollingCounter()),
OBSERVABILITY_EXCEPTIONS_INDEX_NOT_FOUND_EXCEPTION("exception.index_not_found", RollingCounter()),
OBSERVABILITY_EXCEPTIONS_INVALID_INDEX_NAME_EXCEPTION(
"exception.invalid_index_name", RollingCounter()
"exception.invalid_index_name",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_ILLEGAL_ARGUMENT_EXCEPTION(
"exception.illegal_argument", RollingCounter()
"exception.illegal_argument",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_ILLEGAL_STATE_EXCEPTION(
"exception.illegal_state", RollingCounter()
"exception.illegal_state",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_IO_EXCEPTION(
"exception.io", RollingCounter()
"exception.io",
RollingCounter()
),
OBSERVABILITY_EXCEPTIONS_INTERNAL_SERVER_ERROR(
"exception.internal_server_error", RollingCounter()
"exception.internal_server_error",
RollingCounter()
),

OBSERVABILITY_SECURITY_PERMISSION_ERROR("security_permission_error", RollingCounter()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ internal data class SavedQuery(

internal data class Token(
val name: String,
val type: String,
val type: String
) : BaseModel {
internal companion object {
private const val NAME_TAG = "name"
Expand Down Expand Up @@ -291,7 +291,7 @@ internal data class SavedQuery(
*/
constructor(input: StreamInput) : this(
name = input.readString(),
type = input.readString(),
type = input.readString()
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal data class SavedVisualization(
val subType: String?,
val metricType: String? = null,
val unitsOfMeasure: String? = null,
val selectedLabels: SelectedLabels? = null,
val selectedLabels: SelectedLabels? = null
) : BaseObjectData {

internal companion object {
Expand Down Expand Up @@ -155,7 +155,7 @@ internal data class SavedVisualization(
subType,
metricType,
unitsOfMeasure,
selectedLabels,
selectedLabels
)
}
}
Expand Down Expand Up @@ -186,7 +186,7 @@ internal data class SavedVisualization(
subType = input.readString(),
metricType = input.readOptionalString(),
unitsOfMeasure = input.readOptionalString(),
selectedLabels = input.readOptionalWriteable(SelectedLabels.reader),
selectedLabels = input.readOptionalWriteable(SelectedLabels.reader)
)

/**
Expand Down Expand Up @@ -231,7 +231,7 @@ internal data class SavedVisualization(
}

internal data class Token(
val label: String,
val label: String
) : BaseModel {
internal companion object {
private const val LABEL_TAG = "label"
Expand Down Expand Up @@ -276,7 +276,7 @@ internal data class SavedVisualization(
* @param input StreamInput stream to deserialize data from.
*/
constructor(input: StreamInput) : this(
label = input.readString(),
label = input.readString()
)

/**
Expand All @@ -299,7 +299,7 @@ internal data class SavedVisualization(
}

internal data class SelectedLabels(
val labels: List<Token>?,
val labels: List<Token>?
) : BaseModel {
internal companion object {
private const val LABELS_TAG = "labels"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal data class Timestamp(
val name: String?,
val index: String?,
val type: String?,
val dslType: String?,
val dslType: String?
) : BaseObjectData {

internal companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,61 +283,70 @@ internal object PluginSettings {
OPERATION_TIMEOUT_MS_KEY,
defaultSettings[OPERATION_TIMEOUT_MS_KEY]!!.toLong(),
MINIMUM_OPERATION_TIMEOUT_MS,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val JOB_LOCK_DURATION_S: Setting<Int> = Setting.intSetting(
JOB_LOCK_DURATION_S_KEY,
defaultSettings[JOB_LOCK_DURATION_S_KEY]!!.toInt(),
MINIMUM_JOB_LOCK_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MIN_POLLING_DURATION_S: Setting<Int> = Setting.intSetting(
MIN_POLLING_DURATION_S_KEY,
defaultSettings[MIN_POLLING_DURATION_S_KEY]!!.toInt(),
MINIMUM_MIN_POLLING_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MAX_POLLING_DURATION_S: Setting<Int> = Setting.intSetting(
MAX_POLLING_DURATION_S_KEY,
defaultSettings[MAX_POLLING_DURATION_S_KEY]!!.toInt(),
MINIMUM_MAX_POLLING_DURATION_S,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val MAX_LOCK_RETRIES: Setting<Int> = Setting.intSetting(
MAX_LOCK_RETRIES_KEY,
defaultSettings[MAX_LOCK_RETRIES_KEY]!!.toInt(),
MINIMUM_LOCK_RETRIES,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val DEFAULT_ITEMS_QUERY_COUNT: Setting<Int> = Setting.intSetting(
DEFAULT_ITEMS_QUERY_COUNT_KEY,
defaultSettings[DEFAULT_ITEMS_QUERY_COUNT_KEY]!!.toInt(),
MINIMUM_ITEMS_QUERY_COUNT,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val ADMIN_ACCESS: Setting<String> = Setting.simpleString(
ADMIN_ACCESS_KEY,
defaultSettings[ADMIN_ACCESS_KEY]!!,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val FILTER_BY: Setting<String> = Setting.simpleString(
FILTER_BY_KEY,
defaultSettings[FILTER_BY_KEY]!!,
NodeScope, Dynamic
NodeScope,
Dynamic
)

private val IGNORED_ROLES: Setting<List<String>> = Setting.listSetting(
IGNORE_ROLE_KEY,
DEFAULT_IGNORED_ROLES,
{ it },
NodeScope, Dynamic
NodeScope,
Dynamic
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ abstract class PluginRestTestCase : OpenSearchRestTestCase() {
val response = client().performRequest(Request("GET", "/_cat/indices?format=json&expand_wildcards=all"))
val xContentType = MediaType.fromMediaType(response.entity.contentType)
xContentType.xContent().createParser(
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
response.entity.content
).use { parser ->
for (index in parser.list()) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/kotlin/org/opensearch/observability/TestHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ fun constructNotebookRequest(name: String = "test notebook"): String {
}
""".trimIndent()
}

@Suppress("MaxLineLength")
fun constructSavedQueryRequest(name: String = "test saved query"): String {
return """
Expand Down Expand Up @@ -101,6 +102,7 @@ fun constructSavedQueryRequest(name: String = "test saved query"): String {
}
""".trimIndent()
}

@Suppress("MaxLineLength")
fun constructSavedVisualizationRequest(name: String = "test saved visualization"): String {
return """
Expand Down

0 comments on commit 34f6490

Please sign in to comment.