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

[Question] Why parsing yaml to the resource duplicates kind property? #76

Open
snowdrop-bot opened this issue Jun 16, 2021 · 0 comments

Comments

@snowdrop-bot
Copy link

Hi.
I am using the vsion 5.4.0.I have a custom resource defined as

public class MyResource extends CustomResource<MyResourceSpec, MyResourceStatus> implements Namespaced, UnknownPropertyPreserving { ... }

In my test, I am trying to parse yaml into the object of this class. So I am doing similar

class TestClass<T extends HasMetadata,
        L extends KubernetesResource & KubernetesResourceList,
        R extends Resource<T>> {

    protected T copyResource(T resource) {
            ObjectMapper objectMapper = new ObjectMapper();
            try {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                objectMapper.writeValue(baos, resource);
                return (T) objectMapper.readValue(baos.toByteArray(), resource.getClass());
            } catch (IOException e) {
                return null;
            }
    }
}

However, the mapper writes an object with a duplicate kind property. For example:

---
apiVersion: "my.org/v1alpha1"
kind: "MyResource"
metadata:
  name: "my-resouce"
  namespace: "default"
spec:
  property: value
kind: "MyResource"

I think kubernetes API does cope with duplicities in the resource yaml, however I do have issues in my test suite. Do you have any idea what has been changed in this regard? The version of jackson has not changed, so it has to be something about CustomResource class. Thank you


fabric8io#3195


$upstream:3195$

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

2 participants