Skip to content
This repository was archived by the owner on Jan 4, 2022. It is now read-only.

Commit 495f488

Browse files
author
Alena Prokharchyk
committed
Support for timestamps and since as container logs args
1 parent 05643ce commit 495f488

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

code/implementation/docker/api/src/main/java/io/cattle/platform/docker/api/ContainerLogsActionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public Object perform(String name, Object obj, ApiRequest request) {
5151

5252
String dockerId = DockerUtils.getDockerIdentifier(container);
5353
Map<String, Object> data = CollectionUtils.asMap(DockerInstanceConstants.DOCKER_CONTAINER, dockerId, "Lines", logs.getLines(), "Follow",
54-
logs.getFollow());
54+
logs.getFollow(), "Timestamps", logs.getTimestamps(), "Since", logs.getSince());
5555

5656
HostApiAccess apiAccess = apiService.getAccess(request, host.getId(), CollectionUtils.asMap("logs", data), HOST_LOGS_PATH.get());
5757

code/implementation/docker/common/src/main/java/io/cattle/platform/docker/api/model/ContainerLogs.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ public interface ContainerLogs {
1111

1212
@Field(defaultValue = "100", min = 0)
1313
Integer getLines();
14+
15+
@Field(defaultValue = "true")
16+
Boolean getTimestamps();
17+
18+
@Field(defaultValue = "")
19+
String getSince();
1420
}

resources/content/schema/user/user-auth.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@
205205
"containerLogs":"r",
206206
"containerLogs.follow":"cr",
207207
"containerLogs.lines":"cr",
208+
"containerLogs.timestamps":"cr",
209+
"containerLogs.since":"cr",
208210

209211
"containerProxy":"r",
210212
"containerProxy.port":"cr",

tests/integration/cattletest/core/test_container.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def test_container_logs(context):
493493

494494
assert callable(c.logs)
495495

496-
resp = c.logs(follow=True, lines=300)
496+
resp = c.logs(follow=True, lines=300, timestamps=True, since="2017-05-03")
497497

498498
assert resp.url is not None
499499
assert resp.token is not None
@@ -503,6 +503,8 @@ def test_container_logs(context):
503503
assert jwt['logs']['Container'] == c.externalId
504504
assert jwt['logs']['Lines'] == 300
505505
assert jwt['logs']['Follow'] is True
506+
assert jwt['logs']['Timestamps'] is True
507+
assert jwt['logs']['Since'] == "2017-05-03"
506508
assert jwt['exp'] is not None
507509

508510
resp = c.logs()
@@ -515,6 +517,7 @@ def test_container_logs(context):
515517
assert jwt['logs']['Container'] == c.externalId
516518
assert jwt['logs']['Lines'] == 100
517519
assert jwt['logs']['Follow'] is True
520+
assert jwt['logs']['Timestamps'] is True
518521
assert jwt['exp'] is not None
519522

520523
context.delete(c)

0 commit comments

Comments
 (0)