Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 33a58b6

Browse filesBrowse files
Parse prefixed Capability values (docker-java#2418)
Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com>
1 parent 1f1e60d commit 33a58b6
Copy full SHA for 33a58b6

2 files changed

+12-1Lines changed: 12 additions & 1 deletion

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java‎

Copy file name to clipboardExpand all lines: docker-java-api/src/main/java/com/github/dockerjava/api/model/Capability.java
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.dockerjava.api.model;
22

3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
35
/**
46
* The Linux capabilities supported by Docker. The list of capabilities is defined in Docker's types.go, {@link #ALL} was added manually.
57
*
@@ -299,5 +301,11 @@ public enum Capability {
299301
/**
300302
* Trigger something that will wake up the system (set CLOCK_REALTIME_ALARM and CLOCK_BOOTTIME_ALARM timers).
301303
*/
302-
WAKE_ALARM
304+
WAKE_ALARM;
305+
306+
@JsonCreator
307+
public static Capability fromValue(String cap) {
308+
String result = !cap.startsWith("CAP_") ? cap : cap.split("_", 2)[1];
309+
return Capability.valueOf(result);
310+
}
303311
}
Collapse file

‎docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java‎

Copy file name to clipboardExpand all lines: docker-java/src/test/java/com/github/dockerjava/api/model/CapabilityTest.java
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public void serializeCapability() throws Exception {
1818
public void deserializeCapability() throws Exception {
1919
Capability capability = JSONTestHelper.getMapper().readValue("\"ALL\"", Capability.class);
2020
assertEquals(Capability.ALL, capability);
21+
22+
Capability compatibleCapability = JSONTestHelper.getMapper().readValue("\"CAP_ALL\"", Capability.class);
23+
assertEquals(Capability.ALL, compatibleCapability);
2124
}
2225

2326
@Test(expected = JsonMappingException.class)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.