Skip to content

Commit af1ad3d

Browse files
authored
Merge pull request docker-java#1137 from docker-java/revert-1111-feature/log-cmd-to-string
Revert "Change since parameter in LogContainerCmd to String"
2 parents 5368057 + a57b94b commit af1ad3d

File tree

3 files changed

+10
-45
lines changed

3 files changed

+10
-45
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* @param tail
2424
* - `all` or `<number>`, Output specified number of lines at the end of logs
2525
* @param since
26-
* - UNIX timestamp, RFC 3339 date, or Go duration string to filter logs.
27-
* Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered)
26+
* - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default:
27+
* 0 (unfiltered)
2828
*/
2929
public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame> {
3030

@@ -47,7 +47,7 @@ public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame>
4747
Boolean hasStderrEnabled();
4848

4949
@CheckForNull
50-
String getSince();
50+
Integer getSince();
5151

5252
LogContainerCmd withContainerId(@Nonnull String containerId);
5353

@@ -67,7 +67,7 @@ public interface LogContainerCmd extends AsyncDockerCmd<LogContainerCmd, Frame>
6767

6868
LogContainerCmd withTail(Integer tail);
6969

70-
LogContainerCmd withSince(String since);
70+
LogContainerCmd withSince(Integer since);
7171

7272
/**
7373
* @throws com.github.dockerjava.api.NotFoundException

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

+5-6
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
* @param tail
2323
* - `all` or `<number>`, Output specified number of lines at the end of logs
2424
* @param since
25-
* - UNIX timestamp, RFC 3339 date, or Go duration string to filter logs.
26-
* Specifying a timestamp will only output log-entries since that timestamp. Default: 0 (unfiltered)
25+
* - UNIX timestamp (integer) to filter logs. Specifying a timestamp will only output log-entries since that timestamp. Default:
26+
* 0 (unfiltered)
2727
*/
2828
public class LogContainerCmdImpl extends AbstrAsyncDockerCmd<LogContainerCmd, Frame> implements LogContainerCmd {
2929

3030
private String containerId;
3131

3232
private Boolean followStream, timestamps, stdout, stderr;
3333

34-
private Integer tail;
35-
private String since;
34+
private Integer tail, since;
3635

3736
public LogContainerCmdImpl(LogContainerCmd.Exec exec, String containerId) {
3837
super(exec);
@@ -70,7 +69,7 @@ public Boolean hasStderrEnabled() {
7069
}
7170

7271
@Override
73-
public String getSince() {
72+
public Integer getSince() {
7473
return since;
7574
}
7675

@@ -118,7 +117,7 @@ public LogContainerCmd withTail(Integer tail) {
118117
}
119118

120119
@Override
121-
public LogContainerCmd withSince(String since) {
120+
public LogContainerCmd withSince(Integer since) {
122121
this.since = since;
123122
return this;
124123
}

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

+1-35
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void asyncLogContainerWithSince() throws Exception {
175175
LOG.info("Created container: {}", container.toString());
176176
assertThat(container.getId(), not(isEmptyString()));
177177

178-
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
178+
int timestamp = (int) (System.currentTimeMillis() / 1000);
179179

180180
dockerRule.getClient().startContainerCmd(container.getId()).exec();
181181

@@ -197,38 +197,4 @@ public void asyncLogContainerWithSince() throws Exception {
197197

198198
assertThat(loggingCallback.toString(), containsString(snippet));
199199
}
200-
201-
@Test
202-
public void asyncLogContainerWithSinceNanoseconds() throws Exception {
203-
String snippet = "hello world";
204-
205-
CreateContainerResponse container = dockerRule.getClient().createContainerCmd("busybox")
206-
.withCmd("/bin/echo", snippet)
207-
.exec();
208-
209-
LOG.info("Created container: {}", container.toString());
210-
assertThat(container.getId(), not(isEmptyString()));
211-
212-
String timestamp = String.format("%.4f", System.currentTimeMillis() / 1000d);
213-
dockerRule.getClient().startContainerCmd(container.getId()).exec();
214-
215-
int exitCode = dockerRule.getClient().waitContainerCmd(container.getId())
216-
.exec(new WaitContainerResultCallback())
217-
.awaitStatusCode();
218-
219-
assertThat(exitCode, equalTo(0));
220-
221-
LogContainerTestCallback loggingCallback = new LogContainerTestCallback();
222-
223-
dockerRule.getClient().logContainerCmd(container.getId())
224-
.withStdErr(true)
225-
.withStdOut(true)
226-
.withTimestamps(true)
227-
.withSince(timestamp)
228-
.exec(loggingCallback);
229-
230-
loggingCallback.awaitCompletion();
231-
232-
assertThat(loggingCallback.toString(), containsString(snippet));
233-
}
234200
}

0 commit comments

Comments
 (0)