https://kotlinlang.org logo
#kotless
Title
# kotless
s

sikri

08/30/2020, 1:38 PM
hey, i’m using ktor version of kotless on terraform file generation phase it generates 3 same resources, resulting in a corrupted terraform file, is there any way to find out why it generates 3 same resources?
t

TanVD

08/30/2020, 2:02 PM
It is pretty strange. Can you share your code with me? Or any minimal reproducing example. I would take a look. Kotless should generate same resources only if you actually has clashing declarations of HTTP routes
s

sikri

08/30/2020, 2:09 PM
okay, i will prepare repo asap, maybe this evening, thanks for replying
t

TanVD

08/30/2020, 2:42 PM
No problem 🙂 Ping me once you have an example and I'll investigate)
s

sikri

08/30/2020, 6:25 PM
@TanVD i believe the problem is in ktor parser for example, for ktor with koin next code is valid:
Copy code
routing {
   // koin
   get<GetAllUsersEndpoint>().invoke(this)
}

class GetAllUsersEndpoint(
   private val usecase: Usecase
) : (Route) -> Route {
   fun invoke(route: Route) = route.get("allUsers") {
      .... //logic
   }
}
but I assume kotless’ ktor parser expect for routes and endpoints do be ALWAYS declared in a body of “routing” due to the fact that it is for small serverless lambdas, it is not a problem, but imo it should be mentioned anywhere that routes and endpoints SHOULD be declared in
routing
DSL
t

TanVD

08/30/2020, 6:35 PM
Hm, I would not say that it is kind of a rule. Your example should be working and too. If it does not work -- it is definitely a bug in Kotless parser logic 🙂 Kotless must evaluate all functions bodies that are able to somehow access
Routing
context. Could you please file an issue?
In general case, Kotless should not have any limitations and should be able to deploy any kinds of Ktor applications. All the situations in which Kotless does not produce the same REST API Ktor can be considered as bugs. Definitely, there will be some implementation-related limitations (for example, Kotless probably would not work for a very large projects with a routing tree of thousands of parts), but it is definitely not that case
20 Views