-
Notifications
You must be signed in to change notification settings - Fork 115
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
Issue with x_kubernetes_preserve_unknown_fields in java com.pulumi.kubernetes.apiextensions.v1.CustomResourceDefinition #3325
Comments
@elonazoulay what version of |
Simply put, the Lines 716 to 721 in d440f53
|
Repro package myproject;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.kubernetes.apiextensions.v1.CustomResourceDefinition;
import com.pulumi.kubernetes.apiextensions.v1.CustomResourceDefinitionArgs;
import com.pulumi.kubernetes.apiextensions.v1.inputs.CustomResourceDefinitionNamesArgs;
import com.pulumi.kubernetes.apiextensions.v1.inputs.CustomResourceDefinitionVersionArgs;
import com.pulumi.kubernetes.apiextensions.v1.inputs.CustomResourceDefinitionSpecArgs;
import com.pulumi.kubernetes.apiextensions.v1.inputs.CustomResourceValidationArgs;
import com.pulumi.kubernetes.meta.v1.inputs.ObjectMetaArgs;
import com.pulumi.kubernetes.apiextensions.v1.inputs.JSONSchemaPropsArgs;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
Pulumi.run(Main::stack);
}
public static void stack(Context ctx) {
var metadata = ObjectMetaArgs.builder()
.name("crds.example.com")
.build();
var spec = CustomResourceDefinitionSpecArgs.builder()
.group("example.com")
.scope("Namespaced")
.names(CustomResourceDefinitionNamesArgs.builder()
.kind("MyCRD")
.plural("mycrds")
.singular("mycrd")
.shortNames("mycrd")
.build())
.versions(CustomResourceDefinitionVersionArgs.builder()
.name("v1")
.served(true)
.storage(true)
.schema(CustomResourceValidationArgs.builder()
.openAPIV3Schema(JSONSchemaPropsArgs.builder()
.type("object")
.properties(new HashMap<String, JSONSchemaPropsArgs>() {
{
put("key", JSONSchemaPropsArgs.builder()
.x_kubernetes_preserve_unknown_fields(true)
.build());
}
}).build())
.build())
.build())
.build();
new CustomResourceDefinition("crd",
CustomResourceDefinitionArgs.builder()
.metadata(metadata)
.spec(spec)
.build());
}
} |
Properties containing punctuation (like hyphens) aren't generally supported due to pulumi/pulumi#15874. In other words I don't think we can fix this for Java without also breaking Node and Dotnet. As a workaround, you could specify the CRD as a YAML manifest and apply it via something like a ConfigFile resource. |
What happened?
I am attempting to create a CustomResourceDefinition that has a field with
x-kubernetes-preserve-unknown-fields
set to true via thex_kubernetes_preserve_unknown_fields
method and expected the resource to be created but instead get the following error:If I remove the fields in the example below that contain
x_kubernetes_preserve_unknown_fields
it works.Example
This is the removed portion of the spec:
Which is the equivalent of the following yaml (which does work with kubectl apply -f):
Output of
pulumi about
CLI
Version 3.137.0
Go Version go1.23.2
Go Compiler gc
Plugins
KIND NAME VERSION
language java unknown
Host
OS darwin
Version 14.6.1
Arch arm64
This project is written in java: executable='/Users/elon.azoulay/.jenv/shims/java' version='openjdk 22.0.2 2024-07-16
OpenJDK Runtime Environment Temurin-22.0.2+9 (build 22.0.2+9)
OpenJDK 64-Bit Server VM Temurin-22.0.2+9 (build 22.0.2+9, mixed mode)' maven='Apache Maven 3.9.9 ()' gradle='8.11' java='/Users/elon.azoulay/.jenv/shims/java' javac='22.0.2'
Backend
Name pulumi.com
URL https://app.pulumi.com/elonazoulay
User elonazoulay
Organizations elonazoulay, starburstdata
Token type personal
No dependencies found
Pulumi locates its logs in /var/folders/5q/524n82557j5_bh2vy4pwr0d00000gq/T/ by default
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: