pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
38 stars 11 forks source link

Verify support for returning plain values from YAML methods #499

Open t0yv0 opened 11 months ago

t0yv0 commented 11 months ago

Hello!

Issue details

As a provider author I would like to be able to mark methods as plain: true so that my provider's consumers can access their results directly without an Output wrapper.

Further, methods that return a single value only should not be wrapped in a struct, making it as simple as possible to consume.

Methods should be able to return explicit Provider references usable for configuring other resources in the stack, so that methods can be used as factories to simplify complex provider configuration.

Here is a PR implementing plain-valued methods for Node, Python, Go that includes acceptance tests for this feature: https://github.com/pulumi/pulumi/pull/13592

Borrowing from that PR, the new schema forms is listed below; "tlsProvider" returns a singleton provider reference, "meaningOfLife" returns a singleton integer, and "objectMix" returns both in a struct.

  "functions": {
    "metaprovider:index:Configurer/tlsProvider": {
      "inputs": {
        "properties": {
          "__self__": {
            "$ref": "#/resources/metaprovider:index:Configurer"
          }
        }
      },
      "outputs": {
        "$ref": "/tls/v4.10.0/schema.json#/provider",
        "plain": true
      }
    },
    "metaprovider:index:Configurer/meaningOfLife": {
      "inputs": {
        "properties": {
          "__self__": {
            "$ref": "#/resources/metaprovider:index:Configurer"
          }
        }
      },
      "outputs": {
        "type": "integer",
        "plain": true
      }
    },
    "metaprovider:index:Configurer/objectMix": {
      "inputs": {
        "properties": {
          "__self__": {
            "$ref": "#/resources/metaprovider:index:Configurer"
          }
        }
      },
      "outputs": {
        "type": "object",
        "plain": true,
        "properties": {
          "provider": {
            "$ref": "/tls/v4.10.0/schema.json#/provider"
          },
          "meaningOfLife": {
            "type": "integer"
          }
        }
      }
    }
  },

YAML-specific considerations

Since YAML does not require SDK generation and relies on Go SDK under the hood, the feature might just work once Method calls are supported - it is currently blocked on that. However it would be good to verify in particular that the information flows correctly and that provider references returned from factory methods can be used to configure further resources.

Affected area/feature