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

Support for non-overlay components in codegen for pulumi-kubernetes provider #15490

Merged
merged 4 commits into from
Mar 4, 2024

Conversation

EronWright
Copy link
Contributor

@EronWright EronWright commented Feb 22, 2024

Description

This PR enhances the codegen for dotnet to allow the pulumi-kubernetes provider to have non-overlay components. Previously all components were overlays and didn't require codegen.

The specific change is to not apply the KubernetesResource base class when the resource is a component. It is inappropriate to use KubernetesResource in this case because it extends CustomResource not ComponentResource.

The sdkgen test suite for kubernetes20 mode was updated with a new example resource:

  • a non-overlay component resource (code)

The fix is manifested here.

Checklist

  • I have run make tidy to update any new dependencies
  • I have run make lint to verify my code passes the lint check
    • I have formatted my code using gofumpt
  • I have added tests that prove my fix is effective or that my feature works
  • I have run make changelog and committed the changelog/pending/<file> documenting my change
  • Yes, there are changes in this PR that warrants bumping the Pulumi Cloud API version

@pulumi-bot
Copy link
Contributor

pulumi-bot commented Feb 22, 2024

Changelog

[uncommitted] (2024-03-04)

Features

  • [sdkgen/dotnet] Support for non-overlay components in codegen for pulumi-kubernetes provider
    #15490

@EronWright EronWright added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label Feb 22, 2024
@EronWright
Copy link
Contributor Author

EronWright commented Feb 22, 2024

@lblackstone would you happen to know the origin story of the KubernetesResource base class? e.g. would something break if a new component resource weren't extending it? I do see the KubernetesResource class being used in ParseYamlObject.

Also, I just noticed that the old ConfigGroup extends CollectionComponentResource (ref). But it seems to be related to resource references, and maybe the native system will work in lieu.

@lblackstone
Copy link
Member

@lblackstone would you happen to know the origin story of the KubernetesResource base class? e.g. would something break if a new component resource weren't extending it? I do see the KubernetesResource class being used in ParseYamlObject.

Also, I just noticed that the old ConfigGroup extends CollectionComponentResource (ref). But it seems to be related to resource references, and maybe the native system will work in lieu.

As far as I recall, that was copied over from the original TS implementation. I think the extra base class may have added k8s-specific get methods, or something along those lines. I don't know offhand what the implications of changing it would be.

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.

This really ought to have a test in pkg/codegen/testing/test/testdata if just to make sure we don't break it.

@EronWright
Copy link
Contributor Author

EronWright commented Feb 22, 2024

A follow-up about KubernetesResource, I came across some usage that, I think, illustrates its purpose:

    /// <summary>
    /// Base component for containers of Kubernetes resources.
    /// </summary>
    public abstract class CollectionComponentResource : ComponentResource
    {
        /// <summary>
        /// Returns a resource defined by the given name.
        /// </summary>
        /// <param name="name">Resource name.</param>
        /// <param name="namespaceName">Optional namespace, e.g. "kube-prometheus-exporter-kubernetes".</param>
        /// <typeparam name="T">The type of the resource.</typeparam>
        public Output<T> GetResource<T>(string name, string? namespaceName = null)
            where T : KubernetesResource
    
...

From this I would say that KubernetesResource is the base class for any resource that represents a Kubernetes object (or list). The component resources would not fall under that category, nor will the MLC ones extend CollectionComponentResource.

@EronWright EronWright force-pushed the eronwright/dotnet-gen-argsclassname branch from 895c7b6 to 8c6454e Compare March 1, 2024 00:26
Base automatically changed from eronwright/dotnet-gen-argsclassname to master March 2, 2024 07:49
@EronWright EronWright force-pushed the eronwright/codegen-dotnet-k8s-component branch from 01f2056 to d9f8904 Compare March 4, 2024 17:15
@EronWright EronWright added this pull request to the merge queue Mar 4, 2024
Merged via the queue into master with commit 8c7a9e5 Mar 4, 2024
57 of 59 checks passed
@EronWright EronWright deleted the eronwright/codegen-dotnet-k8s-component branch March 4, 2024 21:11
github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2024
### Features

- [pkg] Make schema.NewPluginLoader respect PULUMI_DEBUG_PROVIDERS,
which enables Pulumi YAML programs to work correctly with this feature
  [#15526](#15526)

- [sdk/python] Add support for asynchronous invokes via a new
`invoke_async` function
  [#15602](#15602)

- [sdkgen/dotnet] Support for non-overlay components in codegen for
pulumi-kubernetes provider
  [#15490](#15490)


### Bug Fixes

- [backend/service] Make decrypt/encrypt network calls retryable to help
work around network hiccups
  [#15600](#15600)

- [cli/new] Strip credentials and query strings from template URLs saved
to project
  [#15586](#15586)

- [engine] Fix an issue where snapshots could become invalid when doing
a targeted up
  [#15476](#15476)

- [sdk/python] Fix determining plugins for old packages in the Python
language host
  [#15576](#15576)

- [pkg/testing] Make ProgramTest use a temporary PULUMI_HOME for each
test
  [#15568](#15568)

- [sdkgen/dotnet] Codegen fix for resources without constant input
properties
  [#15488](#15488)
@justinvp justinvp mentioned this pull request Mar 7, 2024
github-merge-queue bot pushed a commit that referenced this pull request Mar 7, 2024
Draft changelog:

### Features

- [auto/{go,nodejs,python}] Add support for suppress progress and
suppress outputs parameters in the Automation API
  [#15596](#15596)

- [pkg] Make schema.NewPluginLoader respect PULUMI_DEBUG_PROVIDERS,
which enables Pulumi YAML programs to work correctly with this feature
  [#15526](#15526)

- [sdk/dotnet] Update dotnet language host to 3.60.0
  [#15609](#15609)

- [sdk/nodejs] Add experimental support to the NodeJS SDK for the new
transforms system.
  [#15532](#15532)

- [sdk/python] Add support for asynchronous invokes via a new
`invoke_async` function
  [#15602](#15602)

- [sdkgen/dotnet] Support for non-overlay components in codegen for
pulumi-kubernetes provider
  [#15490](#15490)


### Bug Fixes

- [cli] Fix a panic when the secrets provider is missing from the
deployment snapshot
  [#15599](#15599)

- [backend/service] Make decrypt/encrypt network calls retryable to help
work around network hiccups
  [#15600](#15600)

- [cli/new] Strip credentials and query strings from template URLs saved
to project
  [#15586](#15586)

- [engine] Fix an issue where snapshots could become invalid when doing
a targeted up
  [#15476](#15476)

- [pkg/testing] Make ProgramTest use a temporary PULUMI_HOME for each
test
  [#15568](#15568)

- [sdkgen/dotnet] Codegen fix for resources without constant input
properties
  [#15488](#15488)

- [sdk/nodejs] Properly capture node:crypto and global.crypto in node
19+

- [sdk/python] Fix determining plugins for old packages in the Python
language host
  [#15576](#15576)
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 impact/no-changelog-required This issue doesn't require a CHANGELOG update kind/enhancement Improvements or new features language/dotnet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants