mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-11-01 01:03:13 +00:00
Generated largely from the specified config; small parts taken from `docker image inspect`, such as the command line. Renamed some of the yaml keys to match the OCI spec rather than Docker Compose as we decided they are more readable, no more underscores. Add some extra functionality - tmpfs specification - fully general mount specification - no new privileges can be specified now For nostalgic reasons, using engine-api to talk to the docker cli as we only need an old API version, and it is nice and easy to vendor... Signed-off-by: Justin Cormack <justin.cormack@docker.com>
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package client
|
|
|
|
import (
|
|
"io"
|
|
"net/url"
|
|
"time"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
"github.com/docker/engine-api/types"
|
|
"github.com/docker/engine-api/types/filters"
|
|
timetypes "github.com/docker/engine-api/types/time"
|
|
)
|
|
|
|
// Events returns a stream of events in the daemon in a ReadCloser.
|
|
// It's up to the caller to close the stream.
|
|
func (cli *Client) Events(ctx context.Context, options types.EventsOptions) (io.ReadCloser, error) {
|
|
query := url.Values{}
|
|
ref := time.Now()
|
|
|
|
if options.Since != "" {
|
|
ts, err := timetypes.GetTimestamp(options.Since, ref)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
query.Set("since", ts)
|
|
}
|
|
if options.Until != "" {
|
|
ts, err := timetypes.GetTimestamp(options.Until, ref)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
query.Set("until", ts)
|
|
}
|
|
if options.Filters.Len() > 0 {
|
|
filterJSON, err := filters.ToParamWithVersion(cli.version, options.Filters)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
query.Set("filters", filterJSON)
|
|
}
|
|
|
|
serverResponse, err := cli.get(ctx, "/events", query, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return serverResponse.body, nil
|
|
}
|