Skip to content

Generating x-kubernetes-preserve-unknown-fields: true with JsonNode does not seems to be working #7215

@csviri

Description

@csviri

Describe the bug

CRD generator fails when try to generate with

public class ExampleSpec {
  JsonNode someValue;

  @JsonAnyGetter
  JsonNode getSomeValue() {
    return someValue;
  }

  @JsonAnySetter
  void setSomeValue(JsonNode value) {
    this.someValue = value;
  }
}

I get an error message:

Execution default of goal io.fabric8:crd-generator-maven-plugin:7.3.1:generate failed: java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Invalid 'any-getter' annotation on method getSomeValue(): return type is not instance of java.util.Map -> [Help 1]

see reproducer:
operator-framework/java-operator-sdk#2887

If I change it to map it does not generate the
x-kubernetes-preserve-unknown-fields: true attribute.
And in that case also the deserialization does not work.

Is there a workaround for this ATM?
What I want to achieve is to have arbitrary yaml property

Fabric8 Kubernetes Client version

7.3.1

Steps to reproduce

operator-framework/java-operator-sdk#2887

checkout this PR, run mvn clean install

Expected behavior

CRD is generated, CR is properly deserialized

Runtime

Kubernetes (vanilla)

Kubernetes API Server version

1.33

Environment

macOS

Fabric8 Kubernetes Client Logs

Additional context

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions