| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,9 @@ public interface CreateVolumeCmd extends SyncDockerCmd<CreateVolumeResponse> { | |||
| 9 | 9 | @CheckForNull | |
| 10 | 10 | String getName(); | |
| 11 | 11 | ||
| 12 | + @CheckForNull | ||
| 13 | + Map<String, String> getLabels(); | ||
| 14 | + | ||
| 12 | 15 | @CheckForNull | |
| 13 | 16 | String getDriver(); | |
| 14 | 17 | ||
@@ -21,6 +24,12 @@ public interface CreateVolumeCmd extends SyncDockerCmd<CreateVolumeResponse> { | |||
| 21 | 24 | */ | |
| 22 | 25 | CreateVolumeCmd withName(String name); | |
| 23 | 26 | ||
| 27 | + /** | ||
| 28 | + * @param labels | ||
| 29 | + * - A mapping of labels keys and values. Labels are a mechanism for applying metadata to Docker objects. | ||
| 30 | + */ | ||
| 31 | + CreateVolumeCmd withLabels(Map<String, String> labels); | ||
| 32 | + | ||
| 24 | 33 | /** | |
| 25 | 34 | * @param driver | |
| 26 | 35 | * - Name of the volume driver to use. Defaults to local for the name. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | import lombok.EqualsAndHashCode; | |
| 5 | 5 | import lombok.ToString; | |
| 6 | 6 | ||
| 7 | + import java.util.Map; | ||
| 8 | + | ||
| 7 | 9 | /** | |
| 8 | 10 | * | |
| 9 | 11 | * @author Marcus Linke | |
@@ -15,6 +17,9 @@ public class CreateVolumeResponse { | |||
| 15 | 17 | @JsonProperty("Name") | |
| 16 | 18 | private String name; | |
| 17 | 19 | ||
| 20 | + @JsonProperty("Labels") | ||
| 21 | + private Map<String, String> labels; | ||
| 22 | + | ||
| 18 | 23 | @JsonProperty("Driver") | |
| 19 | 24 | private String driver; | |
| 20 | 25 | ||
@@ -25,6 +30,10 @@ public String getName() { | |||
| 25 | 30 | return name; | |
| 26 | 31 | } | |
| 27 | 32 | ||
| 33 | + public Map<String, String> getLabels() { | ||
| 34 | + return labels; | ||
| 35 | + } | ||
| 36 | + | ||
| 28 | 37 | public String getDriver() { | |
| 29 | 38 | return driver; | |
| 30 | 39 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | import lombok.EqualsAndHashCode; | |
| 5 | 5 | import lombok.ToString; | |
| 6 | 6 | ||
| 7 | + import java.util.Map; | ||
| 8 | + | ||
| 7 | 9 | /** | |
| 8 | 10 | * | |
| 9 | 11 | * @author Marcus Linke | |
@@ -15,6 +17,9 @@ public class InspectVolumeResponse { | |||
| 15 | 17 | @JsonProperty("Name") | |
| 16 | 18 | private String name; | |
| 17 | 19 | ||
| 20 | + @JsonProperty("Labels") | ||
| 21 | + private Map<String, String> labels; | ||
| 22 | + | ||
| 18 | 23 | @JsonProperty("Driver") | |
| 19 | 24 | private String driver; | |
| 20 | 25 | ||
@@ -25,6 +30,10 @@ public String getName() { | |||
| 25 | 30 | return name; | |
| 26 | 31 | } | |
| 27 | 32 | ||
| 33 | + public Map<String, String> getLabels() { | ||
| 34 | + return labels; | ||
| 35 | + } | ||
| 36 | + | ||
| 28 | 37 | public String getDriver() { | |
| 29 | 38 | return driver; | |
| 30 | 39 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,6 +19,9 @@ public class CreateVolumeCmdImpl extends AbstrDockerCmd<CreateVolumeCmd, CreateV | |||
| 19 | 19 | @JsonProperty("Name") | |
| 20 | 20 | private String name; | |
| 21 | 21 | ||
| 22 | + @JsonProperty("Labels") | ||
| 23 | + private Map<String, String> labels; | ||
| 24 | + | ||
| 22 | 25 | @JsonProperty("Driver") | |
| 23 | 26 | private String driver; | |
| 24 | 27 | ||
@@ -34,6 +37,11 @@ public String getName() { | |||
| 34 | 37 | return name; | |
| 35 | 38 | } | |
| 36 | 39 | ||
| 40 | + @Override | ||
| 41 | + public Map<String, String> getLabels() { | ||
| 42 | + return labels; | ||
| 43 | + } | ||
| 44 | + | ||
| 37 | 45 | @Override | |
| 38 | 46 | public String getDriver() { | |
| 39 | 47 | return driver; | |
@@ -51,6 +59,13 @@ public CreateVolumeCmdImpl withName(String name) { | |||
| 51 | 59 | return this; | |
| 52 | 60 | } | |
| 53 | 61 | ||
| 62 | + @Override | ||
| 63 | + public CreateVolumeCmdImpl withLabels(Map<String, String> labels) { | ||
| 64 | + checkNotNull(labels, "labels was not specified"); | ||
| 65 | + this.labels = labels; | ||
| 66 | + return this; | ||
| 67 | + } | ||
| 68 | + | ||
| 54 | 69 | @Override | |
| 55 | 70 | public CreateVolumeCmdImpl withDriver(String driver) { | |
| 56 | 71 | checkNotNull(driver, "driver was not specified"); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,6 +4,8 @@ | |||
| 4 | 4 | import com.github.dockerjava.api.exception.DockerException; | |
| 5 | 5 | import org.junit.Test; | |
| 6 | 6 | ||
| 7 | + import java.util.Collections; | ||
| 8 | + | ||
| 7 | 9 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 8 | 10 | import static org.hamcrest.Matchers.containsString; | |
| 9 | 11 | import static org.hamcrest.Matchers.equalTo; | |
@@ -16,10 +18,11 @@ public void createVolume() throws DockerException { | |||
| 16 | 18 | String volumeName = "volume1"; | |
| 17 | 19 | ||
| 18 | 20 | CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName(volumeName) | |
| 19 | - .withDriver("local").exec(); | ||
| 21 | + .withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 20 | 22 | ||
| 21 | 23 | assertThat(createVolumeResponse.getName(), equalTo(volumeName)); | |
| 22 | 24 | assertThat(createVolumeResponse.getDriver(), equalTo("local")); | |
| 25 | + assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 23 | 26 | assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/")); | |
| 24 | 27 | } | |
| 25 | 28 | ||
@@ -29,17 +32,19 @@ public void createVolumeWithExistingName() throws DockerException { | |||
| 29 | 32 | String volumeName = "volume1"; | |
| 30 | 33 | ||
| 31 | 34 | CreateVolumeResponse createVolumeResponse1 = dockerRule.getClient().createVolumeCmd().withName(volumeName) | |
| 32 | - .withDriver("local").exec(); | ||
| 35 | + .withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 33 | 36 | ||
| 34 | 37 | assertThat(createVolumeResponse1.getName(), equalTo(volumeName)); | |
| 35 | 38 | assertThat(createVolumeResponse1.getDriver(), equalTo("local")); | |
| 39 | + assertThat(createVolumeResponse1.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 36 | 40 | assertThat(createVolumeResponse1.getMountpoint(), containsString("/volume1/")); | |
| 37 | 41 | ||
| 38 | 42 | CreateVolumeResponse createVolumeResponse2 = dockerRule.getClient().createVolumeCmd().withName(volumeName) | |
| 39 | - .withDriver("local").exec(); | ||
| 43 | + .withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 40 | 44 | ||
| 41 | 45 | assertThat(createVolumeResponse2.getName(), equalTo(volumeName)); | |
| 42 | 46 | assertThat(createVolumeResponse2.getDriver(), equalTo("local")); | |
| 47 | + assertThat(createVolumeResponse2.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 43 | 48 | assertThat(createVolumeResponse2.getMountpoint(), equalTo(createVolumeResponse1.getMountpoint())); | |
| 44 | 49 | } | |
| 45 | 50 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ | |||
| 5 | 5 | import com.github.dockerjava.api.exception.NotFoundException; | |
| 6 | 6 | import org.junit.Test; | |
| 7 | 7 | ||
| 8 | + import java.util.Collections; | ||
| 9 | + | ||
| 8 | 10 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 9 | 11 | import static org.hamcrest.Matchers.containsString; | |
| 10 | 12 | import static org.hamcrest.Matchers.equalTo; | |
@@ -16,12 +18,14 @@ public void inspectVolume() throws DockerException { | |||
| 16 | 18 | ||
| 17 | 19 | String volumeName = "volume1"; | |
| 18 | 20 | ||
| 19 | - dockerRule.getClient().createVolumeCmd().withName(volumeName).withDriver("local").exec(); | ||
| 21 | + dockerRule.getClient().createVolumeCmd().withName(volumeName).withDriver("local") | ||
| 22 | + .withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 20 | 23 | ||
| 21 | 24 | InspectVolumeResponse inspectVolumeResponse = dockerRule.getClient().inspectVolumeCmd(volumeName).exec(); | |
| 22 | 25 | ||
| 23 | 26 | assertThat(inspectVolumeResponse.getName(), equalTo("volume1")); | |
| 24 | 27 | assertThat(inspectVolumeResponse.getDriver(), equalTo("local")); | |
| 28 | + assertThat(inspectVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 25 | 29 | assertThat(inspectVolumeResponse.getMountpoint(), containsString("/volume1/")); | |
| 26 | 30 | } | |
| 27 | 31 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ | |||
| 5 | 5 | import com.github.dockerjava.api.exception.DockerException; | |
| 6 | 6 | import org.junit.Test; | |
| 7 | 7 | ||
| 8 | + import java.util.Collections; | ||
| 9 | + | ||
| 8 | 10 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 9 | 11 | import static org.hamcrest.Matchers.containsString; | |
| 10 | 12 | import static org.hamcrest.Matchers.equalTo; | |
@@ -16,10 +18,11 @@ public class ListVolumesCmdIT extends CmdIT { | |||
| 16 | 18 | public void listVolumes() throws DockerException { | |
| 17 | 19 | ||
| 18 | 20 | CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName("volume1") | |
| 19 | - .withDriver("local").exec(); | ||
| 21 | + .withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 20 | 22 | ||
| 21 | 23 | assertThat(createVolumeResponse.getName(), equalTo("volume1")); | |
| 22 | 24 | assertThat(createVolumeResponse.getDriver(), equalTo("local")); | |
| 25 | + assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 23 | 26 | assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/")); | |
| 24 | 27 | ||
| 25 | 28 | ListVolumesResponse listVolumesResponse = dockerRule.getClient().listVolumesCmd().exec(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ | |||
| 5 | 5 | import com.github.dockerjava.api.exception.NotFoundException; | |
| 6 | 6 | import org.junit.Test; | |
| 7 | 7 | ||
| 8 | + import java.util.Collections; | ||
| 9 | + | ||
| 8 | 10 | import static org.hamcrest.MatcherAssert.assertThat; | |
| 9 | 11 | import static org.hamcrest.Matchers.containsString; | |
| 10 | 12 | import static org.hamcrest.Matchers.equalTo; | |
@@ -19,10 +21,12 @@ public void removeVolume() throws DockerException { | |||
| 19 | 21 | ||
| 20 | 22 | CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd() | |
| 21 | 23 | .withName(volumeName) | |
| 22 | - .withDriver("local").exec(); | ||
| 24 | + .withDriver("local") | ||
| 25 | + .withLabels(Collections.singletonMap("is-timelord", "yes")).exec(); | ||
| 23 | 26 | ||
| 24 | 27 | assertThat(createVolumeResponse.getName(), equalTo(volumeName)); | |
| 25 | 28 | assertThat(createVolumeResponse.getDriver(), equalTo("local")); | |
| 29 | + assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes"))); | ||
| 26 | 30 | assertThat(createVolumeResponse.getMountpoint(), containsString(volumeName)); | |
| 27 | 31 | ||
| 28 | 32 | dockerRule.getClient().removeVolumeCmd(volumeName).exec(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments