Title: No GenericResources in ServiceSpec.TaskTemplate.Resources.Reservations · Issue #2320 · docker-java/docker-java · GitHub
Open Graph Title: No GenericResources in ServiceSpec.TaskTemplate.Resources.Reservations · Issue #2320 · docker-java/docker-java
X Title: No GenericResources in ServiceSpec.TaskTemplate.Resources.Reservations · Issue #2320 · docker-java/docker-java
Description: I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't see a way to use it in docker-java: whe...
Open Graph Description: I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't...
X Description: I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but...
Opengraph URL: https://github.com/docker-java/docker-java/issues/2320
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"No GenericResources in ServiceSpec.TaskTemplate.Resources.Reservations","articleBody":"I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't see a way to use it in docker-java: when creating a service I want to be able to define `GenericResource`s (`NamedResourceSpec` or `DiscreteResourceSpec`) in `ServiceSpec.TaskTemplate.Resources.Reservations`.\r\n\r\nUsing the spotify client, this is the type of thing I could do\r\n```java\r\nfinal Map\u003cString, String\u003e genericResources; // Assume this is defined somewhere\r\nfinal List\u003cResourceSpec\u003e resourceSpecs = genericResources.entrySet().stream()\r\n .map(entry -\u003e StringUtils.isNumeric(entry.getValue()) ?\r\n ResourceSpec.DiscreteResourceSpec.builder().kind(entry.getKey()).value(Integer.parseInt(entry.getValue())).build() :\r\n ResourceSpec.NamedResourceSpec.builder().kind(entry.getKey()).value(entry.getValue()).build())\r\n .collect(Collectors.toList());\r\nfinal ResourceRequirements resourceRequirements =\r\n ResourceRequirements.builder()\r\n .reservations(Reservations.builder()\r\n .resources(resourceSpecs)\r\n .build())\r\n .build();\r\nfinal TaskSpec taskSpec = TaskSpec.builder()\r\n .resources(resourceRequirements)\r\n .build();\r\nfinal ServiceSpec serviceSpec = ServiceSpec.builder()\r\n .taskTemplate(taskSpec)\r\n .build();\r\n// then pass this to the client to create a service\r\n```\r\nIn the docker-java client I can do similar things, but I can't see a way to pass generic resources to the task spec.\r\n```java\r\nnew TaskSpec().withResources(\r\n new ResourceRequirements().withReservations(\r\n new ResourceSpecs().with...? // There is nothing here that takes generic resources\r\n )\r\n);\r\n```\r\nI do see `abstract class GenericResource\u003cT\u003e` and its concrete implementations `NamedResourceSpec` and `DiscreteResourceSpec` in `com.github.dockerjava.api.model`. But it looks to me like those are only used to deserialize `Task` responses received from the API, not used to create new services in a `TaskSpec`.\r\n\r\nAlso `NamedResourceSpec` and `DiscreteResourceSpec` are both marked `@Deprecated` but I can't understand why. That annotation was added to those classes in #1635 but I can't see it mentioned in any of the commits or the discussion.\r\n\r\nIs there some reason this isn't supported? It is part of the docker API and has been for quite some time. Alternatively, is there a workaround I could do to inject these generic resource specs directly into the API calls before they are sent? (I'm still getting used to the new(-to-me) way of working with docker-java, so I don't know what low-level tricks I can pull.) ","author":{"url":"https://github.com/johnflavin-fw","@type":"Person","name":"johnflavin-fw"},"datePublished":"2024-04-19T20:19:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2320/docker-java/issues/2320"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:00e76ac5-bc8e-3d91-4093-5deccd5b9465 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D4CE:B411C:6593F2C:8A7C6D1:6973561A |
| html-safe-nonce | 9cf5917c88169d14df38f0dce95a597fa9944622d4cf9c73e011606e02029305 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENENFOkI0MTFDOjY1OTNGMkM6OEE3QzZEMTo2OTczNTYxQSIsInZpc2l0b3JfaWQiOiIyNzM0MTk2NTYyMDIyNTg1ODgyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5367fac87d92ce1e52c2c39e9fff096ac86fd4a5979a2360fd3b2fe73fd879fd |
| hovercard-subject-tag | issue:2253905945 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/docker-java/docker-java/2320/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9eeadd7aa6294126b7f80b59df25cdff02fb6a1c6f289e546a4850f56cf0e3b1/docker-java/docker-java/issues/2320 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9eeadd7aa6294126b7f80b59df25cdff02fb6a1c6f289e546a4850f56cf0e3b1/docker-java/docker-java/issues/2320 |
| og:image:alt | I'm migrating some code that was written using https://github.com/spotify/docker-client over to docker-java. I've found a part of the Docker API that was supported in the spotify client but I can't... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | johnflavin-fw |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4cf879a11b0a28a85543899a36aaee9ec9ca2fb7bedad86c0da5731193c95f01 |
| turbo-cache-control | no-preview |
| go-import | github.com/docker-java/docker-java git https://github.com/docker-java/docker-java.git |
| octolytics-dimension-user_id | 7772003 |
| octolytics-dimension-user_login | docker-java |
| octolytics-dimension-repository_id | 20415251 |
| octolytics-dimension-repository_nwo | docker-java/docker-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20415251 |
| octolytics-dimension-repository_network_root_nwo | docker-java/docker-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 63c75712c8aa15b01c097cbf3f10ca694d449599 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width