-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add resize container and exec command #1262
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3ddc2c1
Add resize container and exec command
creaink d2a134f
Apply suggestions from code review
creaink 8780e6a
fix resize exec test case error
creaink ce00bdb
Merge branch 'master' into resize
creaink aec6364
remove DEFAULT_IMAGE in resize exec
creaink e475e30
add validation of resize exec test case
creaink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
30 changes: 30 additions & 0 deletions
30
docker-java-api/src/main/java/com/github/dockerjava/api/command/ResizeContainerCmd.java
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.github.dockerjava.api.command; | ||
|
|
||
| import com.github.dockerjava.api.exception.NotFoundException; | ||
|
|
||
| import javax.annotation.CheckForNull; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| public interface ResizeContainerCmd extends SyncDockerCmd<Void> { | ||
|
|
||
| @CheckForNull | ||
| String getContainerId(); | ||
|
|
||
| Integer getHeight(); | ||
|
|
||
| Integer getWidth(); | ||
|
|
||
| ResizeContainerCmd withContainerId(@Nonnull String execId); | ||
|
|
||
| ResizeContainerCmd withSize(int height, int width); | ||
|
|
||
| /** | ||
| * @throws NotFoundException no such container instance | ||
| */ | ||
| @Override | ||
| Void exec() throws NotFoundException; | ||
|
|
||
| interface Exec extends DockerCmdSyncExec<ResizeContainerCmd, Void> { | ||
| } | ||
|
|
||
| } |
29 changes: 29 additions & 0 deletions
29
docker-java-api/src/main/java/com/github/dockerjava/api/command/ResizeExecCmd.java
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 |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.github.dockerjava.api.command; | ||
|
|
||
| import com.github.dockerjava.api.exception.NotFoundException; | ||
|
|
||
| import javax.annotation.CheckForNull; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| public interface ResizeExecCmd extends SyncDockerCmd<Void> { | ||
| @CheckForNull | ||
| String getExecId(); | ||
|
|
||
| Integer getHeight(); | ||
|
|
||
| Integer getWidth(); | ||
|
|
||
| ResizeExecCmd withExecId(@Nonnull String execId); | ||
|
|
||
| ResizeExecCmd withSize(int height, int width); | ||
|
|
||
| /** | ||
| * @throws NotFoundException no such exec instance | ||
| */ | ||
| @Override | ||
| Void exec() throws NotFoundException; | ||
|
|
||
| interface Exec extends DockerCmdSyncExec<ResizeExecCmd, Void> { | ||
| } | ||
|
|
||
| } |
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
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
57 changes: 57 additions & 0 deletions
57
...er-java-core/src/main/java/com/github/dockerjava/core/command/ResizeContainerCmdImpl.java
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 |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package com.github.dockerjava.core.command; | ||
|
|
||
| import com.github.dockerjava.api.command.ResizeContainerCmd; | ||
| import com.github.dockerjava.api.exception.NotFoundException; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
|
|
||
| public class ResizeContainerCmdImpl extends AbstrDockerCmd<ResizeContainerCmd, Void> implements ResizeContainerCmd { | ||
|
|
||
| private String containerId; | ||
|
|
||
| private Integer height; | ||
|
|
||
| private Integer width; | ||
|
|
||
| public ResizeContainerCmdImpl(ResizeContainerCmd.Exec exec, String execId) { | ||
| super(exec); | ||
| withContainerId(execId); | ||
| } | ||
|
|
||
| @Override | ||
| public String getContainerId() { | ||
| return containerId; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getHeight() { | ||
| return height; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getWidth() { | ||
| return width; | ||
| } | ||
|
|
||
| @Override | ||
| public ResizeContainerCmd withContainerId(String containerId) { | ||
| checkNotNull(containerId, "containerId was not specified"); | ||
| this.containerId = containerId; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public ResizeContainerCmd withSize(int height, int width) { | ||
| this.height = height; | ||
| this.width = width; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * @throws NotFoundException no such exec instance | ||
| */ | ||
| @Override | ||
| public Void exec() throws NotFoundException { | ||
| return super.exec(); | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
docker-java-core/src/main/java/com/github/dockerjava/core/command/ResizeExecCmdImpl.java
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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.github.dockerjava.core.command; | ||
|
|
||
| import com.github.dockerjava.api.command.ResizeExecCmd; | ||
| import com.github.dockerjava.api.exception.NotFoundException; | ||
|
|
||
| import static com.google.common.base.Preconditions.checkNotNull; | ||
|
|
||
| public class ResizeExecCmdImpl extends AbstrDockerCmd<ResizeExecCmd, Void> implements ResizeExecCmd { | ||
|
|
||
| private String execId; | ||
|
|
||
| private Integer height; | ||
|
|
||
| private Integer width; | ||
|
|
||
| public ResizeExecCmdImpl(ResizeExecCmd.Exec exec, String execId) { | ||
| super(exec); | ||
| withExecId(execId); | ||
| } | ||
|
|
||
| @Override | ||
| public String getExecId() { | ||
| return execId; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getHeight() { | ||
| return height; | ||
| } | ||
|
|
||
| @Override | ||
| public Integer getWidth() { | ||
| return width; | ||
| } | ||
|
|
||
| @Override | ||
| public ResizeExecCmd withExecId(String execId) { | ||
| checkNotNull(execId, "execId was not specified"); | ||
| this.execId = execId; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public ResizeExecCmd withSize(int height, int width) { | ||
| this.height = height; | ||
| this.width = width; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * @throws NotFoundException no such exec instance | ||
| */ | ||
| @Override | ||
| public Void exec() throws NotFoundException { | ||
| return super.exec(); | ||
| } | ||
|
|
||
| } |
30 changes: 30 additions & 0 deletions
30
docker-java-core/src/main/java/com/github/dockerjava/core/exec/ResizeContainerCmdExec.java
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 |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| package com.github.dockerjava.core.exec; | ||
|
|
||
| import com.github.dockerjava.api.command.ResizeContainerCmd; | ||
| import com.github.dockerjava.core.DockerClientConfig; | ||
| import com.github.dockerjava.core.MediaType; | ||
| import com.github.dockerjava.core.WebTarget; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class ResizeContainerCmdExec extends AbstrSyncDockerCmdExec<ResizeContainerCmd, Void> implements ResizeContainerCmd.Exec { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(ResizeContainerCmdExec.class); | ||
|
|
||
| public ResizeContainerCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { | ||
| super(baseResource, dockerClientConfig); | ||
| } | ||
|
|
||
| @Override | ||
| protected Void execute(ResizeContainerCmd command) { | ||
| WebTarget webResource = getBaseResource().path("/containers/{id}/resize") | ||
| .resolveTemplate("id", command.getContainerId()).queryParam("h", command.getHeight()) | ||
| .queryParam("w", command.getWidth()); | ||
|
|
||
| LOGGER.trace("POST: {}", webResource); | ||
|
|
||
| webResource.request().accept(MediaType.APPLICATION_JSON).post(command); | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
docker-java-core/src/main/java/com/github/dockerjava/core/exec/ResizeExecCmdExec.java
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.github.dockerjava.core.exec; | ||
|
|
||
| import com.github.dockerjava.api.command.ResizeExecCmd; | ||
| import com.github.dockerjava.core.DockerClientConfig; | ||
| import com.github.dockerjava.core.MediaType; | ||
| import com.github.dockerjava.core.WebTarget; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
||
| public class ResizeExecCmdExec extends AbstrSyncDockerCmdExec<ResizeExecCmd, Void> implements ResizeExecCmd.Exec { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(ResizeExecCmdExec.class); | ||
|
|
||
| public ResizeExecCmdExec(WebTarget baseResource, DockerClientConfig dockerClientConfig) { | ||
| super(baseResource, dockerClientConfig); | ||
| } | ||
|
|
||
| @Override | ||
| protected Void execute(ResizeExecCmd command) { | ||
| WebTarget webResource = getBaseResource().path("/exec/{id}/resize") | ||
| .resolveTemplate("id", command.getExecId()).queryParam("h", command.getHeight()).queryParam("w", command.getWidth()); | ||
|
|
||
| LOGGER.trace("POST: {}", webResource); | ||
|
|
||
| webResource.request().accept(MediaType.APPLICATION_JSON).post(null); | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.