summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-05-20 14:24:18 -0700
committerJhon Honce <jhonce@redhat.com>2020-05-22 07:51:29 -0700
commitf51e0d0597757da72fd7a10085998052684e396b (patch)
tree0f7b197097bbb9ec682c23a318e86d36b687018a /pkg/domain
parent6aa802d8012a78ac95e4fe2017a5b54ec8d4b8de (diff)
downloadpodman-f51e0d0597757da72fd7a10085998052684e396b.tar.gz
podman-f51e0d0597757da72fd7a10085998052684e396b.tar.bz2
podman-f51e0d0597757da72fd7a10085998052684e396b.zip
V2 enable remote logs and testing
* wire up bindings and handler for obtaining logs remotely * enable debug logging from podman in e2e test using DEBUG and DEBUG_SERVICE env variables * Fix error in streaming log frames * enable remote logs test Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/infra/tunnel/containers.go35
1 files changed, 32 insertions, 3 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 30c4a8359..beba55c2b 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -4,7 +4,9 @@ import (
"context"
"io"
"os"
+ "strconv"
"strings"
+ "time"
"github.com/containers/common/pkg/config"
"github.com/containers/image/v5/docker/reference"
@@ -336,9 +338,36 @@ func (ic *ContainerEngine) ContainerCreate(ctx context.Context, s *specgen.SpecG
return &entities.ContainerCreateReport{Id: response.ID}, nil
}
-func (ic *ContainerEngine) ContainerLogs(ctx context.Context, containers []string, options entities.ContainerLogsOptions) error {
- // The endpoint is not ready yet and requires some more work.
- return errors.New("not implemented yet")
+func (ic *ContainerEngine) ContainerLogs(_ context.Context, nameOrIds []string, options entities.ContainerLogsOptions) error {
+ since := options.Since.Format(time.RFC3339)
+ tail := strconv.FormatInt(options.Tail, 10)
+ stdout := options.Writer != nil
+ opts := containers.LogOptions{
+ Follow: &options.Follow,
+ Since: &since,
+ Stderr: &stdout,
+ Stdout: &stdout,
+ Tail: &tail,
+ Timestamps: &options.Timestamps,
+ Until: nil,
+ }
+
+ var err error
+ outCh := make(chan string)
+ ctx, cancel := context.WithCancel(context.Background())
+ go func() {
+ err = containers.Logs(ic.ClientCxt, nameOrIds[0], opts, outCh, outCh)
+ cancel()
+ }()
+
+ for {
+ select {
+ case <-ctx.Done():
+ return err
+ case line := <-outCh:
+ _, _ = io.WriteString(options.Writer, line)
+ }
+ }
}
func (ic *ContainerEngine) ContainerAttach(ctx context.Context, nameOrId string, options entities.AttachOptions) error {