question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Free-Form Objects in crd generator

See original GitHub issue

Is your enhancement related to a problem? Please describe

I’m trying to create a spec property as a free-form object from my POJO but it seems that it’s not possible.

I wanted to add a map/object property that accepts any kind of value (string, int, objects…). I’ve tried in these ways

Map<String, ?> config; 
Map<String, Object> config; 

Both generate this schema:

config:
  additionalProperties:
    type: object         
  type: object

My goal is to generate instead

config:
  additionalProperties: {}
  type: object

or

config:
  additionalProperties: true
  type: object

Describe the solution you’d like

Be able to generate a spec like:

config:
  additionalProperties: true
  type: object

Describe alternatives you’ve considered

No response

Additional context

Using latest version

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nicoloboschicommented, Dec 5, 2022
1reaction
nicoloboschicommented, Nov 24, 2022

It looks like this is a valid workaround

@SchemaFrom(type = JsonNode.class)
Map<String, Object> config;

the generated schema

config:
  x-kubernetes-preserve-unknown-fields: true

this allows me to pass nested objects with any kind of values However the k8s data type validation is basically disabled so I’d retain this feature request since it would be the right way to do it

Read more comments on GitHub >

github_iconTop Results From Across the Web

GSOC 17: Making CustomResources in Kubernetes more ...
The custom resource instance is free-form JSON (possibly validated though with CRD validation), so we need to know the JSON paths to spec...
Read more >
Generating CRDs - The Kubebuilder Book
Generating CRDs. Kubebuilder uses a tool called controller-gen to generate utility code and Kubernetes object YAML, like CustomResourceDefinitions.
Read more >
Freeform board tasks - ServiceNow Docs
How search works: Punctuation and capital letters are ignored. Special characters like underscores (_) are removed.
Read more >
deepcopy-gen generates invalid code for interface{} #138
Declaring a map[string]interface{} member in a struct handled by deepcopy-gen generates invalid code. It seems there could be two options ...
Read more >
Creating an object from a custom resource definition
A custom resource definition (CRD) file defines your own object kinds and lets the API Server handle the entire lifecycle.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found