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

[Java SDK] use CustomResource by default to rehydrate a resource #3118

Open
EronWright opened this issue Jul 23, 2024 · 0 comments
Open

[Java SDK] use CustomResource by default to rehydrate a resource #3118

EronWright opened this issue Jul 23, 2024 · 0 comments
Labels
kind/bug Some behavior is incorrect or out of spec language/java

Comments

@EronWright
Copy link
Contributor

EronWright commented Jul 23, 2024

When a Java SDK program applies a manifest containing a custom resource (e.g. using ConfigGroup v2), the resultant resources output should contain an instance of com.pulumi.kubernetes.apiextensions.CustomResource, but doesn't. Well-known kinds like ConfigMap work as expected, but it appears that the SDK is unaware of the possibility of using CustomResource as a fallback. As a result, the resources array has incomplete information.

Example program snippet:

            var issuer = new ConfigGroup("example", ConfigGroupArgs.builder()
                .objs(Map.ofEntries(
                    Map.entry("apiVersion", "cert-manager.io/v1"),
                    Map.entry("kind", "Issuer"),
                    Map.entry("metadata", Map.ofEntries(
                        Map.entry("name", "my-issuer")
                    )),
                    Map.entry("spec", Map.ofEntries(
                        Map.entry("selfSigned", Map.ofEntries())
                    ))
                ))
                .build());

Debug logs show:

I0722 18:15:15.359646   88274 eventsink.go:59] Deserialize/ResourcePackages: can't find a resource: 'kubernetes:cert-manager.io/v1:Issuer'; version= urn=urn:pulumi:dev::issue-3057::kubernetes:yaml/v2:ConfigGroup$kubernetes:cert-manager.io/v1:Issuer::example:default/my-issuer

The relevant code snippet in pulumi-java is here. The code appears to scan the classpath for resource classes marked with the @ResourceType annotation.

Observe that com.pulumi.kubernetes.apiextensions.CustomResource does have a @ResourceType annotation, with an apparently useless value, given that no actual resource is of type kubernetes:apiextensions:CustomResource. When I authored CustomResource, I didn't know enough about the purpose of ResourceType.

@ResourceType(type="kubernetes:apiextensions:CustomResource")
public class CustomResource extends com.pulumi.resources.CustomResource {
}

I would suggest as a possible fix that the Java SDK allow for a given resource to be marked as the default, e.g.

@ResourceType(type="*")
@ResourceType(typeExpression="kubernetes:.+")
public class CustomResource extends com.pulumi.resources.CustomResource {
}
@EronWright EronWright added kind/bug Some behavior is incorrect or out of spec language/java needs-triage Needs attention from the triage team labels Jul 23, 2024
@rquitales rquitales removed the needs-triage Needs attention from the triage team label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec language/java
Projects
None yet
Development

No branches or pull requests

2 participants