FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Labels for volume has been added by mazu-rok · Pull Request #1320 · docker-java/docker-java · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (8) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public interface CreateVolumeCmd extends SyncDockerCmd<CreateVolumeResponse> {
@CheckForNull
String getName();

@CheckForNull
Map<String, String> getLabels();

@CheckForNull
String getDriver();

Expand All @@ -21,6 +24,12 @@ public interface CreateVolumeCmd extends SyncDockerCmd<CreateVolumeResponse> {
*/
CreateVolumeCmd withName(String name);

/**
* @param labels
* - A mapping of labels keys and values. Labels are a mechanism for applying metadata to Docker objects.
*/
CreateVolumeCmd withLabels(Map<String, String> labels);

/**
* @param driver
* - Name of the volume driver to use. Defaults to local for the name.
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Map;

/**
*
* @author Marcus Linke
Expand All @@ -15,6 +17,9 @@ public class CreateVolumeResponse {
@JsonProperty("Name")
private String name;

@JsonProperty("Labels")
private Map<String, String> labels;

@JsonProperty("Driver")
private String driver;

Expand All @@ -25,6 +30,10 @@ public String getName() {
return name;
}

public Map<String, String> getLabels() {
return labels;
}

public String getDriver() {
return driver;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.Map;

/**
*
* @author Marcus Linke
Expand All @@ -15,6 +17,9 @@ public class InspectVolumeResponse {
@JsonProperty("Name")
private String name;

@JsonProperty("Labels")
private Map<String, String> labels;

@JsonProperty("Driver")
private String driver;

Expand All @@ -25,6 +30,10 @@ public String getName() {
return name;
}

public Map<String, String> getLabels() {
return labels;
}

public String getDriver() {
return driver;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class CreateVolumeCmdImpl extends AbstrDockerCmd<CreateVolumeCmd, CreateV
@JsonProperty("Name")
private String name;

@JsonProperty("Labels")
private Map<String, String> labels;

@JsonProperty("Driver")
private String driver;

Expand All @@ -34,6 +37,11 @@ public String getName() {
return name;
}

@Override
public Map<String, String> getLabels() {
return labels;
}

@Override
public String getDriver() {
return driver;
Expand All @@ -51,6 +59,13 @@ public CreateVolumeCmdImpl withName(String name) {
return this;
}

@Override
public CreateVolumeCmdImpl withLabels(Map<String, String> labels) {
checkNotNull(labels, "labels was not specified");
this.labels = labels;
return this;
}

@Override
public CreateVolumeCmdImpl withDriver(String driver) {
checkNotNull(driver, "driver was not specified");
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.github.dockerjava.api.exception.DockerException;
import org.junit.Test;

import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -16,10 +18,11 @@ public void createVolume() throws DockerException {
String volumeName = "volume1";

CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
.withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

assertThat(createVolumeResponse.getName(), equalTo(volumeName));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/"));
}

Expand All @@ -29,17 +32,19 @@ public void createVolumeWithExistingName() throws DockerException {
String volumeName = "volume1";

CreateVolumeResponse createVolumeResponse1 = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
.withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

assertThat(createVolumeResponse1.getName(), equalTo(volumeName));
assertThat(createVolumeResponse1.getDriver(), equalTo("local"));
assertThat(createVolumeResponse1.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(createVolumeResponse1.getMountpoint(), containsString("/volume1/"));

CreateVolumeResponse createVolumeResponse2 = dockerRule.getClient().createVolumeCmd().withName(volumeName)
.withDriver("local").exec();
.withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

assertThat(createVolumeResponse2.getName(), equalTo(volumeName));
assertThat(createVolumeResponse2.getDriver(), equalTo("local"));
assertThat(createVolumeResponse2.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(createVolumeResponse2.getMountpoint(), equalTo(createVolumeResponse1.getMountpoint()));
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.github.dockerjava.api.exception.NotFoundException;
import org.junit.Test;

import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -16,12 +18,14 @@ public void inspectVolume() throws DockerException {

String volumeName = "volume1";

dockerRule.getClient().createVolumeCmd().withName(volumeName).withDriver("local").exec();
dockerRule.getClient().createVolumeCmd().withName(volumeName).withDriver("local")
.withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

InspectVolumeResponse inspectVolumeResponse = dockerRule.getClient().inspectVolumeCmd(volumeName).exec();

assertThat(inspectVolumeResponse.getName(), equalTo("volume1"));
assertThat(inspectVolumeResponse.getDriver(), equalTo("local"));
assertThat(inspectVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(inspectVolumeResponse.getMountpoint(), containsString("/volume1/"));
}

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.github.dockerjava.api.exception.DockerException;
import org.junit.Test;

import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -16,10 +18,11 @@ public class ListVolumesCmdIT extends CmdIT {
public void listVolumes() throws DockerException {

CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd().withName("volume1")
.withDriver("local").exec();
.withDriver("local").withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

assertThat(createVolumeResponse.getName(), equalTo("volume1"));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(createVolumeResponse.getMountpoint(), containsString("/volume1/"));

ListVolumesResponse listVolumesResponse = dockerRule.getClient().listVolumesCmd().exec();
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.github.dockerjava.api.exception.NotFoundException;
import org.junit.Test;

import java.util.Collections;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
Expand All @@ -19,10 +21,12 @@ public void removeVolume() throws DockerException {

CreateVolumeResponse createVolumeResponse = dockerRule.getClient().createVolumeCmd()
.withName(volumeName)
.withDriver("local").exec();
.withDriver("local")
.withLabels(Collections.singletonMap("is-timelord", "yes")).exec();

assertThat(createVolumeResponse.getName(), equalTo(volumeName));
assertThat(createVolumeResponse.getDriver(), equalTo("local"));
assertThat(createVolumeResponse.getLabels(), equalTo(Collections.singletonMap("is-timelord", "yes")));
assertThat(createVolumeResponse.getMountpoint(), containsString(volumeName));

dockerRule.getClient().removeVolumeCmd(volumeName).exec();
Expand Down

Back | FazBrowse Home | New Git URL