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

Cannot load resource from stream without apiVersion #2316

Closed
sbaier1 opened this issue Jun 26, 2020 · 1 comment · Fixed by #2374
Closed

Cannot load resource from stream without apiVersion #2316

sbaier1 opened this issue Jun 26, 2020 · 1 comment · Fixed by #2374
Assignees
Labels

Comments

@sbaier1
Copy link

sbaier1 commented Jun 26, 2020

I am rendering a template and loading the resulting resource directly as inputstream. When loading the resource directly, in version 4.10.1 it was previously possible to simply specify kind: Deployment and have the client figure out the apiVersion. Since 4.10.2 this leads to a Jackson deserialization error. I am not sure whether this implied change of behavior was intended, but here's a simple reproducer for the problem that will throw the exception on 4.10.2 but work on 4.10.1.

I understand that just specifying the apiVersion as apps/v1 works in this case, but i am not sure if this change was intended.

    @Test
    public void testTemplate() {
        final DefaultKubernetesClient client = new DefaultKubernetesClient();

        final String deployment = "kind: Deployment\n" +
                "metadata:\n" +
                "  name: \"test\"\n" +
                "  labels:\n" +
                "    app: \"test\"\n" +
                "spec:\n" +
                "  selector:\n" +
                "    matchLabels:\n" +
                "      app: \"test\"\n" +
                "  replicas: \"1\"\n" +
                "  template:\n" +
                "    metadata:\n" +
                "      labels:\n" +
                "        app: \"test\"\n" +
                "    spec:\n" +
                "      containers:\n" +
                "        - name: \"test\"\n" +
                "          image: \"busybox:latest\"\n" +
                "          command: [\"/bin/sh\", \"-c\"]\n" +
                "          args:\n" +
                "            - |\n" +
                "             sleep 60";

        final var deploymentObject = client.load(new ByteArrayInputStream(deployment.getBytes()));
    }
@rohanKanojia rohanKanojia self-assigned this Jul 28, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 28, 2020
In case of duplicate Kubernetes resources found, when no apiVersion
is provided return first item found instead of null
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 28, 2020
In case of duplicate Kubernetes resources found, when no apiVersion
is provided return first item found instead of null
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Jul 28, 2020
In case of duplicate Kubernetes resources found, when no apiVersion
is provided return first item found instead of null
@manusa
Copy link
Member

manusa commented Apr 12, 2022

This behavior will be broken after #4039 is merged (#3993)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants