VirtusLab / besom

Besom - a Pulumi SDK for Scala. Also, incidentally, a broom made of twigs tied round a stick. Brooms and besoms are used for protection, to ward off evil spirits, and cleansing of ritual spaces.
https://virtuslab.github.io/besom/
Apache License 2.0
113 stars 7 forks source link

Fix codegen ignoring "plain": true fields in Args schemas #506

Closed lbialy closed 4 days ago

lbialy commented 1 month ago

Our codegen currently ignores modifier "plain": true in args schemas which is apparently used to mark fields that are not dynamic and have to be provided statically. Here's an example of VpcArgs in ts awsx:

export interface VpcArgs {
    /**
     * Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block. Default is `false`. Conflicts with `ipv6_ipam_pool_id`
     */
    assignGeneratedIpv6CidrBlock?: pulumi.Input<boolean>;
    /**
     * The netmask for each available zone to be aligned to. This is optional, the default value is inferred based on an even distribution of available space from the VPC's CIDR block after being divided evenly by the number of availability zones.
     */
    availabilityZoneCidrMask?: number;
    /**
     * A list of availability zone names to which the subnets defined in subnetSpecs will be deployed. Optional, defaults to the first 3 AZs in the current region.
     */
    availabilityZoneNames?: string[];
    /**
     * The CIDR block for the VPC. Optional. Defaults to 10.0.0.0/16.
     */
    cidrBlock?: string;
    /**
     * A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false.
     */
    enableDnsHostnames?: pulumi.Input<boolean>;

And relevant schema definition:

             "inputProperties": {
                "assignGeneratedIpv6CidrBlock": {
                    "type": "boolean",
                    "description": "Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC. You cannot specify the range of IP addresses, or the size of the CIDR block. Default is `false`. Conflicts with `ipv6_ipam_pool_id`\n"
                },
                "availabilityZoneCidrMask": {
                    "type": "integer",
                    "plain": true,
                    "description": "The netmask for each available zone to be aligned to. This is optional, the default value is inferred based on an even distribution of available space from the VPC's CIDR block after being divided evenly by the number of availability zones."
                },
                "availabilityZoneNames": {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "plain": true
                    },
                    "plain": true,
                    "description": "A list of availability zone names to which the subnets defined in subnetSpecs will be deployed. Optional, defaults to the first 3 AZs in the current region."
                },
                "cidrBlock": {
                    "type": "string",
                    "plain": true,
                    "description": "The CIDR block for the VPC. Optional. Defaults to 10.0.0.0/16."
                },
                "enableDnsHostnames": {
                    "type": "boolean",
                    "description": "A boolean flag to enable/disable DNS hostnames in the VPC. Defaults false.\n"
                },

Each field marked with plain: true is not wrapped in Input here and this means there's no way to provide an Output-wrapped value for it - it has to be known statically (or user has to make the whole resource part of a dynamic tree and create it in apply (our map/flatMap) lambda). This property is upheld when resources are used in multi-language components (MLC) - in this case AWSx and EKS and Besom breaks the expectation by sending an Output due to keep outputs / outputValues feature support (we send an output on wire protocol, serde on receiving side deserializes it correctly as OutputValue but then the whole code expects it to be a plain type, not a wrapped one so it explodes like in #493 (this is the cause of this issue).