From 5c55e8e9557c9b515f91816f8cd0ceae24ef06e1 Mon Sep 17 00:00:00 2001 From: "radoslaw.chrzanowski" Date: Fri, 27 Dec 2024 11:17:59 +0100 Subject: [PATCH] fix checkstyles --- .../envoycontrol/groups/NodeMetadata.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt index 0fcf1452d..356053ac3 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt @@ -73,7 +73,6 @@ data class ProxySettings( ) } - fun Value.toPathNormalization(snapshotProperties: SnapshotProperties): PathNormalizationPolicy { return PathNormalizationPolicy( normalizationEnabled = this.field("enabled")?.boolValue ?: snapshotProperties.pathNormalization.enabled, @@ -82,6 +81,7 @@ fun Value.toPathNormalization(snapshotProperties: SnapshotProperties): PathNorma ?: snapshotProperties.pathNormalization.pathWithEscapedSlashesAction ) } + fun getPathNormalization(proto: Value?, snapshotProperties: SnapshotProperties): PathNormalizationPolicy { val defaultNormalizationConfig = PathNormalizationPolicy( snapshotProperties.pathNormalization.enabled, @@ -366,7 +366,7 @@ fun Value?.toIncoming(properties: SnapshotProperties): Incoming { rateLimitEndpoints = rateLimitEndpointsField.orEmpty().map(Value::toIncomingRateLimitEndpoint), // if there is no endpoint field defined in metadata, we allow for all traffic permissionsEnabled = endpointsField != null, - pathNormalizationPolicy = this?.field("path_normalization")?.toPathNormalization(properties), + pathNormalizationPolicy = this?.field("path_normalization")?.toPathNormalization(properties), healthCheck = this?.field("healthCheck").toHealthCheck(), roles = this?.field("roles")?.list().orEmpty().map { Role(it) }, timeoutPolicy = this?.field("timeoutPolicy").toIncomingTimeoutPolicy(), @@ -412,7 +412,8 @@ fun Value.toIncomingEndpoint(properties: SnapshotProperties): IncomingEndpoint { if (isMoreThanOnePropertyDefined(paths, path, pathPrefix, pathRegex)) { throw NodeMetadataValidationException( - "Precisely one of 'paths', 'path', 'pathPrefix' or 'pathRegex' field is allowed") + "Precisely one of 'paths', 'path', 'pathPrefix' or 'pathRegex' field is allowed" + ) } val methods = this.field("methods")?.list().orEmpty().map { it.stringValue }.toSet() @@ -422,9 +423,13 @@ fun Value.toIncomingEndpoint(properties: SnapshotProperties): IncomingEndpoint { return when { paths.isNotEmpty() -> IncomingEndpoint( - paths, "", PathMatchingType.PATH, methods, clients, unlistedClientsPolicy, oauth) + paths, "", PathMatchingType.PATH, methods, clients, unlistedClientsPolicy, oauth + ) + path != null -> IncomingEndpoint( - paths, path, PathMatchingType.PATH, methods, clients, unlistedClientsPolicy, oauth) + paths, path, PathMatchingType.PATH, methods, clients, unlistedClientsPolicy, oauth + ) + pathPrefix != null -> IncomingEndpoint( paths, pathPrefix, PathMatchingType.PATH_PREFIX, methods, clients, unlistedClientsPolicy, oauth ) @@ -434,7 +439,8 @@ fun Value.toIncomingEndpoint(properties: SnapshotProperties): IncomingEndpoint { ) else -> throw NodeMetadataValidationException( - "One of 'paths', 'path', 'pathPrefix' or 'pathRegex' field is required") + "One of 'paths', 'path', 'pathPrefix' or 'pathRegex' field is required" + ) } }