Skip to content

Commit a135d21

Browse files
ziminghua訾明华bsideup
authored
add until param to LogContainerCmd (#1734)
* add `until` param with LogContainerCmd * Update LogContainerCmdIT.java Co-authored-by: 訾明华 <zmh01@digibird.com.cn> Co-authored-by: Sergei Egorov <bsideup@gmail.com>
1 parent 599aeb7 commit a135d21

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

docker-java-api/src/main/java/com/github/dockerjava/api/command/LogContainerCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
* @param since
2626
* - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default:
2727
* 0 (unfiltered)
28+
* @param until
29+
* - Only return logs before this time, as a UNIX timestamp. Default: 0
2830
*/
2931
public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame> {
3032

@@ -49,6 +51,9 @@ public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame>
4951
@CheckForNull
5052
Integer getSince();
5153

54+
@CheckForNull
55+
Integer getUntil();
56+
5257
LogContainerCmd withContainerId(@Nonnull String containerId);
5358

5459
/**
@@ -69,6 +74,8 @@ public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame>
6974

7075
LogContainerCmd withSince(Integer since);
7176

77+
LogContainerCmd withUntil(Integer until);
78+
7279
/**
7380
* @throws com.github.dockerjava.api.NotFoundException
7481
* No such container

docker-java-core/src/main/java/com/github/dockerjava/core/command/LogContainerCmdImpl.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
* @param since
2525
* - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default:
2626
* 0 (unfiltered)
27+
* @param until
28+
* - Only return logs before this time, as a UNIX timestamp. Default: 0
2729
*/
2830
public class LogContainerCmdImpl extends AbstrAsyncDockerCmd<LogContainerCmd, Frame> implements LogContainerCmd {
2931

3032
private String containerId;
3133

3234
private Boolean followStream, timestamps, stdout, stderr;
3335

34-
private Integer tail, since;
36+
private Integer tail, since, until;
3537

3638
public LogContainerCmdImpl(LogContainerCmd.Exec exec, String containerId) {
3739
super(exec);
@@ -73,6 +75,11 @@ public Integer getSince() {
7375
return since;
7476
}
7577

78+
@Override
79+
public Integer getUntil() {
80+
return until;
81+
}
82+
7683
@Override
7784
public LogContainerCmd withContainerId(String containerId) {
7885
checkNotNull(containerId, "containerId was not specified");
@@ -122,6 +129,12 @@ public LogContainerCmd withSince(Integer since) {
122129
return this;
123130
}
124131

132+
@Override
133+
public LogContainerCmd withUntil(Integer until) {
134+
this.until = until;
135+
return this;
136+
}
137+
125138
@Override
126139
public String toString() {
127140
return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);

docker-java-core/src/main/java/com/github/dockerjava/core/exec/LogContainerCmdExec.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ protected Void execute0(LogContainerCmd command, ResultCallback<Frame> resultCal
3232
webTarget = webTarget.queryParam("since", command.getSince());
3333
}
3434

35+
if (command.getUntil() != null) {
36+
webTarget = webTarget.queryParam("until", command.getUntil());
37+
}
38+
3539
webTarget = booleanQueryParam(webTarget, "timestamps", command.hasTimestampsEnabled());
3640
webTarget = booleanQueryParam(webTarget, "stdout", command.hasStdoutEnabled());
3741
webTarget = booleanQueryParam(webTarget, "stderr", command.hasStderrEnabled());

docker-java/src/test/java/com/github/dockerjava/cmd/LogContainerCmdIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public void asyncLogContainerWithSince() throws Exception {
206206
.withStdErr(true)
207207
.withStdOut(true)
208208
.withSince(timestamp)
209+
.withUntil(timestamp + 1000)
209210
.exec(loggingCallback);
210211

211212
loggingCallback.awaitCompletion();

0 commit comments

Comments
 (0)