VirtuslabRnD/pulumi-kotlin

Accessing a JavaResource from a KotlinResource

Opened this issue ยท 6 comments

Sometime I fallback to using just the Java bindings, but have specified say the provider in the Kotlin side. I tried to extract a JavaProviderResource from a KotlinProviderResource - but it is protected (so I had to patch locally, and start generating more things locally).

My local path is just modifying

internal abstract val underlyingJavaResource: JavaResource
to be public instead of internal.

So two questions:

  • Is there already a way to extract the JavaResource from the KotlinResource?
  • If not, thoughts on having it? Seems useful.

#706 is a good example of needing to fallback to the Java bindings, and wanting to re-use my existing Kotlin logic.

#706 is a good example of needing to fallback to the Java bindings, and wanting to re-use my existing Kotlin logic.

Yes, but in this case there's no corresponding Kotlin classes, so exposing the Java objects wouldn't really be of much help ๐Ÿ˜… Do any other examples come to mind?

Definitely possible that I am missing something better, but in the other example I have:

  • a Kubernetes (Kotlin) provider
  • I use it with Kotlin-generated bindings, works fine.
  • CustomResource does not exist, thus I need to use the Java bindings
  • The Java CustomResource needs a JavaProvider, and rather than figuring out how to generate that directly, I instead want to make use of my Kubernetes Kotlin provider
  • For my local version, I expose the underlying Java object, which lets me use the mix of Java and Kotlin

Ah, I understand, good point. I'll try to figure out how to handle these overlay resources when I get the chance, thank you for your patience ๐Ÿ™

Sounds good, no rush though, I'm unblocked.

And I empathize with the desire to both hide implementation details and also the occasional need for escape hatches. ๐Ÿ˜