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

Schema Analyzer to infer component schemas from classes #498

Merged
merged 4 commits into from
Feb 24, 2025

Conversation

mikhailshilkov
Copy link
Member

Implements ComponentAnalyzer.GenerateSchema which takes either an assembly or a list of component resources and produces a serializable package schema structure. Infers component resources and their dependent types. Here are the features that this PR implements and tests:

  • Inputs
  • Outputs
  • Plain types
  • Boolean, integer, number, string
  • Complex types
  • Nested complex types
  • Self-recursive complex types
  • Mutually recursive complex types
  • Required properties & inputs
  • Component description
  • Complex type description
  • Property description
  • Optional
  • Array
  • Map
  • Asset/Archive
  • Resource reference
  • Discriminated Union
  • Enum
  • Methods
  • References to component in same provider
  • pulumi.Any

Resolve #468 (we'll track missing features in separate issues)

@mikhailshilkov mikhailshilkov requested a review from a team as a code owner February 21, 2025 16:12
@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/schema-analyzer branch from 0842767 to 2ab10a8 Compare February 21, 2025 16:21
Copy link
Member

@Frassle Frassle left a comment

Choose a reason for hiding this comment

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

Why does this just return a schema? Don't we need to keep the schema together with construct functions that can implement it

@mikhailshilkov
Copy link
Member Author

Why does this just return a schema? Don't we need to keep the schema together with construct functions that can implement it

This is mostly a utility class, it will be used in a provider implementation similar to this Java one

/// <returns>A PackageSpec containing the complete schema for all components and their types</returns>
public static PackageSpec GenerateSchema(Metadata metadata, params Type[] componentTypes)
{
if (metadata?.Name == null || string.IsNullOrWhiteSpace(metadata.Name))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we evaulate this against the same regex we have in pulumi.json?

Also micronit, I'd prefer curly braces in all if statements even if they are just one line. Not sure we have a linter or guidelines for that though.

@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/schema-analyzer branch from 8595302 to 5e0ca99 Compare February 24, 2025 12:00
@mikhailshilkov mikhailshilkov force-pushed the mikhailshilkov/schema-analyzer branch from 5e0ca99 to b08bc13 Compare February 24, 2025 12:20
@mikhailshilkov mikhailshilkov added this pull request to the merge queue Feb 24, 2025
Merged via the queue into main with commit aba61bb Feb 24, 2025
20 checks passed
@mikhailshilkov mikhailshilkov deleted the mikhailshilkov/schema-analyzer branch February 24, 2025 13:35
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.

Infer Pulumi schema from implementation of ComponentResource(s)
3 participants