From 93a041c5e896c72cddece6aa127f745da3eabd79 Mon Sep 17 00:00:00 2001 From: Ayan Sen Date: Mon, 15 Jan 2024 18:17:20 -0800 Subject: [PATCH 1/2] Added documentation to classes and refactored import statements in test files --- checkstyle/checkstyle.xml | 137 -------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 checkstyle/checkstyle.xml diff --git a/checkstyle/checkstyle.xml b/checkstyle/checkstyle.xml deleted file mode 100644 index c91ac03..0000000 --- a/checkstyle/checkstyle.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 4a13133b9d8941df99ade763d52f71de567c447c Mon Sep 17 00:00:00 2001 From: Ayan Sen Date: Mon, 15 Jan 2024 18:17:34 -0800 Subject: [PATCH 2/2] Added documentation to classes and refactored import statements in test files --- envoy/src/main/kotlin/ayansen/playground/envoy/App.kt | 4 +++- .../ayansen/playground/envoy/SpringConfiguration.kt | 3 +++ .../envoy/controller/EnvoyConfigurationsController.kt | 4 +--- .../main/kotlin/ayansen/playground/envoy/entity/Proxy.kt | 5 ++++- .../playground/envoy/provider/FileProxyProvider.kt | 6 ++++++ .../ayansen/playground/envoy/server/DiscoveryServer.kt | 2 +- .../src/test/kotlin/ayansen/playground/envoy/Fixtures.kt | 1 - .../playground/envoy/server/DiscoveryServerTests.kt | 9 ++++++--- .../exemplar/server/provider/FileConfigProviderTest.kt | 4 +--- 9 files changed, 25 insertions(+), 13 deletions(-) diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/App.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/App.kt index 4d1e78c..96d85b7 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/App.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/App.kt @@ -2,7 +2,9 @@ package ayansen.playground.envoy import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication - +/** + * This is the main entry point for the application + */ @SpringBootApplication open class App diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/SpringConfiguration.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/SpringConfiguration.kt index 4edfcc5..90abab3 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/SpringConfiguration.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/SpringConfiguration.kt @@ -9,6 +9,9 @@ import io.envoyproxy.controlplane.cache.v3.SimpleCache import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +/** + * This class is responsible for configuring the spring beans + */ @Configuration open class SpringConfiguration { @Bean diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/controller/EnvoyConfigurationsController.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/controller/EnvoyConfigurationsController.kt index 3c002fe..c2c255f 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/controller/EnvoyConfigurationsController.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/controller/EnvoyConfigurationsController.kt @@ -7,14 +7,12 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController - @RestController @RequestMapping("/proxy") class EnvoyConfigurationsController(private val proxyProvider: ProxyProvider) { - @Operation(summary = "Get All Proxies", description = "Returns a list of Proxies configured in Envoy") @GetMapping("/all") suspend fun getProxies(): List { return proxyProvider.getProxies() } -} \ No newline at end of file +} diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/entity/Proxy.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/entity/Proxy.kt index 6cf18a3..d3b8118 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/entity/Proxy.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/entity/Proxy.kt @@ -6,7 +6,10 @@ import io.envoyproxy.envoy.config.endpoint.v3.Endpoint import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints - +/** + * This class represents a proxy configuration. It contains nested data classes for defining routes, clusters, hosts, and socket addresses. + * The class provides methods for converting the proxy configuration to protobuf messages for use with Envoy. + */ data class Proxy( val name: String, val domains: List, diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/provider/FileProxyProvider.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/provider/FileProxyProvider.kt index dd52873..8fa1869 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/provider/FileProxyProvider.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/provider/FileProxyProvider.kt @@ -15,6 +15,12 @@ import java.nio.file.Path import java.nio.file.StandardWatchEventKinds import java.nio.file.WatchKey +/** + * This class is responsible for providing the proxy configuration from a folder of yaml files + * @property proxyFolderPath + * @property simpleCache + * @property listenersConfiguration + */ class FileProxyProvider( private val proxyFolderPath: String, simpleCache: SimpleCache, diff --git a/envoy/src/main/kotlin/ayansen/playground/envoy/server/DiscoveryServer.kt b/envoy/src/main/kotlin/ayansen/playground/envoy/server/DiscoveryServer.kt index 0b51ce0..751a349 100644 --- a/envoy/src/main/kotlin/ayansen/playground/envoy/server/DiscoveryServer.kt +++ b/envoy/src/main/kotlin/ayansen/playground/envoy/server/DiscoveryServer.kt @@ -6,7 +6,7 @@ import org.slf4j.LoggerFactory /** - * TODOThe DiscoveryServer class is responsible for starting a gRPC server and initializing the necessary services for Envoy proxy configuration discovery. + * The DiscoveryServer class is responsible for starting a gRPC server and initializing the necessary services for Envoy proxy configuration discovery. Example Usage val simpleCache = SimpleCache() val discoveryServer = DiscoveryServer(simpleCache) diff --git a/envoy/src/test/kotlin/ayansen/playground/envoy/Fixtures.kt b/envoy/src/test/kotlin/ayansen/playground/envoy/Fixtures.kt index 4820911..36cbbe6 100644 --- a/envoy/src/test/kotlin/ayansen/playground/envoy/Fixtures.kt +++ b/envoy/src/test/kotlin/ayansen/playground/envoy/Fixtures.kt @@ -10,7 +10,6 @@ object Fixtures { val mapper: ObjectMapper = ObjectMapper(YAMLFactory()).apply { registerModule(KotlinModule.Builder().build()) } - inline fun parseYamlFile(file: File): T { return mapper.readValue(file, T::class.java) } diff --git a/envoy/src/test/kotlin/ayansen/playground/envoy/server/DiscoveryServerTests.kt b/envoy/src/test/kotlin/ayansen/playground/envoy/server/DiscoveryServerTests.kt index 4f2aedb..1e01170 100644 --- a/envoy/src/test/kotlin/ayansen/playground/envoy/server/DiscoveryServerTests.kt +++ b/envoy/src/test/kotlin/ayansen/playground/envoy/server/DiscoveryServerTests.kt @@ -1,8 +1,11 @@ package ayansen.playground.envoy.server +import io.envoyproxy.envoy.config.core.v3.Node import io.envoyproxy.envoy.service.discovery.v3.DiscoveryRequest +import io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse import io.envoyproxy.envoy.service.endpoint.v3.EndpointDiscoveryServiceGrpc import io.grpc.ManagedChannelBuilder +import io.grpc.stub.StreamObserver import org.junit.jupiter.api.Test import org.springframework.boot.test.context.SpringBootTest import kotlin.test.assertNotNull @@ -18,8 +21,8 @@ class DiscoveryServerTests { ) client.streamEndpoints(object : - io.grpc.stub.StreamObserver { - override fun onNext(value: io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse?) { + StreamObserver { + override fun onNext(value: DiscoveryResponse?) { assertNotNull(value) } @@ -35,7 +38,7 @@ class DiscoveryServerTests { DiscoveryRequest.newBuilder().setTypeUrl( "type.googleapis.com/envoy.config.endpoint.v3.ClusterLoadAssignment" ).setNode( - io.envoyproxy.envoy.config.core.v3.Node.newBuilder().setId("key").build( + Node.newBuilder().setId("key").build( ) ).build() ) diff --git a/openapi/src/test/kotlin/ayansen/playground/openapi/exemplar/server/provider/FileConfigProviderTest.kt b/openapi/src/test/kotlin/ayansen/playground/openapi/exemplar/server/provider/FileConfigProviderTest.kt index 441e70b..401de59 100644 --- a/openapi/src/test/kotlin/ayansen/playground/openapi/exemplar/server/provider/FileConfigProviderTest.kt +++ b/openapi/src/test/kotlin/ayansen/playground/openapi/exemplar/server/provider/FileConfigProviderTest.kt @@ -1,5 +1,3 @@ package ayansen.playground.openapi.exemplar.server.provider -class FileConfigProviderTest { - -} \ No newline at end of file +class FileConfigProviderTest