-
Notifications
You must be signed in to change notification settings - Fork 17
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
CRDS Gross type name generated in Python SDK for network policy #107
Comments
Found a similar issue, where |
The SDK generators generally expect type and property names in the Pulumi schema to be PascalCase and camelCase respectively. Type NamesFor type names, there's no reason why Right now the in-memory representation of the schema that "types": {
"kubernetes:juice.box.com/v1alpha1:NetworkPolicySpecApps_incoming": {
}
} When instead it could be named as: "types": {
"kubernetes:juice.box.com/v1alpha1:NetworkPolicySpecAppsIncoming": {
}
} Property NamesFor property names, I don't think So for a property like For Python, the property will be emitted in the SDK as type NetworkPolicySpecArgs struct {
Apps_incoming NetworkPolicySpecAppsIncomingArrayInput `pulumi:"apps_incoming"`
} export interface NetworkPolicySpecArgs {
apps_incoming?: pulumi.Input<pulumi.Input<inputs.juice.v1alpha1.NetworkPolicySpecAppsIncomingArgs>[]>;
} For Go, we could consider changing the SDK gen to make However, I don't think we can do anything for TypeScript right now since there isn't currently a way to add extra metadata to indicate a different name to use during marshaling, so it'd have to remain |
Thanks for the added context, @justinvp - it seems like we ought to be able to do as much as we can here (in |
It looks like there may not be much action item within the For example:
GVK: Furthermore, official k8s API naming conventions strongly suggest that camel casing should be used for field names. @kpitzen WDYT would be the next best steps here? |
I think the fix is as simple as this: f90e016 With that change, I get: __all__ = [
'NetworkPolicySpecAppsIncomingArgs',
'NetworkPolicySpecAppsOutgoingArgs',
'NetworkPolicySpecNamespacesIncomingArgs',
'NetworkPolicySpecNamespacesOutgoingArgs',
'NetworkPolicySpecArgs',
] |
This isn't about changing the names of resources. It's about changing the names of nested types, which get erased when the values are serialized and sent to the engine (they essentially turn into a map[string]any). These type names will not be displayed as part of a Pulumi operation. |
@justinvp Ah, gotcha. Yes, I believe that one line fix would do it. I was testing with a simplified CRD, that didn't have nested fields, so there were no nested types to modify. Thanks for the clarification. Do you want to submit a PR for that change? |
What happened?
CRD has fields named with underscores: For example, the networkpolicy.yaml will have:
The main thing is the
_
inapps_incoming
.We need to translate lower snake case to camel and back dynamically.
The fields to be named properly per language, but translate back to the proper names in the provider.
This is what the
networkpolicies/pulumi_crds/juice/v1alpha1/_inputs.py
will end up as after crd2pulumi is ran:This is what the
networkpolicies/pulumi_crds/juice/v1alpha1/outputs.py
will end up as:Expected Behavior
When using the snippet below
after running crd2pulumi, the python generated code at:
networkpolicies/pulumi_crds/juice/v1alpha1/__inputs.py
would show up as:There are no
_
anymore and now everything is camelCase.The code for
networkpolicies/pulumi_crds/juice/v1alpha1/outputs.py
would also be correct:There are no
_
anymore and now everything is camelCase.Steps to reproduce
networkpolicy.yaml
with the following code:Run
crd2pulumi --pythonPath ./networkpolicies networkpolicy.yaml
Check out the new crds that are created:
cd networkpolicies/pulumi_crds/pulumi_crds/juice/v1alpha1
Go to where the
_inputs.py outputs.py
are:cd networkpolicies/pulumi_crds/juice/v1alpha1/
The output for
_inputs.py
will show up in theall
block as:Notice that there is a
_
and no camelCasing for the first 4 items.The output from
outputs.py
will show up asNotice that there is a
_
and no camelCasing for the last 4 items.Output of
pulumi about
Output from
❯ crd2pulumi version
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).
The text was updated successfully, but these errors were encountered: