Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide pulumiResourceName and pulumiProject, pulumiOrganization, pulumiStack #295

Closed
dubinsky opened this issue Nov 14, 2023 · 12 comments · Fixed by #301
Closed

Provide pulumiResourceName and pulumiProject, pulumiOrganization, pulumiStack #295

dubinsky opened this issue Nov 14, 2023 · 12 comments · Fixed by #301
Labels
area/api User visible API impact/first-48 This bug is likely to be hit during a user's first 48 hours of product evaluation impact/usability Something that impacts users' ability to use the product easily and intuitively kind/improvement An improvement with existing workaround
Milestone

Comments

@dubinsky
Copy link

In Pulumi, name given to a resource at construction time can be recovered by calling pulumiResourceName method on the com.pulumi.resources.Resource. What is the Besom way of doing this?

Thanks!

@lbialy
Copy link
Collaborator

lbialy commented Nov 14, 2023

Hi!

We don't really have pulumiResourceName as such (maybe we should?) but it's still possible to access the resource's logical name via URN. Each and every resource has to have a urn field of type Output[URN] where URN is an opaque type with several extensions allowing access to it's parts (one of which is a logical resource name!). Therefore:

    val redisNamespace = Namespace(s"redis-cluster-namespace-$name")

    redisNamespace.urn.map(_.resourceName): Output[String]

I think we can add some extension syntaxes for all resources to just have this and that wouldn't be a breaking change. Adding a field to each generated resource to hold on to the logical name would be a breaking change but maybe we should make it.

Do you feel that getting that name in Output[String] is inconvenient?

@dubinsky
Copy link
Author

dubinsky commented Nov 14, 2023

I think we can add some extension syntaxes for all resources to just have this and that wouldn't be a breaking change. Adding a field to each generated resource to hold on to the logical name would be a breaking change but maybe we should make it.

Everything works great even without adding anything. Thanks!

Do you feel that getting that name in Output[String] is inconvenient?

It's perfectly fine! (And will only get better with #291...)

Thank you!!

@pawelprazak pawelprazak added kind/question Questions about existing features area/api User visible API labels Nov 14, 2023
@pawelprazak
Copy link
Contributor

@dubinsky I'm glad you're having fun with Besom, please let us know if any other issue comes to mind :)

@lbialy maybe we could improve the API a bit and it is still less characters than pulumiResourceName ;)
redisNamespace.urn.map(_.resourceName) -> redisNamespace.urn.resourceName

@dubinsky
Copy link
Author

I'm glad you're having fun with Besom, please let us know if any other issue comes to mind :)

I am having lots of fun! Thank you!!

  1. I need things like OrganizationsFunctions.getOrganization(GetOrganizationArgs) (GCP), but I see that they are in the next release. Thanks! When is the next release planned?
  2. What are the plans for tracking changes to the providers? I am using org.virtuslab:besom-gcp_3:6.66.0-core.0.1.0, and while 0.1.0 is the latest released version of Besom, 6.66.0 is not the latest released version of GCP ;)
  3. Is GitHub Issues the way to contact you with questions or will there be something more conversational (GitHub Discussions? Something else?)

Thanks!

@dubinsky
Copy link
Author

On this specific issue:

  1. I agree that writing resource.urn.resourceName instead of resporce.urn.map(_.resourceName) is cleaner and more in the "lifted" style of Besom... but how far should this go? Lift all the URN components? Everything?
  2. I think that retrieval of the resource name (and other URN components) should be documented. https://virtuslab.github.io/besom/docs/constructors? https://virtuslab.github.io/besom/docs/interpolator?

@lbialy
Copy link
Collaborator

lbialy commented Nov 14, 2023 via email

@dubinsky
Copy link
Author

Now I personally think that said
prototype is the way to go in ergonomy of all monadic interfaces but it's
not yet ready for prime time for sure (compilation times would probably
explode as well).

Hope to see it some day!

Given the need for refinement types support in IDE
to support this feature we've went with simpler and well supported design
based on code-generated extensions.

My IDE (Idea) does not let me click through to the definitions of the extension method like urn...

Going via
outputResource.urn.resourceName feels a bit esoteric for me - user has to
know about URNs and while they are quite basic and important concept I
don't feel they are as in-the-face as resources and outputs. I'd prefer
outputResource.pulumiResourceName personally as in other sdks.

I completely agree, outputResource.pulumiResourceName is better than outputResource.urn.resourceName.

I personally do not need access to the other components of the urn ;)

@pawelprazak
Copy link
Contributor

I'm glad you're having fun with Besom, please let us know if any other issue comes to mind :)

I am having lots of fun! Thank you!!

  1. I need things like OrganizationsFunctions.getOrganization(GetOrganizationArgs) (GCP), but I see that they are in the next release. Thanks! When is the next release planned?
  2. What are the plans for tracking changes to the providers? I am using org.virtuslab:besom-gcp_3:6.66.0-core.0.1.0, and while 0.1.0 is the latest released version of Besom, 6.66.0 is not the latest released version of GCP ;)
  3. Is GitHub Issues the way to contact you with questions or will there be something more conversational (GitHub Discussions? Something else?)

Thanks!

  1. yes, top-level functions have codegen part done (the provider SDK code generation), we're working on the core part of the plumbing from the function all the way down to gRPC call to the Pulumi engine
  2. the long term plan would be to automate the releases, so we re-release providers daily if new version is detected- thats the goal, right now we prioritize feature parity with upstream and stabilization, but there is a semi-automatic script for the release, so every time we release, we release the providers with the newest versions; as to the mentioned GCP, I've tested the 7.0.0 and it builds
  3. Personally I'm happy answering GH question issues, but we should probably enable GH discussions, @lbialy WDYT?

@lbialy
Copy link
Collaborator

lbialy commented Nov 15, 2023 via email

@pawelprazak pawelprazak changed the title Is there an equivalent to the com.pulumi.resources.Resource.pulumiResourceName? Is there an equivalent to the Java com.pulumi.resources.Resource.pulumiResourceName? Nov 15, 2023
@pawelprazak
Copy link
Contributor

pawelprazak commented Nov 15, 2023

Now I personally think that said
prototype is the way to go in ergonomy of all monadic interfaces but it's
not yet ready for prime time for sure (compilation times would probably
explode as well).

Hope to see it some day!

Given the need for refinement types support in IDE
to support this feature we've went with simpler and well supported design
based on code-generated extensions.

My IDE (Idea) does not let me click through to the definitions of the extension method like urn...

Going via
outputResource.urn.resourceName feels a bit esoteric for me - user has to
know about URNs and while they are quite basic and important concept I
don't feel they are as in-the-face as resources and outputs. I'd prefer
outputResource.pulumiResourceName personally as in other sdks.

I completely agree, outputResource.pulumiResourceName is better than outputResource.urn.resourceName.

I personally do not need access to the other components of the urn ;)

I agree, outputResource.pulumiResourceName is more discoverable, and the prefix avoids collisions.

In spirit of that, we'd also need pulumiProject, pulumiOrganization, pulumiStack on the Context, as they are exposed in every SDK and tend to be useful in my experience.

@lbialy
Copy link
Collaborator

lbialy commented Nov 15, 2023 via email

@pawelprazak pawelprazak changed the title Is there an equivalent to the Java com.pulumi.resources.Resource.pulumiResourceName? Provide pulumiResourceName and pulumiProject, pulumiOrganization, pulumiStack Nov 15, 2023
@pawelprazak pawelprazak added impact/usability Something that impacts users' ability to use the product easily and intuitively impact/first-48 This bug is likely to be hit during a user's first 48 hours of product evaluation kind/improvement An improvement with existing workaround and removed kind/question Questions about existing features labels Nov 15, 2023
@pawelprazak pawelprazak added this to the 0.2.0 milestone Nov 15, 2023
@dubinsky
Copy link
Author

dubinsky commented Nov 15, 2023

@pawelprazak

Personally I'm happy answering GH question issues, but we should probably enable GH discussions

@lbialy

Is there any benefit in conversations over question issues? I mean, beside
separation of questions and bug reports? I'm OK with that but for issues I
get emails and can just respond in Gmail.

If you guys do not mind getting questions in a form of issues, I am fine with that; no need to bother complicating the setup with discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api User visible API impact/first-48 This bug is likely to be hit during a user's first 48 hours of product evaluation impact/usability Something that impacts users' ability to use the product easily and intuitively kind/improvement An improvement with existing workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants