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

Fix 611 #624

Merged
merged 11 commits into from
Oct 17, 2022
Merged

Fix 611 #624

merged 11 commits into from
Oct 17, 2022

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Oct 12, 2022

Fixes #611

First introduces a test case reproducing 611, in the golden test style reminiscent of what Pulumi uses to test SDK generation (example).

How this works:

  • expected PackageSpec is stored in indented JSON
  • the test asserts that there are no changes vs the indented JSON from the expected file
  • you can run PULUMI_ACCEPT=1 go test to rewrite the expected file to actual value, check it with git diff, and commit if the new output makes sense to serve as the subsequent expected value

The test provider is extracted from a subset of AWS from #611

Extracting the test provider subset is what caused most trouble. The values from "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" Provider type that serve as a logical input to our schema generation process are not serializable as they contain funcs. Therefore it is difficult to write code that automatically computes subset. I got by with a semi-manual procedure that ended relying on "github.com/hexops/valast" package and some custom code to get back a Go literal that can be coaxed into an example provider value.

NOTE: ioutil deprecation changes unrelated, added to pass golangci-lint CI checks.

@github-actions
Copy link

Diff for pulumi-random with merge commit 8042e0b

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 8042e0b

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 8042e0b

@github-actions
Copy link

Diff for pulumi-azure with merge commit 8042e0b

@t0yv0
Copy link
Member Author

t0yv0 commented Oct 12, 2022

Working through an import cycle, need to move code around.

@github-actions
Copy link

Diff for pulumi-aws with merge commit 8042e0b

@github-actions
Copy link

Diff for pulumi-random with merge commit 62de229

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 62de229

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 62de229

@github-actions
Copy link

Diff for pulumi-azure with merge commit 62de229

@github-actions
Copy link

Diff for pulumi-random with merge commit 8bcdf03

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 8bcdf03

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 8bcdf03

@github-actions
Copy link

Diff for pulumi-aws with merge commit 62de229

@github-actions
Copy link

Diff for pulumi-random with merge commit 88d52c7

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 88d52c7

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 88d52c7

@github-actions
Copy link

Diff for pulumi-azure with merge commit 8bcdf03

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 60f4c4a

@github-actions
Copy link

Diff for pulumi-random with merge commit 60f4c4a

…622)

* Switch pkg type from string to tokens.Package

* Use tokens.Module instead of string where possible

* Add ability to save generated schema

* Compute module placement via type gen paths

* Undo accidental docs diffs

* Simplify diff

* Remove debug helpers

* Remove diff

* Satisfy lint

* PULUMI_ACCEPT=1 go test -run TestRegress611
@t0yv0 t0yv0 changed the title Introduce a test case reproducing 611 Fix 611 Oct 12, 2022
@github-actions
Copy link

Diff for pulumi-random with merge commit 3be86d5

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 3be86d5

@github-actions
Copy link

Diff for pulumi-random with merge commit 2f2dd15

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 2f2dd15

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 2f2dd15

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 3be86d5

@github-actions
Copy link

Diff for pulumi-azure with merge commit 3be86d5

@github-actions
Copy link

Diff for pulumi-azure with merge commit 2f2dd15

@github-actions
Copy link

Diff for pulumi-aws with merge commit 2f2dd15

@github-actions
Copy link

Diff for pulumi-aws with merge commit 3be86d5

Copy link
Contributor

@viveklak viveklak left a comment

Choose a reason for hiding this comment

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

Couple of minor comments. I will follow up with fixing them. Thanks for adding the testing framework!

internal/testing/schemas.go Show resolved Hide resolved
assert.Equal(t, schemaToString(expectedSpec), schemaToString(actualSpec))
}

if os.Getenv("PULUMI_ACCEPT") != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! Should probably add some documentation around this to update the reference schema.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a Makefile target with comment.

@github-actions
Copy link

Diff for pulumi-azuread with merge commit d6f047d

@github-actions
Copy link

Diff for pulumi-random with merge commit d6f047d

@github-actions
Copy link

Diff for pulumi-gcp with merge commit d6f047d

@github-actions
Copy link

Diff for pulumi-azure with merge commit d6f047d

@github-actions
Copy link

Diff for pulumi-aws with merge commit d6f047d

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 69e30f1

@github-actions
Copy link

Diff for pulumi-random with merge commit 69e30f1

@t0yv0 t0yv0 merged commit a727928 into master Oct 17, 2022
@t0yv0 t0yv0 deleted the t0yv0/repro-611 branch October 17, 2022 16:39
@github-actions
Copy link

Diff for pulumi-gcp with merge commit 69e30f1

@github-actions
Copy link

Diff for pulumi-azure with merge commit 69e30f1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inclusion of a / in a datasources module name produces incorrect tokens in schema.json for children properties
2 participants