-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Reify Input
and Optional
types in the schema type system.
#7059
Conversation
Diff for pulumi-random with merge commit 3230abb |
Diff for pulumi-azuread with merge commit 3230abb |
Diff for pulumi-kubernetes with merge commit 3230abb |
Diff for pulumi-gcp with merge commit 3230abb |
Diff for pulumi-azure with merge commit 3230abb |
Diff for pulumi-aws with merge commit 3230abb |
Diff for pulumi-azure-native with merge commit 3230abb |
@cnunciato it looks like a bunch of docs tests changed here--any idea why? I didn't touch anything in the docs generator directly... |
Diff for pulumi-random with merge commit 7a8e5a2 |
Diff for pulumi-azuread with merge commit 7a8e5a2 |
Diff for pulumi-kubernetes with merge commit 7a8e5a2 |
Diff for pulumi-gcp with merge commit 7a8e5a2 |
Diff for pulumi-azure with merge commit 7a8e5a2 |
@pgavlin Not immediately sure either. I don't see this on master, but I do see it when I check out your branch and run the tests with |
Diff for pulumi-aws with merge commit 7a8e5a2 |
Diff for pulumi-azure-native with merge commit 7a8e5a2 |
There shouldn't be, no. The changes I made should be localized to SDK generation. |
Where do we define shallow/deep unwrapping? Looking at this PR, Foo and FooArgs in the example seem structurally identical. Would a difference appear if they referenced nested Output/Input props? |
This does not address the issue for Go, where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something isn't right with these changes... I tried generating SDKs with these changes with the following schema:
{
"name": "xyz",
"types": {
"example:index:Foo": {
"properties": {
"a": {
"type": "boolean"
}
},
"type": "object"
}
},
"resources": {
"xyz:index:StaticPage": {
"isComponent": true,
"inputProperties": {
"indexContent": {
"type": "string",
"description": "The HTML content for index.html."
},
"foo": {
"$ref": "#/types/example:index:Foo"
}
},
"requiredInputs": [
"indexContent"
],
"properties": {
"bucket": {
"$ref": "/aws/v4.0.0/schema.json#/resources/aws:s3%2Fbucket:Bucket",
"description": "The bucket resource."
},
"websiteUrl": {
"type": "string",
"description": "The website URL."
}
},
"required": [
"bucket",
"websiteUrl"
],
"plainInputs": ["foo"]
}
},
"language": {
"csharp": {
"packageReferences": {
"Pulumi": "3.*",
"Pulumi.Aws": "4.*"
}
},
"go": {
"generateResourceContainerTypes": true,
"importBasePath": "github.com/pulumi/pulumi-xyz/sdk/go/xyz"
},
"nodejs": {
"dependencies": {
"@pulumi/aws": "^4.0.0"
},
"devDependencies": {
"typescript": "^3.7.0"
}
},
"python": {
"requires": {
"pulumi": ">=3.0.0,<4.0.0",
"pulumi-aws": ">=4.0.0,<5.0.0"
}
}
}
}
.NET
The resource args refers to FooArgs
:
public sealed class StaticPageArgs : Pulumi.ResourceArgs
{
[Input("foo")]
public Pulumi.Example.Inputs.FooArgs? Foo { get; set; }
/// <summary>
/// The HTML content for index.html.
/// </summary>
[Input("indexContent", required: true)]
public Input<string> IndexContent { get; set; } = null!;
public StaticPageArgs()
{
}
}
And sdk/dotnet/Inputs/FooArgs.cs
is emitted, but it's empty (missing definition for FooArgs
):
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Example.Inputs
{
}
Node.js
Similarly, the resource's args refers to the FooArgs
correctly:
export interface StaticPageArgs {
foo?: inputs.FooArgs;
/**
* The HTML content for index.html.
*/
indexContent: pulumi.Input<string>;
}
And sdk/nodejs/types/input.ts
is emitted, but it's empty (missing definition for FooArgs
):
// *** WARNING: this file was generated by Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
import * as pulumi from "@pulumi/pulumi";
import { input as inputs, output as outputs } from "../types";
Python
Similarly, the resource args refers to FooArgs
:
class StaticPage(pulumi.ComponentResource):
@overload
def __init__(__self__,
resource_name: str,
opts: Optional[pulumi.ResourceOptions] = None,
foo: Optional[pulumi.InputType['FooArgs']] = None,
index_content: Optional[pulumi.Input[str]] = None,
__props__=None):
And sdk/python/pulumi_xyz/_inputs.py
is emitted, but it's empty (missing definition of FooArgs
):
# coding=utf-8
# *** WARNING: this file was generated by Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import warnings
import pulumi
import pulumi.runtime
from typing import Any, Mapping, Optional, Sequence, Union, overload
from . import _utilities
__all__ = [
]
Diff for pulumi-random with merge commit c64334f |
Diff for pulumi-azuread with merge commit c64334f |
Diff for pulumi-kubernetes with merge commit c64334f |
Diff for pulumi-gcp with merge commit c64334f |
This is now done.
Excellent catch, @justinvp. Fixed. |
Diff for pulumi-azure with merge commit c64334f |
Diff for pulumi-aws with merge commit c64334f |
Diff for pulumi-azuread with merge commit 80802c8 |
Diff for pulumi-kubernetes with merge commit 80802c8 |
Diff for pulumi-gcp with merge commit 80802c8 |
Diff for pulumi-azure with merge commit 80802c8 |
Diff for pulumi-aws with merge commit 80802c8 |
React to changes from pulumi/pulumi#7059 - Remove `plain` and `plainInputs` array properties - Add a bool `plain` property to `Type`.
React to changes from pulumi/pulumi#7059 - Remove `plain` and `plainInputs` array properties - Add a bool `plain` property to `Type`.
These changes support arbitrary combinations of input + plain types
within a schema. Handling plain types at the property level was not
sufficient to support such combinations. Reifying these types
required updating quite a bit of code. This is likely to have caused
some temporary complications, but should eventually lead to
substantial simplification in the SDK and program code generators.
With the new design, input and optional types are explicit in the schema
type system. Optionals will only appear at the outermost level of a type
(i.e. Input<Optional<>>, Array<Optional<>>, etc. will not occur). In
addition to explicit input types, each object type now has a "plain"
shape and an "input" shape. The former uses only plain types; the latter
uses input shapes wherever a plain type is not specified. Plain types
are indicated in the schema by setting the "plain" property of a type spec
to true.