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

Add overlay support to codegen #402

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Conversation

pawelprazak
Copy link
Contributor

@pawelprazak pawelprazak commented Feb 22, 2024

  • refactor codegen to allow for the required changes to be made
    • implicit val changed to given/using
    • unified Config with added overlays dir setting (overlaysDir/DefaultOverlaysDir)
    • pre-process the schema and store parsed types, resources and functions in PulumiPackageInfo
    • store a reference to the deserialized schema in the PulumiPackageInfo
    • store provider related config (e.g. overlays) per schema in the PulumiPackageInfo
    • parsing logic moved from SchemaProvider and PulumiPackageOps to PulumiPackageInfo
    • other small cosmetic changes, renames, etc
  • add support for overlays in codegen (Overlay.scala)

fixes #286 (was closed as done, but we were just ignoring the overlays, now we can add them)

@pawelprazak pawelprazak added kind/missing We are missing a part of functionality compared to upstream area/codegen Schema to code generator labels Feb 22, 2024
@pawelprazak pawelprazak requested a review from lbialy February 22, 2024 11:04
@pawelprazak pawelprazak added this to the 0.2.2 milestone Feb 22, 2024
@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch 3 times, most recently from 9ae47b8 to cac9714 Compare February 22, 2024 16:48
@pawelprazak pawelprazak modified the milestones: 0.2.2, 0.2.3 Feb 22, 2024
@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch 4 times, most recently from a602349 to fd8162e Compare February 28, 2024 14:00
@pawelprazak pawelprazak added the blocked Something is blocking this issue form progressing label Feb 28, 2024
@pawelprazak
Copy link
Contributor Author

blocked by #407

@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch from fd8162e to ce9d644 Compare February 28, 2024 14:08
@pawelprazak pawelprazak modified the milestones: 0.2.3, 0.2.4 Feb 28, 2024
@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch from ce9d644 to 8a0f5e4 Compare February 28, 2024 18:37
@pawelprazak
Copy link
Contributor Author

Depends on #409

@pawelprazak pawelprazak removed the blocked Something is blocking this issue form progressing label Feb 28, 2024
@pawelprazak pawelprazak marked this pull request as ready for review February 28, 2024 18:37
@pawelprazak pawelprazak modified the milestones: 0.2.4, 0.3.0 Mar 7, 2024
@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch 2 times, most recently from a279479 to f29a8ab Compare March 8, 2024 08:45
@pawelprazak
Copy link
Contributor Author

I've addressed the comments, ready for re-review

@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch 2 times, most recently from 3bff8ba to ad0a44c Compare March 27, 2024 12:20
@pawelprazak
Copy link
Contributor Author

Note to self: split the refactoring and the changes, postpone the changes, merge the refactoring.

@pawelprazak pawelprazak self-assigned this Apr 2, 2024
- add support for overlays in codegen
- refactor codegen to allow for the required changes to be made
@pawelprazak pawelprazak force-pushed the pprazak/add-kubernetes-overlays-1 branch from ad0a44c to 6aaa82b Compare April 9, 2024 13:30
@pawelprazak
Copy link
Contributor Author

I've reduced the scope of this PR to only include the mechanism for overlays and associated refactoring, without any specific overlay implemented.

@@ -2,6 +2,25 @@ package besom.codegen

import besom.model.SemanticVersion

case class Config(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

One unified Config instead of separate CodegenConfig, ProviderConfig

objectTypeTokens: Set[String],
resourceTypeTokens: Set[String],
enumValueToInstances: Map[PulumiToken, Map[ConstValue, EnumInstanceName]],
parsedTypes: Map[PulumiDefinitionCoordinates, (TypeDefinition, Boolean)],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we pre-process the schema and store parsed types, resources and functions

parsedResources: Map[PulumiDefinitionCoordinates, (ResourceDefinition, Boolean)],
parsedFunctions: Map[PulumiDefinitionCoordinates, (FunctionDefinition, Boolean)]
)(
private[codegen] val pulumiPackage: PulumiPackage,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

store a reference to the deserialized schema

parsedFunctions: Map[PulumiDefinitionCoordinates, (FunctionDefinition, Boolean)]
)(
private[codegen] val pulumiPackage: PulumiPackage,
private[codegen] val providerConfig: Config.Provider
Copy link
Contributor Author

Choose a reason for hiding this comment

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

store provider related config (e.g. overlays) per schema

def asPackageMetadata: PackageMetadata = PackageMetadata(name, Some(version))

def parseMethods(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the parsing logic moved from other places (mostly SchemaProvider and PulumiPackageOps)

def from(
pulumiPackage: PulumiPackage,
packageMetadata: PackageMetadata
)(using Logger, Config): PulumiPackageInfo = PreProcessed.from(pulumiPackage, packageMetadata).process
Copy link
Contributor Author

Choose a reason for hiding this comment

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

invoke the new 2-stage schema processing

@pawelprazak pawelprazak merged commit 5e67e0d into main Apr 10, 2024
2 checks passed
@pawelprazak pawelprazak deleted the pprazak/add-kubernetes-overlays-1 branch April 10, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen Schema to code generator kind/missing We are missing a part of functionality compared to upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add overlays support to codegen
2 participants