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

Yaml Util could not dump java.util.Map object which value is type of io.kubernetes.client.custom.Quantity #404

Closed
kayeez opened this issue Oct 25, 2018 · 5 comments

Comments

@kayeez
Copy link

kayeez commented Oct 25, 2018

Basic Information

  • Java client API version: 2.0.0

Reproduce Steps

  • write code as below
        V1Container container = new V1Container();
        V1ResourceRequirements redisResourceReq = new V1ResourceRequirements();
        Map<String, Quantity> requestQuantity = new HashMap<>();
        requestQuantity.put("memory", new Quantity("1Gi"));
        requestQuantity.put("cpu", new Quantity("0.5"));
        Map<String, Quantity> limitQuantity = new HashMap<>();
        limitQuantity.put("memory", new Quantity("4Gi"));
        limitQuantity.put("cpu", new Quantity("2"));
        redisResourceReq.requests(requestQuantity);
        redisResourceReq.limits(limitQuantity);
        container.resources(redisResourceReq);
        System.out.println(Yaml.getSnakeYaml().dump(container));
  • the output shows below
resources:
  limits:
    memory: {}
    cpu: {}
  requests:
    memory: {}
    cpu: {}
  • Expect:
resources:
  limits:
    memory: "1Gi"
    cpu: "0.5"
  requests:
    memory: "4Gi"
    cpu: "2"

As you can see , the Yaml util does't work as expected !
I have checked latest Yaml Util class
This class also doesn't work well .

@karthikkondapally
Copy link
Contributor

adding something like RepresentQuantity to yaml CustomRepresnter will print values

resources:
  limits:
    memory: 4Gi
    cpu: '2'
  requests:
    memory: 1Gi
    cpu: 500m

but it seems, values are loosing original format because of QunatityFormatter
will try to create a pr with this

@kayeez
Copy link
Author

kayeez commented Oct 31, 2018

@kondapally1989

I've slove this problem by create a CustomRepresnter !
But I wanna a common yaml dump util.

@davidxia
Copy link
Contributor

davidxia commented Nov 3, 2018

I created a failing test for this.

@davidxia
Copy link
Contributor

davidxia commented Nov 3, 2018

And a PR here #417.

@brendandburns
Copy link
Contributor

Fixed by #417

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

No branches or pull requests

4 participants