Update dependencies

Among others, this updates minio-go, so that the new "eu-west-3" zone
for AWS is supported.
This commit is contained in:
Alexander Neumann
2018-01-23 19:40:42 +01:00
parent b63de7c798
commit 2b39f9f4b2
3435 changed files with 1317989 additions and 315639 deletions
+28 -26
View File
@@ -26,7 +26,6 @@
package logadmin // import "cloud.google.com/go/logging/logadmin"
import (
"errors"
"fmt"
"math"
"net/http"
@@ -54,22 +53,20 @@ import (
// Client is a Logging client. A Client is associated with a single Cloud project.
type Client struct {
lClient *vkit.Client // logging client
sClient *vkit.ConfigClient // sink client
mClient *vkit.MetricsClient // metric client
projectID string
closed bool
lClient *vkit.Client // logging client
sClient *vkit.ConfigClient // sink client
mClient *vkit.MetricsClient // metric client
parent string
closed bool
}
// NewClient returns a new logging client associated with the provided project ID.
//
// By default NewClient uses AdminScope. To use a different scope, call
// NewClient using a WithScopes option (see https://godoc.org/google.golang.org/api/option#WithScopes).
func NewClient(ctx context.Context, projectID string, opts ...option.ClientOption) (*Client, error) {
// Check for '/' in project ID to reserve the ability to support various owning resources,
// in the form "{Collection}/{Name}", for instance "organizations/my-org".
if strings.ContainsRune(projectID, '/') {
return nil, errors.New("logging: project ID contains '/'")
func NewClient(ctx context.Context, parent string, opts ...option.ClientOption) (*Client, error) {
if !strings.ContainsRune(parent, '/') {
parent = "projects/" + parent
}
opts = append([]option.ClientOption{
option.WithEndpoint(internal.ProdAddr),
@@ -106,19 +103,14 @@ func NewClient(ctx context.Context, projectID string, opts ...option.ClientOptio
sc.SetGoogleClientInfo("gccl", version.Repo)
mc.SetGoogleClientInfo("gccl", version.Repo)
client := &Client{
lClient: lc,
sClient: sc,
mClient: mc,
projectID: projectID,
lClient: lc,
sClient: sc,
mClient: mc,
parent: parent,
}
return client, nil
}
// parent returns the string used in many RPCs to denote the parent resource of the log.
func (c *Client) parent() string {
return "projects/" + c.projectID
}
// Close closes the client.
func (c *Client) Close() error {
if c.closed {
@@ -137,7 +129,7 @@ func (c *Client) Close() error {
// logID identifies the log within the project. An example log ID is "syslog". Requires AdminScope.
func (c *Client) DeleteLog(ctx context.Context, logID string) error {
return c.lClient.DeleteLog(ctx, &logpb.DeleteLogRequest{
LogName: internal.LogPath(c.parent(), logID),
LogName: internal.LogPath(c.parent, logID),
})
}
@@ -197,6 +189,16 @@ func (p projectIDs) set(r *logpb.ListLogEntriesRequest) {
}
}
// ResourceNames sets the resource names from which to retrieve
// log entries. Examples: "projects/my-project-1A", "organizations/my-org".
func ResourceNames(rns []string) EntriesOption { return resourceNames(rns) }
type resourceNames []string
func (rn resourceNames) set(r *logpb.ListLogEntriesRequest) {
r.ResourceNames = append([]string(nil), rn...)
}
// Filter sets an advanced logs filter for listing log entries (see
// https://cloud.google.com/logging/docs/view/advanced_filters). The filter is
// compared against all log entries in the projects specified by ProjectIDs.
@@ -228,7 +230,7 @@ func (newestFirst) set(r *logpb.ListLogEntriesRequest) { r.OrderBy = "timestamp
// NewClient. This may be overridden by passing a ProjectIDs option. Requires ReadScope or AdminScope.
func (c *Client) Entries(ctx context.Context, opts ...EntriesOption) *EntryIterator {
it := &EntryIterator{
it: c.lClient.ListLogEntries(ctx, listLogEntriesRequest(c.projectID, opts)),
it: c.lClient.ListLogEntries(ctx, listLogEntriesRequest(c.parent, opts)),
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(
it.fetch,
@@ -237,9 +239,9 @@ func (c *Client) Entries(ctx context.Context, opts ...EntriesOption) *EntryItera
return it
}
func listLogEntriesRequest(projectID string, opts []EntriesOption) *logpb.ListLogEntriesRequest {
func listLogEntriesRequest(parent string, opts []EntriesOption) *logpb.ListLogEntriesRequest {
req := &logpb.ListLogEntriesRequest{
ResourceNames: []string{"projects/" + projectID},
ResourceNames: []string{parent},
}
for _, opt := range opts {
opt.set(req)
@@ -340,8 +342,8 @@ func fromLogEntry(le *logpb.LogEntry) (*logging.Entry, error) {
// Logs lists the logs owned by the parent resource of the client.
func (c *Client) Logs(ctx context.Context) *LogIterator {
it := &LogIterator{
parentResource: c.parent(),
it: c.lClient.ListLogs(ctx, &logpb.ListLogsRequest{Parent: c.parent()}),
parentResource: c.parent,
it: c.lClient.ListLogs(ctx, &logpb.ListLogsRequest{Parent: c.parent}),
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(
it.fetch,
+16 -14
View File
@@ -32,6 +32,7 @@ import (
"github.com/golang/protobuf/ptypes"
durpb "github.com/golang/protobuf/ptypes/duration"
structpb "github.com/golang/protobuf/ptypes/struct"
"github.com/google/go-cmp/cmp/cmpopts"
"golang.org/x/net/context"
"google.golang.org/api/option"
mrpb "google.golang.org/genproto/googleapis/api/monitoredres"
@@ -183,7 +184,7 @@ func TestFromLogEntry(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if diff := testutil.Diff(got, want, testutil.IgnoreUnexported(http.Request{})); diff != "" {
if diff := testutil.Diff(got, want, cmpopts.IgnoreUnexported(http.Request{})); diff != "" {
t.Errorf("FullEntry:\n%s", diff)
}
@@ -232,29 +233,30 @@ func TestFromLogEntry(t *testing.T) {
func TestListLogEntriesRequest(t *testing.T) {
for _, test := range []struct {
opts []EntriesOption
projectIDs []string
filter string
orderBy string
opts []EntriesOption
resourceNames []string
filter string
orderBy string
}{
// Default is client's project ID, empty filter and orderBy.
{nil,
[]string{"PROJECT_ID"}, "", ""},
{nil, []string{"projects/PROJECT_ID"}, "", ""},
{[]EntriesOption{NewestFirst(), Filter("f")},
[]string{"PROJECT_ID"}, "f", "timestamp desc"},
[]string{"projects/PROJECT_ID"}, "f", "timestamp desc"},
{[]EntriesOption{ProjectIDs([]string{"foo"})},
[]string{"foo"}, "", ""},
[]string{"projects/foo"}, "", ""},
{[]EntriesOption{ResourceNames([]string{"folders/F", "organizations/O"})},
[]string{"folders/F", "organizations/O"}, "", ""},
{[]EntriesOption{NewestFirst(), Filter("f"), ProjectIDs([]string{"foo"})},
[]string{"foo"}, "f", "timestamp desc"},
[]string{"projects/foo"}, "f", "timestamp desc"},
{[]EntriesOption{NewestFirst(), Filter("f"), ProjectIDs([]string{"foo"})},
[]string{"foo"}, "f", "timestamp desc"},
[]string{"projects/foo"}, "f", "timestamp desc"},
// If there are repeats, last one wins.
{[]EntriesOption{NewestFirst(), Filter("no"), ProjectIDs([]string{"foo"}), Filter("f")},
[]string{"foo"}, "f", "timestamp desc"},
[]string{"projects/foo"}, "f", "timestamp desc"},
} {
got := listLogEntriesRequest("PROJECT_ID", test.opts)
got := listLogEntriesRequest("projects/PROJECT_ID", test.opts)
want := &logpb.ListLogEntriesRequest{
ResourceNames: []string{"projects/" + test.projectIDs[0]},
ResourceNames: test.resourceNames,
Filter: test.filter,
OrderBy: test.orderBy,
}
+3 -3
View File
@@ -49,7 +49,7 @@ type Metric struct {
// CreateMetric creates a logs-based metric.
func (c *Client) CreateMetric(ctx context.Context, m *Metric) error {
_, err := c.mClient.CreateLogMetric(ctx, &logpb.CreateLogMetricRequest{
Parent: c.parent(),
Parent: c.parent,
Metric: toLogMetric(m),
})
return err
@@ -87,14 +87,14 @@ func (c *Client) UpdateMetric(ctx context.Context, m *Metric) error {
}
func (c *Client) metricPath(metricID string) string {
return fmt.Sprintf("%s/metrics/%s", c.parent(), metricID)
return fmt.Sprintf("%s/metrics/%s", c.parent, metricID)
}
// Metrics returns a MetricIterator for iterating over all Metrics in the Client's project.
// Requires ReadScope or AdminScope.
func (c *Client) Metrics(ctx context.Context) *MetricIterator {
it := &MetricIterator{
it: c.mClient.ListLogMetrics(ctx, &logpb.ListLogMetricsRequest{Parent: c.parent()}),
it: c.mClient.ListLogMetrics(ctx, &logpb.ListLogMetricsRequest{Parent: c.parent}),
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(
it.fetch,
+3 -3
View File
@@ -55,7 +55,7 @@ type Sink struct {
// Requires AdminScope.
func (c *Client) CreateSink(ctx context.Context, sink *Sink) (*Sink, error) {
ls, err := c.sClient.CreateSink(ctx, &logpb.CreateSinkRequest{
Parent: c.parent(),
Parent: c.parent,
Sink: toLogSink(sink),
})
if err != nil {
@@ -100,14 +100,14 @@ func (c *Client) UpdateSink(ctx context.Context, sink *Sink) (*Sink, error) {
}
func (c *Client) sinkPath(sinkID string) string {
return fmt.Sprintf("%s/sinks/%s", c.parent(), sinkID)
return fmt.Sprintf("%s/sinks/%s", c.parent, sinkID)
}
// Sinks returns a SinkIterator for iterating over all Sinks in the Client's project.
// Requires ReadScope or AdminScope.
func (c *Client) Sinks(ctx context.Context) *SinkIterator {
it := &SinkIterator{
it: c.sClient.ListSinks(ctx, &logpb.ListSinksRequest{Parent: c.parent()}),
it: c.sClient.ListSinks(ctx, &logpb.ListSinksRequest{Parent: c.parent}),
}
it.pageInfo, it.nextFunc = iterator.NewPageInfo(
it.fetch,