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

io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps does not retain extensions #3182

Closed
lburgazzoli opened this issue May 27, 2021 · 8 comments

Comments

@lburgazzoli
Copy link
Contributor

i.e. there's no way to get the value of x-descriptors

  accessKey:
    title: Access Key
    description: The access key obtained from AWS
    type: string
    format: password
    x-descriptors:
    - urn:alm:descriptor:com.tectonic.ui:password

Looking at the JSONSchemaProps class, it looks like it handle a specific set of json extensions.

Would be nice to have a generic support for extensions.

@lburgazzoli lburgazzoli changed the title io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps does not retain extensions #284 io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps does not retain extensions May 27, 2021
@lburgazzoli
Copy link
Contributor Author

Original issue: apache/camel-kamelets#284

@manusa
Copy link
Member

manusa commented Jun 14, 2021

That's a generated class, is your field be available in the additionalProperties?

@lburgazzoli
Copy link
Contributor Author

lburgazzoli commented Jun 14, 2021

I've tried with this:

///usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS org.slf4j:slf4j-simple:1.7.30
//DEPS io.fabric8:kubernetes-client:5.4.1
//DEPS io.fabric8:camel-k-model-v1alpha1:5.4.1

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import io.fabric8.camelk.v1alpha1.Kamelet;
import io.fabric8.kubernetes.client.utils.Serialization;

class kl {
    public static String KAMELET = ""
        + "apiVersion: camel.apache.org/v1alpha1\n"
        + "kind: Kamelet\n"
        + "metadata:\n"
        + "  name: aws-s3-sink\n"
        + "spec:\n"
        + "  definition:\n"
        + "    type: object\n"
        + "    properties:\n"
        + "      accessKey:\n"
        + "        type: string\n"
        + "        format: password\n"
        + "        x-descriptors:\n"
        + "          - urn:alm:descriptor:com.tectonic.ui:password\n";
    
    public static void main(String... args) throws Exception {
        try (var is = new ByteArrayInputStream(KAMELET.getBytes(StandardCharsets.UTF_8))) {
            var result = Serialization.unmarshal(is, Kamelet.class);

            System.out.println("> " + result);
        }
    }
}

And what I get is an exception caused by:

com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: 
Unrecognized field "x-descriptors" (class io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps), 
not marked as ignorable 
(43 known properties: "definitions", "default", "x-kubernetes-list-map-keys", "$schema", "multipleOf", "x-kubernetes-int-or-string", "minItems", "exclusiveMinimum", "not", "allOf", "additionalItems", "id", "oneOf", "required", "maximum", "nullable", "exclusiveMaximum", "anyOf", "minProperties", "externalDocs", "dependencies", "example", "x-kubernetes-preserve-unknown-fields", "$ref", "properties", "format", "additionalProperties", "description", "enum", "minimum", "pattern", "minLength", "x-kubernetes-map-type", "x-kubernetes-embedded-resource", "patternProperties", "maxLength", "uniqueItems", "maxProperties", "type", "maxItems", "items", "title", "x-kubernetes-list-type"])

@rohanKanojia
Copy link
Member

I'm not able to find x-descriptors field in equivalent go struct: https://github.com/kubernetes/apiextensions-apiserver/blob/master/pkg/apis/apiextensions/v1/types_jsonschema.go#L20

@lburgazzoli
Copy link
Contributor Author

lburgazzoli commented Jun 14, 2021

It is a our own JSON Schema extension, is not part of k8s but should be put in additionalProperties I guess as there is a https://github.com/apache/camel-k/blob/main/config/crd/bases/camel.apache.org_kamelets.yaml#L82 (not sure if that is on the right position but does not fails in camel-k)

@iocanel
Copy link
Member

iocanel commented Jun 14, 2021

We can probably configure jackson to be more relax. I think that in this case the x-descriptors will end up under addtionalProperties. How would that work for you @lburgazzoli ?

@lburgazzoli
Copy link
Contributor Author

that would be perfectly fine with me

@stale
Copy link

stale bot commented Sep 12, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Sep 12, 2021
@stale stale bot closed this as completed Sep 19, 2021
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Apr 13, 2022
…Exception (fabric8io#3852)

Kamelet resource seems to be using JSONSchemaProps. However, this
JSONSchemaProps is not coming from Apiextensions. Camel repository seems
to have it's own version of JSONSchemaProps. It contains some additional
fields like `x-descriptors`. We've currently added a manual type mapping
of JSONSchemaProps to `io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps`
This works for most cases but doesn't work when some camel specific
fields are used in Kamelet (like in case of fabric8io#3852, fabric8io#3182).

Use CamelK's JSONSchemaProps instead of Apiextensions JSONSchemaProps.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Apr 26, 2022
…Exception (fabric8io#3852)

Kamelet resource seems to be using JSONSchemaProps. However, this
JSONSchemaProps is not coming from Apiextensions. Camel repository seems
to have it's own version of JSONSchemaProps. It contains some additional
fields like `x-descriptors`. We've currently added a manual type mapping
of JSONSchemaProps to `io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps`
This works for most cases but doesn't work when some camel specific
fields are used in Kamelet (like in case of fabric8io#3852, fabric8io#3182).

Use CamelK's JSONSchemaProps instead of Apiextensions JSONSchemaProps.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
manusa pushed a commit that referenced this issue Apr 26, 2022
…Exception (#3852)

Kamelet resource seems to be using JSONSchemaProps. However, this
JSONSchemaProps is not coming from Apiextensions. Camel repository seems
to have it's own version of JSONSchemaProps. It contains some additional
fields like `x-descriptors`. We've currently added a manual type mapping
of JSONSchemaProps to `io.fabric8.kubernetes.api.model.apiextensions.v1.JSONSchemaProps`
This works for most cases but doesn't work when some camel specific
fields are used in Kamelet (like in case of #3852, #3182).

Use CamelK's JSONSchemaProps instead of Apiextensions JSONSchemaProps.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants