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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loosen constraint on int vs number type check #413

Merged
merged 4 commits into from
Nov 28, 2022
Merged

Loosen constraint on int vs number type check #413

merged 4 commits into from
Nov 28, 2022

Conversation

aq17
Copy link
Contributor

@aq17 aq17 commented Nov 28, 2022

Fixes pu/templates pulumi/templates#465

Since the project-level config block supports integer but not number, we can loosen the type check constraint for now until configuration is fully deprecated

@aq17 aq17 requested a review from iwahbe November 28, 2022 17:43
@iwahbe
Copy link
Member

iwahbe commented Nov 28, 2022

Can you show a repro here?

Pulumi YAML configuration does support int:

case "int":
return Int, true
default:

@aq17
Copy link
Contributor Author

aq17 commented Nov 28, 2022

Can you show a repro here?

Pulumi YAML configuration does support int:

case "int":
return Int, true
default:

Ah right but config doesn't support Number. The template before the change used configuration with number, and I assumed if config was set on the cli it was parsed as integer causing the conflict. I'll try to repro to confirm first

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all numbers are integers, so I don't love this fix. I think a repro would be helpful in root causing this.

pkg/pulumiyaml/analyser.go Outdated Show resolved Hide resolved
@aq17
Copy link
Contributor Author

aq17 commented Nov 28, 2022

The Pulumi.dev.yaml that gets initialized on pulumi new container-aws-yaml uses config, setting the keys as integer, whereas the old template with configuration tried to set it as number. Loosening the constraint to allow integer -> number should suffice for now

@aq17 aq17 added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Nov 28, 2022
@aq17 aq17 requested a review from iwahbe November 28, 2022 18:36
Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add some tests here, both for correctness and to act as documentation for how the type coercion is supposed to work (int&float = float, int&int = int, int&string=!ok, ...)?

pkg/pulumiyaml/analyser.go Outdated Show resolved Hide resolved
@aq17 aq17 requested a review from iwahbe November 28, 2022 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact/no-changelog-required This issue doesn't require a CHANGELOG update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants