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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forbid nonsensical flag interactions in the Pulumi schema #8308

Open
iwahbe opened this issue Oct 28, 2021 · 1 comment
Open

Forbid nonsensical flag interactions in the Pulumi schema #8308

iwahbe opened this issue Oct 28, 2021 · 1 comment
Labels
area/codegen SDK-gen, program-gen, convert kind/enhancement Improvements or new features

Comments

@iwahbe
Copy link
Member

iwahbe commented Oct 28, 2021

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

We have several type flags that can be set on a single type in the schema. These include:

  • const: Has a constant and specific value, similar to a const variable. => The caller should not specify a value.
  • default: The field has a default value if no value is provided. => The caller may specify a value.
  • required: The user must specify a value at the call site. => The caller must specify a value.

In the past, we allowed the Pulumi schema to specify nonsensical combinations of flags such as

"field_name": {
          "type": "string",
          "const": "val",
          "default": "another",
	  "required": true
        }

To ensure that the schema is coherent, and that we can faithfully respect the schema during codegen, we will disable specifying any combination of const, default, and required (just 1 is ok).

Note: The required property is not set on the property itself but in an associated list.

Affected area/feature

This will narrow the set of viable schema inputs. It may allow us to simplify codegen, because it strengthens what assumptions we can make.

@iwahbe iwahbe added kind/enhancement Improvements or new features area/codegen SDK-gen, program-gen, convert labels Oct 28, 2021
@iwahbe iwahbe self-assigned this Oct 28, 2021
@iwahbe
Copy link
Member Author

iwahbe commented Oct 28, 2021

This will require a change in schema generation for pulumi-azure-native at the very least, as it generates types like this:

        "azure-native:datafactory:AzureDatabricksDeltaLakeSink": {
            "description": "A copy activity Azure Databricks Delta Lake sink.",
            "properties": {
                ...
                "type": {
                    "type": "string",
                    "description": "Copy sink type.\nExpected value is 'AzureDatabricksDeltaLakeSink'.",
                    "const": "AzureDatabricksDeltaLakeSink"
                }
            ...
            },
            "type": "object",
            "required": [
                "type"
            ]
        }

@iwahbe iwahbe changed the title Forbid nonsensical flag interactions in the pulumi schema. Forbid nonsensical flag interactions in the Pulumi schema Oct 29, 2021
@iwahbe iwahbe removed their assignment Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen SDK-gen, program-gen, convert kind/enhancement Improvements or new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant