pulumi/pkg/codegen/pcl
Will Jones 17b66dfc56
Add a `call` intrinsic to PCL
In order for PCL to serve as an authoritative intermediate language for
Pulumi programs, it needs to be able to express all the concepts
available to a Pulumi program written in a high-level programming
language. Put another way, it must be capable of expressing all the
functionality exposed by the `ResourceMonitor` interface. Presently, the
ability to `Call` methods on component resources is not available in
PCL. This change adds a new `call` intrinsic to fix that.

`call` has three required arguments: the receiver (that will become the
`__self__` argument under the hood), the method name (that must exist in
the resource's `Methods` map in schema), and an object of arguments
(whose specifications must appear in the corresponding `Function` in the
schema). An example use of `call` might thus look as follows:

```hcl
resource "c" "pkg:index:Callable" {
  ...
}

output "o" {
  value = call(c, "method", { x = 1, y = 2 })
}
```

In order to type check and applications of `call` when binding PCL
programs, we use the recently powered-up annotations feature to look up
the resource node of the receiver from its expression. With this, we are
able to grab the schema and validate the method name and arguments.
While we add unit tests for binding programs that use `call`, this
change does not extend program generation or the conformance test suite.
This will be done in a subsequent set of changes.

Part of fixing pulumi/pulumi-java#262
2025-01-10 16:58:48 +00:00
..
README.md Add more documentation on PCL (#18193) 2025-01-09 10:18:08 +00:00
binder.go Add a `call` intrinsic to PCL 2025-01-10 16:58:48 +00:00
binder_component.go [program-gen] Emit deferred outputs for mutually dependant components (#17859) 2024-11-27 23:36:31 +00:00
binder_nodes.go [TF circular reference] Allow specifying mutually dependant components in PCL (#17761) 2024-11-14 22:09:55 +00:00
binder_resource.go Add a `call` intrinsic to PCL 2025-01-10 16:58:48 +00:00
binder_resource_test.go Support loading parameterized schemas in the schema loader (#17108) 2024-08-30 14:25:29 +00:00
binder_schema.go Clean up and test PCL object type annotations 2025-01-10 16:58:48 +00:00
binder_schema_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
binder_test.go Add a `call` intrinsic to PCL 2025-01-10 16:58:48 +00:00
binding.md Add more documentation on PCL (#18193) 2025-01-09 10:18:08 +00:00
call.go Add a `call` intrinsic to PCL 2025-01-10 16:58:48 +00:00
component.go lint 2023-07-27 16:32:06 +02:00
config.go Implement description as comments or docstring for config variables in program-gen 2023-03-21 15:01:16 +01:00
diagnostics.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
functions.go [pcl] Allow PCL function element to take a dynamic expression as input in non-strict mode (#17587) 2024-11-11 12:15:54 +00:00
functions_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
intrinsics.go all: Assert => Assertf 2023-03-03 14:37:43 -08:00
invoke.go Add a `call` intrinsic to PCL 2025-01-10 16:58:48 +00:00
local.go Do not panic when the type of PCL local variable isn't known 2023-04-13 20:05:16 +02:00
output.go codegen: preserve externally visible names of a resources and outputs (#9464) 2022-04-25 15:07:25 -07:00
program.go Use slice.Prealloc instead of make([]T, 0, ...) 2023-06-29 11:27:50 +01:00
resource.go Add support for `DeletedWith` to `pulumi convert` (#12011) 2024-07-19 14:17:45 +00:00
rewrite_apply.go Vendor the inflector library (#16421) 2024-06-20 09:04:33 +00:00
rewrite_apply_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
rewrite_convert.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
rewrite_convert_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
rewrite_properties.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00
type.go [codegen] simplify opaque types to string newtype (#9770) 2022-06-13 11:13:03 -07:00
utilities.go Clean up and test PCL object type annotations 2025-01-10 16:58:48 +00:00
utilities_test.go Enable goheader rule and add missing license headers (#15473) 2024-09-09 12:05:45 +00:00

README.md

(pcl)=

Pulumi Configuration Language (PCL)

Pulumi Configuration Language (PCL) is an internal representation of Pulumi programs which supports all core concepts of the Pulumi programming model in a minimal form. Although not exposed directly to users today, this intermediate representation is used to support a variety of program conversion tasks, from and to various supported Pulumi languages.

Pulumi supports a number of operations pertaining to PCL programs:

  • Lexing and parsing, in which PCL source is parsed into an abstract syntax tree (AST).

  • Type checking and binding, in which a PCL AST is verified to be well-formed (describing resources, outputs, and so on), associated with ("bound to") a set of Pulumi schema, and type checked and resolved.

  • Code generation ("programgen"), in which a PCL program is converted into a program written in a supported target language. Much of this underpins the core of tools such as pulumi convert.

:::{toctree} :maxdepth: 1 :titlesonly:

Syntax and type checking </pkg/codegen/hcl2/README> Binding </pkg/codegen/pcl/binding> :::