Commit 7e63bdbe authored by Miek Gieben's avatar Miek Gieben Committed by Yong Tang

dep ensure -update (#1001)

* dep ensure -update

Run "dep ensure -update` to update all dependencies.

No code changes; just the dependencies.

* dep prune

* add new venderod
parent 558f4bea
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
[[projects]] [[projects]]
name = "cloud.google.com/go" name = "cloud.google.com/go"
packages = ["compute/metadata","internal"] packages = ["compute/metadata"]
revision = "2e6a95edb1071d750f6d7db777bf66cd2997af6c" revision = "0f0b8420cb699ac4ce059c63bac263f4301fe95b"
version = "v0.7.0" version = "v0.12.0"
[[projects]] [[projects]]
name = "github.com/PuerkitoBio/purell" name = "github.com/PuerkitoBio/purell"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
branch = "master" branch = "master"
name = "github.com/PuerkitoBio/urlesc" name = "github.com/PuerkitoBio/urlesc"
packages = ["."] packages = ["."]
revision = "bbf7a2afc14f93e1e0a5c06df524fbd75e5031e5" revision = "de5bf2ad457846296e2031421a34e2568e304e35"
[[projects]] [[projects]]
name = "github.com/Shopify/sarama" name = "github.com/Shopify/sarama"
...@@ -40,20 +40,26 @@ ...@@ -40,20 +40,26 @@
[[projects]] [[projects]]
name = "github.com/blang/semver" name = "github.com/blang/semver"
packages = ["."] packages = ["."]
revision = "b38d23b8782a487059e8fc8773e9a5b228a77cb6" revision = "2ee87856327ba09384cabd113bc6b5d174e9ec0f"
version = "v3.5.0" version = "v3.5.1"
[[projects]] [[projects]]
name = "github.com/coreos/etcd" name = "github.com/coreos/etcd"
packages = ["client","pkg/pathutil","pkg/types"] packages = ["client","pkg/pathutil","pkg/srv","pkg/types","version"]
revision = "d267ca9c184e953554257d0acdd1dc9c47d38229" revision = "9d43462d174c664f5edf313dec0de31e1ef4ed47"
version = "v3.1.8" version = "v3.2.6"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/coreos/go-oidc" name = "github.com/coreos/go-oidc"
packages = ["http","jose","key","oauth2","oidc"] packages = ["http","jose","key","oauth2","oidc"]
revision = "c797a55f1c1001ec3169f1d0fbb4c5523563bec6" revision = "a4973d9a4225417aecf5d450a9522f00c1f7130f"
[[projects]]
name = "github.com/coreos/go-semver"
packages = ["semver"]
revision = "8ab6407b697782a06568d4b7f1db25550ec2e4c6"
version = "v0.2.0"
[[projects]] [[projects]]
name = "github.com/coreos/pkg" name = "github.com/coreos/pkg"
...@@ -76,8 +82,8 @@ ...@@ -76,8 +82,8 @@
[[projects]] [[projects]]
name = "github.com/docker/distribution" name = "github.com/docker/distribution"
packages = ["digest","reference"] packages = ["digest","reference"]
revision = "a25b9ef0c9fe242ac04bb20d3a028442b7d266b6" revision = "48294d928ced5dd9b378f7fd7c6f5da3ff3f2c89"
version = "v2.6.1" version = "v2.6.2"
[[projects]] [[projects]]
name = "github.com/eapache/go-resiliency" name = "github.com/eapache/go-resiliency"
...@@ -143,13 +149,13 @@ ...@@ -143,13 +149,13 @@
branch = "master" branch = "master"
name = "github.com/go-openapi/spec" name = "github.com/go-openapi/spec"
packages = ["."] packages = ["."]
revision = "e51c28f07047ad90caff03f6450908720d337e0c" revision = "3faa0055dbbf2110abc1f3b4e3adbb22721e96e7"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/go-openapi/swag" name = "github.com/go-openapi/swag"
packages = ["."] packages = ["."]
revision = "e43299b4afa7bc7f22e5e82e3d48607230e4c177" revision = "f3f9494671f93fcff853e3c6e9e948b3eb71e590"
[[projects]] [[projects]]
name = "github.com/gogo/protobuf" name = "github.com/gogo/protobuf"
...@@ -167,7 +173,7 @@ ...@@ -167,7 +173,7 @@
branch = "master" branch = "master"
name = "github.com/golang/protobuf" name = "github.com/golang/protobuf"
packages = ["proto","ptypes/any"] packages = ["proto","ptypes/any"]
revision = "5a0f697c9ed9d68fef0116532c6e05cfeae00e55" revision = "ab9f9a6dab164b7d1246e0e688b0ab7b94d8553e"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -179,13 +185,7 @@ ...@@ -179,13 +185,7 @@
branch = "master" branch = "master"
name = "github.com/google/gofuzz" name = "github.com/google/gofuzz"
packages = ["."] packages = ["."]
revision = "44d81051d367757e1c7c6a5a86423ece9afcf63c" revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1"
[[projects]]
branch = "master"
name = "github.com/googleapis/gax-go"
packages = ["."]
revision = "9af46dd5a1713e8b5cd71106287eba3cefdde50b"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
branch = "master" branch = "master"
name = "github.com/mailru/easyjson" name = "github.com/mailru/easyjson"
packages = ["buffer","jlexer","jwriter"] packages = ["buffer","jlexer","jwriter"]
revision = "44c0351a5bc860bcb2608d54aa03ea686c4e7b25" revision = "3b3bbef4e2d9a6f24d7ee73a894afbc064f0e057"
[[projects]] [[projects]]
name = "github.com/matttproud/golang_protobuf_extensions" name = "github.com/matttproud/golang_protobuf_extensions"
...@@ -244,14 +244,14 @@ ...@@ -244,14 +244,14 @@
[[projects]] [[projects]]
name = "github.com/openzipkin/zipkin-go-opentracing" name = "github.com/openzipkin/zipkin-go-opentracing"
packages = [".","_thrift/gen-go/scribe","_thrift/gen-go/zipkincore","flag","types","wire"] packages = [".","_thrift/gen-go/scribe","_thrift/gen-go/zipkincore","flag","types","wire"]
revision = "6022d4d3ed39632fad842942bda1813a9b4f63c8" revision = "d88c90182f3fb514be54a1c7adc11a04d41c7da9"
version = "v0.2.3" version = "v0.2.4"
[[projects]] [[projects]]
name = "github.com/pborman/uuid" name = "github.com/pborman/uuid"
packages = ["."] packages = ["."]
revision = "a97ce2ca70fa5a848076093f05e639a89ca34d06" revision = "e790cca94e6cc75c7064b1332e63811d4aae1a53"
version = "v1.0" version = "v1.1"
[[projects]] [[projects]]
name = "github.com/pierrec/lz4" name = "github.com/pierrec/lz4"
...@@ -281,13 +281,13 @@ ...@@ -281,13 +281,13 @@
branch = "master" branch = "master"
name = "github.com/prometheus/common" name = "github.com/prometheus/common"
packages = ["expfmt","internal/bitbucket.org/ww/goautoneg","model"] packages = ["expfmt","internal/bitbucket.org/ww/goautoneg","model"]
revision = "13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" revision = "61f87aac8082fa8c3c5655c7608d7478d46ac2ad"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/prometheus/procfs" name = "github.com/prometheus/procfs"
packages = [".","xfs"] packages = [".","xfs"]
revision = "65c1f6f8f0fc1e2185eb9863a3bc751496404259" revision = "e645f4e5aaa8506fc71d6edbc5c4ff02c04c46f2"
[[projects]] [[projects]]
branch = "master" branch = "master"
...@@ -296,40 +296,40 @@ ...@@ -296,40 +296,40 @@
revision = "1f30fe9094a513ce4c700b9a54458bbb0c96996c" revision = "1f30fe9094a513ce4c700b9a54458bbb0c96996c"
[[projects]] [[projects]]
branch = "master"
name = "github.com/spf13/pflag" name = "github.com/spf13/pflag"
packages = ["."] packages = ["."]
revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66"
version = "v1.0.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/ugorji/go" name = "github.com/ugorji/go"
packages = ["codec"] packages = ["codec"]
revision = "708a42d246822952f38190a8d8c4e6b16a0e600c" revision = "8c0409fcbb70099c748d71f714529204975f6c3f"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/crypto" name = "golang.org/x/crypto"
packages = ["ssh/terminal"] packages = ["ssh/terminal"]
revision = "e1a4589e7d3ea14a3352255d04b6f1a418845e5e" revision = "81e90905daefcd6fd217b62423c0908922eadb30"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/oauth2" name = "golang.org/x/oauth2"
packages = [".","google","internal","jws","jwt"] packages = [".","google","internal","jws","jwt"]
revision = "f047394b6d14284165300fd82dad67edb3a4d7f6" revision = "9a379c6b3e95a790ffc43293c2a78dee0d7b6e20"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/sys" name = "golang.org/x/sys"
packages = ["unix"] packages = ["unix","windows"]
revision = "b90f89a1e7a9c1f6b918820b3daa7f08488c8594" revision = "2d6f6f883a06fc0d5f4b14a81e4c28705ea64c15"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "golang.org/x/text" name = "golang.org/x/text"
packages = ["internal/gen","internal/triegen","internal/ucd","transform","unicode/cldr","unicode/norm","width"] packages = ["internal/gen","internal/triegen","internal/ucd","transform","unicode/cldr","unicode/norm","width"]
revision = "4ee4af566555f5fbe026368b75596286a312663a" revision = "ac87088df8ef557f1e32cd00ed0b6fbc3f7ddafb"
[[projects]] [[projects]]
name = "google.golang.org/appengine" name = "google.golang.org/appengine"
...@@ -341,13 +341,13 @@ ...@@ -341,13 +341,13 @@
branch = "master" branch = "master"
name = "google.golang.org/genproto" name = "google.golang.org/genproto"
packages = ["googleapis/rpc/status"] packages = ["googleapis/rpc/status"]
revision = "aa2eb687b4d3e17154372564ad8d6bf11c3cf21f" revision = "ee236bd376b077c7a89f260c026c4735b195e459"
[[projects]] [[projects]]
name = "google.golang.org/grpc" name = "google.golang.org/grpc"
packages = [".","codes","credentials","grpclb/grpc_lb_v1","grpclog","internal","keepalive","metadata","naming","peer","stats","status","tap","transport"] packages = [".","codes","connectivity","credentials","grpclb/grpc_lb_v1","grpclog","internal","keepalive","metadata","naming","peer","stats","status","tap","transport"]
revision = "d2e1b51f33ff8c5e4a15560ff049d200e83726c5" revision = "b3ddf786825de56a4178401b7e174ee332173b66"
version = "v1.3.0" version = "v1.5.2"
[[projects]] [[projects]]
name = "gopkg.in/inf.v0" name = "gopkg.in/inf.v0"
...@@ -359,7 +359,7 @@ ...@@ -359,7 +359,7 @@
branch = "v2" branch = "v2"
name = "gopkg.in/yaml.v2" name = "gopkg.in/yaml.v2"
packages = ["."] packages = ["."]
revision = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b" revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
[[projects]] [[projects]]
name = "k8s.io/client-go" name = "k8s.io/client-go"
......
...@@ -7,9 +7,9 @@ go: ...@@ -7,9 +7,9 @@ go:
install: install:
- go get -v cloud.google.com/go/... - go get -v cloud.google.com/go/...
script: script:
- openssl aes-256-cbc -K $encrypted_912ff8fa81ad_key -iv $encrypted_912ff8fa81ad_iv -in key.json.enc -out key.json -d - openssl aes-256-cbc -K $encrypted_a8b3f4fc85f4_key -iv $encrypted_a8b3f4fc85f4_iv -in key.json.enc -out key.json -d
- GCLOUD_TESTS_GOLANG_PROJECT_ID="dulcet-port-762" GCLOUD_TESTS_GOLANG_KEY="$(pwd)/key.json" - GCLOUD_TESTS_GOLANG_PROJECT_ID="dulcet-port-762" GCLOUD_TESTS_GOLANG_KEY="$(pwd)/key.json"
go test -race -v cloud.google.com/go/... ./run-tests.sh $TRAVIS_COMMIT
env: env:
matrix: matrix:
# The GCLOUD_TESTS_API_KEY environment variable. # The GCLOUD_TESTS_API_KEY environment variable.
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
1. `go get golang.org/x/review/git-codereview` to install the code reviewing tool. 1. `go get golang.org/x/review/git-codereview` to install the code reviewing tool.
1. You will need to ensure that your `GOBIN` directory (by default 1. You will need to ensure that your `GOBIN` directory (by default
`$GOPATH/bin`) is in your `PATH` so that git can find the command. `$GOPATH/bin`) is in your `PATH` so that git can find the command.
1. If you would like, you may want to set up aliases for git-codereview,
such that `git codereview change` becomes `git change`. See the
[godoc](https://godoc.org/golang.org/x/review/git-codereview) for details.
1. Should you run into issues with the git-codereview tool, please note
that all error messages will assume that you have set up these
aliases.
1. Get the cloud package by running `go get -d cloud.google.com/go`. 1. Get the cloud package by running `go get -d cloud.google.com/go`.
1. If you have already checked out the source, make sure that the remote git 1. If you have already checked out the source, make sure that the remote git
origin is https://code.googlesource.com/gocloud: origin is https://code.googlesource.com/gocloud:
......
# Code Changes
## v0.10.0
- pubsub: Replace
```
sub.ModifyPushConfig(ctx, pubsub.PushConfig{Endpoint: "https://example.com/push"})
```
with
```
sub.Update(ctx, pubsub.SubscriptionConfigToUpdate{
PushConfig: &pubsub.PushConfig{Endpoint: "https://example.com/push"},
})
```
- trace: traceGRPCServerInterceptor will be provided from *trace.Client.
Given an initialized `*trace.Client` named `tc`, instead of
```
s := grpc.NewServer(grpc.UnaryInterceptor(trace.GRPCServerInterceptor(tc)))
```
write
```
s := grpc.NewServer(grpc.UnaryInterceptor(tc.GRPCServerInterceptor()))
```
- trace trace.GRPCClientInterceptor will also provided from *trace.Client.
Instead of
```
conn, err := grpc.Dial(srv.Addr, grpc.WithUnaryInterceptor(trace.GRPCClientInterceptor()))
```
write
```
conn, err := grpc.Dial(srv.Addr, grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor()))
```
- trace: We removed the deprecated `trace.EnableGRPCTracing`. Use the gRPC
interceptor as a dial option as shown below when initializing Cloud package
clients:
```
c, err := pubsub.NewClient(ctx, "project-id", option.WithGRPCDialOption(grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor())))
if err != nil {
...
}
```
This diff is collapsed.
...@@ -34,8 +34,6 @@ import ( ...@@ -34,8 +34,6 @@ import (
"golang.org/x/net/context" "golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp" "golang.org/x/net/context/ctxhttp"
"cloud.google.com/go/internal"
) )
const ( const (
...@@ -48,6 +46,8 @@ const ( ...@@ -48,6 +46,8 @@ const (
// This is variable name is not defined by any spec, as far as // This is variable name is not defined by any spec, as far as
// I know; it was made up for the Go package. // I know; it was made up for the Go package.
metadataHostEnv = "GCE_METADATA_HOST" metadataHostEnv = "GCE_METADATA_HOST"
userAgent = "gcloud-golang/0.1"
) )
type cachedValue struct { type cachedValue struct {
...@@ -65,24 +65,20 @@ var ( ...@@ -65,24 +65,20 @@ var (
var ( var (
metaClient = &http.Client{ metaClient = &http.Client{
Transport: &internal.Transport{ Transport: &http.Transport{
Base: &http.Transport{ Dial: (&net.Dialer{
Dial: (&net.Dialer{ Timeout: 2 * time.Second,
Timeout: 2 * time.Second, KeepAlive: 30 * time.Second,
KeepAlive: 30 * time.Second, }).Dial,
}).Dial, ResponseHeaderTimeout: 2 * time.Second,
ResponseHeaderTimeout: 2 * time.Second,
},
}, },
} }
subscribeClient = &http.Client{ subscribeClient = &http.Client{
Transport: &internal.Transport{ Transport: &http.Transport{
Base: &http.Transport{ Dial: (&net.Dialer{
Dial: (&net.Dialer{ Timeout: 2 * time.Second,
Timeout: 2 * time.Second, KeepAlive: 30 * time.Second,
KeepAlive: 30 * time.Second, }).Dial,
}).Dial,
},
}, },
} }
) )
...@@ -132,6 +128,7 @@ func getETag(client *http.Client, suffix string) (value, etag string, err error) ...@@ -132,6 +128,7 @@ func getETag(client *http.Client, suffix string) (value, etag string, err error)
url := "http://" + host + "/computeMetadata/v1/" + suffix url := "http://" + host + "/computeMetadata/v1/" + suffix
req, _ := http.NewRequest("GET", url, nil) req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("Metadata-Flavor", "Google") req.Header.Set("Metadata-Flavor", "Google")
req.Header.Set("User-Agent", userAgent)
res, err := client.Do(req) res, err := client.Do(req)
if err != nil { if err != nil {
return "", "", err return "", "", err
...@@ -202,7 +199,9 @@ func testOnGCE() bool { ...@@ -202,7 +199,9 @@ func testOnGCE() bool {
// Try two strategies in parallel. // Try two strategies in parallel.
// See https://github.com/GoogleCloudPlatform/google-cloud-go/issues/194 // See https://github.com/GoogleCloudPlatform/google-cloud-go/issues/194
go func() { go func() {
res, err := ctxhttp.Get(ctx, metaClient, "http://"+metadataIP) req, _ := http.NewRequest("GET", "http://"+metadataIP, nil)
req.Header.Set("User-Agent", userAgent)
res, err := ctxhttp.Do(ctx, metaClient, req)
if err != nil { if err != nil {
resc <- false resc <- false
return return
......
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package internal provides support for the cloud packages.
//
// Users should not import this package directly.
package internal
import (
"fmt"
"net/http"
)
const userAgent = "gcloud-golang/0.1"
// Transport is an http.RoundTripper that appends Google Cloud client's
// user-agent to the original request's user-agent header.
type Transport struct {
// TODO(bradfitz): delete internal.Transport. It's too wrappy for what it does.
// Do User-Agent some other way.
// Base is the actual http.RoundTripper
// requests will use. It must not be nil.
Base http.RoundTripper
}
// RoundTrip appends a user-agent to the existing user-agent
// header and delegates the request to the base http.RoundTripper.
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
req = cloneRequest(req)
ua := req.Header.Get("User-Agent")
if ua == "" {
ua = userAgent
} else {
ua = fmt.Sprintf("%s %s", ua, userAgent)
}
req.Header.Set("User-Agent", ua)
return t.Base.RoundTrip(req)
}
// cloneRequest returns a clone of the provided *http.Request.
// The clone is a shallow copy of the struct and its Header map.
func cloneRequest(r *http.Request) *http.Request {
// shallow copy of the struct
r2 := new(http.Request)
*r2 = *r
// deep copy of the Header
r2.Header = make(http.Header)
for k, s := range r.Header {
r2.Header[k] = s
}
return r2
}
_March 17, 2017_
Breaking Pubsub changes.
* Publish is now asynchronous
([announcement](https://groups.google.com/d/topic/google-api-go-announce/aaqRDIQ3rvU/discussion)).
* Subscription.Pull replaced by Subscription.Receive, which takes a callback ([announcement](https://groups.google.com/d/topic/google-api-go-announce/8pt6oetAdKc/discussion)).
* Message.Done replaced with Message.Ack and Message.Nack.
_February 14, 2017_
Release of a client library for Spanner. See
the
[blog post](https://cloudplatform.googleblog.com/2017/02/introducing-Cloud-Spanner-a-global-database-service-for-mission-critical-applications.html).
Note that although the Spanner service is beta, the Go client library is alpha.
_December 12, 2016_
Beta release of BigQuery, DataStore, Logging and Storage. See the
[blog post](https://cloudplatform.googleblog.com/2016/12/announcing-new-google-cloud-client.html).
Also, BigQuery now supports structs. Read a row directly into a struct with
`RowIterator.Next`, and upload a row directly from a struct with `Uploader.Put`.
You can also use field tags. See the [package documentation][cloud-bigquery-ref]
for details.
_December 5, 2016_
More changes to BigQuery:
* The `ValueList` type was removed. It is no longer necessary. Instead of
```go
var v ValueList
... it.Next(&v) ..
```
use
```go
var v []Value
... it.Next(&v) ...
```
* Previously, repeatedly calling `RowIterator.Next` on the same `[]Value` or
`ValueList` would append to the slice. Now each call resets the size to zero first.
* Schema inference will infer the SQL type BYTES for a struct field of
type []byte. Previously it inferred STRING.
* The types `uint`, `uint64` and `uintptr` are no longer supported in schema
inference. BigQuery's integer type is INT64, and those types may hold values
that are not correctly represented in a 64-bit signed integer.
* The SQL types DATE, TIME and DATETIME are now supported. They correspond to
the `Date`, `Time` and `DateTime` types in the new `cloud.google.com/go/civil`
package.
_November 17, 2016_
Change to BigQuery: values from INTEGER columns will now be returned as int64,
not int. This will avoid errors arising from large values on 32-bit systems.
_November 8, 2016_
New datastore feature: datastore now encodes your nested Go structs as Entity values,
instead of a flattened list of the embedded struct's fields.
This means that you may now have twice-nested slices, eg.
```go
type State struct {
Cities []struct{
Populations []int
}
}
```
See [the announcement](https://groups.google.com/forum/#!topic/google-api-go-announce/79jtrdeuJAg) for
more details.
_November 8, 2016_
Breaking changes to datastore: contexts no longer hold namespaces; instead you
must set a key's namespace explicitly. Also, key functions have been changed
and renamed.
* The WithNamespace function has been removed. To specify a namespace in a Query, use the Query.Namespace method:
```go
q := datastore.NewQuery("Kind").Namespace("ns")
```
* All the fields of Key are exported. That means you can construct any Key with a struct literal:
```go
k := &Key{Kind: "Kind", ID: 37, Namespace: "ns"}
```
* As a result of the above, the Key methods Kind, ID, d.Name, Parent, SetParent and Namespace have been removed.
* `NewIncompleteKey` has been removed, replaced by `IncompleteKey`. Replace
```go
NewIncompleteKey(ctx, kind, parent)
```
with
```go
IncompleteKey(kind, parent)
```
and if you do use namespaces, make sure you set the namespace on the returned key.
* `NewKey` has been removed, replaced by `NameKey` and `IDKey`. Replace
```go
NewKey(ctx, kind, name, 0, parent)
NewKey(ctx, kind, "", id, parent)
```
with
```go
NameKey(kind, name, parent)
IDKey(kind, id, parent)
```
and if you do use namespaces, make sure you set the namespace on the returned key.
* The `Done` variable has been removed. Replace `datastore.Done` with `iterator.Done`, from the package `google.golang.org/api/iterator`.
* The `Client.Close` method will have a return type of error. It will return the result of closing the underlying gRPC connection.
See [the announcement](https://groups.google.com/forum/#!topic/google-api-go-announce/hqXtM_4Ix-0) for
more details.
_October 27, 2016_
Breaking change to bigquery: `NewGCSReference` is now a function,
not a method on `Client`.
New bigquery feature: `Table.LoaderFrom` now accepts a `ReaderSource`, enabling
loading data into a table from a file or any `io.Reader`.
_October 21, 2016_
Breaking change to pubsub: removed `pubsub.Done`.
Use `iterator.Done` instead, where `iterator` is the package
`google.golang.org/api/iterator`.
_October 19, 2016_ _October 19, 2016_
Breaking changes to cloud.google.com/go/bigquery: Breaking changes to cloud.google.com/go/bigquery:
......
#!/bin/bash
# Selectively run tests for this repo, based on what has changed
# in a commit. Runs short tests for the whole repo, and full tests
# for changed directories.
set -e
prefix=cloud.google.com/go
dryrun=false
if [[ $1 == "-n" ]]; then
dryrun=true
shift
fi
if [[ $1 == "" ]]; then
echo >&2 "usage: $0 [-n] COMMIT"
exit 1
fi
# Files or directories that cause all tests to run if modified.
declare -A run_all
run_all=([.travis.yml]=1 [run-tests.sh]=1)
function run {
if $dryrun; then
echo $*
else
(set -x; $*)
fi
}
# Find all the packages that have changed in this commit.
declare -A changed_packages
for f in $(git diff-tree --no-commit-id --name-only -r $1); do
if [[ ${run_all[$f]} == 1 ]]; then
# This change requires a full test. Do it and exit.
run go test -race -v $prefix/...
exit
fi
# Map, e.g., "spanner/client.go" to "$prefix/spanner".
d=$(dirname $f)
if [[ $d == "." ]]; then
pkg=$prefix
else
pkg=$prefix/$d
fi
changed_packages[$pkg]=1
done
echo "changed packages: ${!changed_packages[*]}"
# Reports whether its argument, a package name, depends (recursively)
# on a changed package.
function depends_on_changed_package {
# According to go list, a package does not depend on itself, so
# we test that separately.
if [[ ${changed_packages[$1]} == 1 ]]; then
return 0
fi
for dep in $(go list -f '{{range .Deps}}{{.}} {{end}}' $1); do
if [[ ${changed_packages[$dep]} == 1 ]]; then
return 0
fi
done
return 1
}
# Collect the packages into two separate lists. (It is faster go test a list of
# packages than to individually go test each one.)
shorts=
fulls=
for pkg in $(go list $prefix/...); do # for each package in the repo
if depends_on_changed_package $pkg; then # if it depends on a changed package
fulls="$fulls $pkg" # run the full test
else # otherwise
shorts="$shorts $pkg" # run the short test
fi
done
run go test -race -v -short $shorts
run go test -race -v $fulls
urlesc [![Build Status](https://travis-ci.org/PuerkitoBio/urlesc.png?branch=master)](https://travis-ci.org/PuerkitoBio/urlesc) [![GoDoc](http://godoc.org/github.com/PuerkitoBio/urlesc?status.svg)](http://godoc.org/github.com/PuerkitoBio/urlesc) urlesc [![Build Status](https://travis-ci.org/PuerkitoBio/urlesc.svg?branch=master)](https://travis-ci.org/PuerkitoBio/urlesc) [![GoDoc](http://godoc.org/github.com/PuerkitoBio/urlesc?status.svg)](http://godoc.org/github.com/PuerkitoBio/urlesc)
====== ======
Package urlesc implements query escaping as per RFC 3986. Package urlesc implements query escaping as per RFC 3986.
......
language: go
matrix:
include:
- go: 1.4.3
- go: 1.5.4
- go: 1.6.3
- go: 1.7
- go: tip
allow_failures:
- go: tip
install:
- go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls
script:
- echo "Test and track coverage" ; $HOME/gopath/bin/goveralls -package "." -service=travis-ci
-repotoken $COVERALLS_TOKEN
- echo "Build examples" ; cd examples && go build
- echo "Check if gofmt'd" ; diff -u <(echo -n) <(gofmt -d -s .)
env:
global:
secure: HroGEAUQpVq9zX1b1VIkraLiywhGbzvNnTZq2TMxgK7JHP8xqNplAeF1izrR2i4QLL9nsY+9WtYss4QuPvEtZcVHUobw6XnL6radF7jS1LgfYZ9Y7oF+zogZ2I5QUMRLGA7rcxQ05s7mKq3XZQfeqaNts4bms/eZRefWuaFZbkw=
semver for golang [![Build Status](https://drone.io/github.com/blang/semver/status.png)](https://drone.io/github.com/blang/semver/latest) [![GoDoc](https://godoc.org/github.com/blang/semver?status.png)](https://godoc.org/github.com/blang/semver) [![Coverage Status](https://img.shields.io/coveralls/blang/semver.svg)](https://coveralls.io/r/blang/semver?branch=master) semver for golang [![Build Status](https://travis-ci.org/blang/semver.svg?branch=master)](https://travis-ci.org/blang/semver) [![GoDoc](https://godoc.org/github.com/blang/semver?status.png)](https://godoc.org/github.com/blang/semver) [![Coverage Status](https://img.shields.io/coveralls/blang/semver.svg)](https://coveralls.io/r/blang/semver?branch=master)
====== ======
semver is a [Semantic Versioning](http://semver.org/) library written in golang. It fully covers spec version `2.0.0`. semver is a [Semantic Versioning](http://semver.org/) library written in golang. It fully covers spec version `2.0.0`.
...@@ -41,6 +41,7 @@ Features ...@@ -41,6 +41,7 @@ Features
- Compare Helper Methods - Compare Helper Methods
- InPlace manipulation - InPlace manipulation
- Ranges `>=1.0.0 <2.0.0 || >=3.0.0 !3.0.1-beta.1` - Ranges `>=1.0.0 <2.0.0 || >=3.0.0 !3.0.1-beta.1`
- Wildcards `>=1.x`, `<=2.5.x`
- Sortable (implements sort.Interface) - Sortable (implements sort.Interface)
- database/sql compatible (sql.Scanner/Valuer) - database/sql compatible (sql.Scanner/Valuer)
- encoding/json compatible (json.Marshaler/Unmarshaler) - encoding/json compatible (json.Marshaler/Unmarshaler)
...@@ -59,6 +60,8 @@ A condition is composed of an operator and a version. The supported operators ar ...@@ -59,6 +60,8 @@ A condition is composed of an operator and a version. The supported operators ar
- `1.0.0`, `=1.0.0`, `==1.0.0` Equal to `1.0.0` - `1.0.0`, `=1.0.0`, `==1.0.0` Equal to `1.0.0`
- `!1.0.0`, `!=1.0.0` Not equal to `1.0.0`. Excludes version `1.0.0`. - `!1.0.0`, `!=1.0.0` Not equal to `1.0.0`. Excludes version `1.0.0`.
Note that spaces between the operator and the version will be gracefully tolerated.
A `Range` can link multiple `Ranges` separated by space: A `Range` can link multiple `Ranges` separated by space:
Ranges can be linked by logical AND: Ranges can be linked by logical AND:
......
...@@ -12,6 +12,6 @@ ...@@ -12,6 +12,6 @@
"license": "MIT", "license": "MIT",
"name": "semver", "name": "semver",
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"", "releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
"version": "3.4.0" "version": "3.5.1"
} }
...@@ -12,3 +12,4 @@ ...@@ -12,3 +12,4 @@
*.test *.test
tools/functional-tester/docker/bin tools/functional-tester/docker/bin
hack/tls-setup/certs hack/tls-setup/certs
.idea
...@@ -4,7 +4,8 @@ go_import_path: github.com/coreos/etcd ...@@ -4,7 +4,8 @@ go_import_path: github.com/coreos/etcd
sudo: false sudo: false
go: go:
- 1.7.5 - 1.8.3
- tip
notifications: notifications:
on_success: never on_success: never
...@@ -13,6 +14,8 @@ notifications: ...@@ -13,6 +14,8 @@ notifications:
env: env:
matrix: matrix:
- TARGET=amd64 - TARGET=amd64
- TARGET=darwin-amd64
- TARGET=windows-amd64
- TARGET=arm64 - TARGET=arm64
- TARGET=arm - TARGET=arm
- TARGET=386 - TARGET=386
...@@ -23,6 +26,10 @@ matrix: ...@@ -23,6 +26,10 @@ matrix:
allow_failures: allow_failures:
- go: tip - go: tip
exclude: exclude:
- go: tip
env: TARGET=darwin-amd64
- go: tip
env: TARGET=windows-amd64
- go: tip - go: tip
env: TARGET=arm env: TARGET=arm
- go: tip - go: tip
...@@ -32,6 +39,24 @@ matrix: ...@@ -32,6 +39,24 @@ matrix:
- go: tip - go: tip
env: TARGET=ppc64le env: TARGET=ppc64le
addons:
apt:
sources:
- debian-sid
packages:
- libpcap-dev
- libaspell-dev
- libhunspell-dev
- shellcheck
before_install:
- go get -v -u github.com/chzchzchz/goword
- go get -v -u github.com/coreos/license-bill-of-materials
- go get -v -u honnef.co/go/tools/cmd/gosimple
- go get -v -u honnef.co/go/tools/cmd/unused
- go get -v -u honnef.co/go/tools/cmd/staticcheck
- ./scripts/install-marker.sh amd64
# disable godep restore override # disable godep restore override
install: install:
- pushd cmd/etcd && go get -t -v ./... && popd - pushd cmd/etcd && go get -t -v ./... && popd
...@@ -42,6 +67,12 @@ script: ...@@ -42,6 +67,12 @@ script:
amd64) amd64)
GOARCH=amd64 ./test GOARCH=amd64 ./test
;; ;;
darwin-amd64)
GO_BUILD_FLAGS="-a -v" GOPATH="" GOOS=darwin GOARCH=amd64 ./build
;;
windows-amd64)
GO_BUILD_FLAGS="-a -v" GOPATH="" GOOS=windows GOARCH=amd64 ./build
;;
386) 386)
GOARCH=386 PASSES="build unit" ./test GOARCH=386 PASSES="build unit" ./test
;; ;;
......
# How to contribute # How to contribute
etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on commit message formatting, contact points for developers and other resources to make getting your contribution into etcd easier. etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests. This document outlines some of the conventions on commit message formatting, contact points for developers, and other resources to help get contributions into etcd.
# Email and chat # Email and chat
...@@ -14,24 +14,20 @@ etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests. ...@@ -14,24 +14,20 @@ etcd is Apache 2.0 licensed and accepts contributions via GitHub pull requests.
## Reporting bugs and creating issues ## Reporting bugs and creating issues
Reporting bugs is one of the best ways to contribute. However, a good bug report Reporting bugs is one of the best ways to contribute. However, a good bug report has some very specific qualities, so please read over our short document on [reporting bugs](https://github.com/coreos/etcd/blob/master/Documentation/reporting_bugs.md) before submitting a bug report. This document might contain links to known issues, another good reason to take a look there before reporting a bug.
has some very specific qualities, so please read over our short document on
[reporting bugs](https://github.com/coreos/etcd/blob/master/Documentation/reporting_bugs.md)
before you submit your bug report. This document might contain links known
issues, another good reason to take a look there, before reporting your bug.
## Contribution flow ## Contribution flow
This is a rough outline of what a contributor's workflow looks like: This is a rough outline of what a contributor's workflow looks like:
- Create a topic branch from where you want to base your work. This is usually master. - Create a topic branch from where to base the contribution. This is usually master.
- Make commits of logical units. - Make commits of logical units.
- Make sure your commit messages are in the proper format (see below). - Make sure commit messages are in the proper format (see below).
- Push your changes to a topic branch in your fork of the repository. - Push changes in a topic branch to a personal fork of the repository.
- Submit a pull request to coreos/etcd. - Submit a pull request to coreos/etcd.
- Your PR must receive a LGTM from two maintainers found in the MAINTAINERS file. - The PR must receive a LGTM from two maintainers found in the MAINTAINERS file.
Thanks for your contributions! Thanks for contributing!
### Code style ### Code style
...@@ -48,8 +44,7 @@ the body of the commit should describe the why. ...@@ -48,8 +44,7 @@ the body of the commit should describe the why.
``` ```
scripts: add the test-cluster command scripts: add the test-cluster command
this uses tmux to setup a test cluster that you can easily kill and this uses tmux to setup a test cluster that can easily be killed and started for debugging.
start for debugging.
Fixes #38 Fixes #38
``` ```
...@@ -64,7 +59,4 @@ The format can be described more formally as follows: ...@@ -64,7 +59,4 @@ The format can be described more formally as follows:
<footer> <footer>
``` ```
The first line is the subject and should be no longer than 70 characters, the The first line is the subject and should be no longer than 70 characters, the second line is always blank, and other lines should be wrapped at 80 characters. This allows the message to be easier to read on GitHub as well as in various git tools.
second line is always blank, and other lines should be wrapped at 80 characters.
This allows the message to be easier to read on GitHub as well as in various
git tools.
FROM aarch64/ubuntu:16.04
ADD etcd /usr/local/bin/
ADD etcdctl /usr/local/bin/
ADD var/etcd /var/etcd
ADD var/lib/etcd /var/lib/etcd
EXPOSE 2379 2380
# Define default command.
CMD ["/usr/local/bin/etcd"]
FROM ppc64le/ubuntu:16.04
ADD etcd /usr/local/bin/
ADD etcdctl /usr/local/bin/
ADD var/etcd /var/etcd
ADD var/lib/etcd /var/lib/etcd
EXPOSE 2379 2380
# Define default command.
CMD ["/usr/local/bin/etcd"]
Anthony Romano <anthony.romano@coreos.com> (@heyitsanthony) pkg:* Anthony Romano <anthony.romano@coreos.com> (@heyitsanthony) pkg:*
Brandon Philips <brandon.philips@coreos.com> (@philips) pkg:* Brandon Philips <brandon.philips@coreos.com> (@philips) pkg:*
Fanmin Shi <fanmin.shi@coreos.com> (@fanminshi) pkg:*
Gyu-Ho Lee <gyu_ho.lee@coreos.com> (@gyuho) pkg:* Gyu-Ho Lee <gyu_ho.lee@coreos.com> (@gyuho) pkg:*
Xiang Li <xiang.li@coreos.com> (@xiang90) pkg:* Xiang Li <xiang.li@coreos.com> (@xiang90) pkg:*
......
etcd v3.1.6 (2017-04-19)
- remove auth check in Status API
- fill in Auth API response header
etcd v3.1.5 (2017-03-27)
- add '/etc/nsswitch.conf' file to alpine-based Docker image
- fix raft memory leak issue
- fix Windows file path issues
etcd v3.1.4 (2017-03-22)
etcd v3.1.3 (2017-03-10)
- use machine default host when advertise URLs are default
values(localhost:2379,2380) AND if listen URL is 0.0.0.0
- fix 'etcd gateway' schema handling in DNS discovery
- fix sd_notify behaviors in gateway, grpc-proxy
etcd v3.1.2 (2017-02-24)
- use IPv4 default host, by default (when IPv4 and IPv6 are available)
- fix 'etcd gateway' with multiple endpoints
etcd v3.1.1 (2017-02-17)
etcd v2.3.8 (2017-02-17)
etcd v3.1.0 (2017-01-20) etcd v3.1.0 (2017-01-20)
- faster linearizable reads (implements Raft read-index) - faster linearizable reads (implements Raft read-index)
- automatic leadership transfer when leader steps down - automatic leadership transfer when leader steps down
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
![etcd Logo](logos/etcd-horizontal-color.png) ![etcd Logo](logos/etcd-horizontal-color.png)
etcd is a distributed, consistent key-value store for shared configuration and service discovery, with a focus on being: etcd is a distributed reliable key-value store for the most critical data of a distributed system, with a focus on being:
* *Simple*: well-defined, user-facing API (gRPC) * *Simple*: well-defined, user-facing API (gRPC)
* *Secure*: automatic TLS with optional client cert authentication * *Secure*: automatic TLS with optional client cert authentication
...@@ -39,12 +39,9 @@ See [etcdctl][etcdctl] for a simple command line client. ...@@ -39,12 +39,9 @@ See [etcdctl][etcdctl] for a simple command line client.
The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, [rkt][rkt], and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release]. The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, [rkt][rkt], and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release].
For those wanting to try the very latest version, you can [build the latest version of etcd][dl-build] from the `master` branch. For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.8+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.
You will first need [*Go*](https://golang.org/) installed on your machine (version 1.7+ is required).
All development occurs on `master`, including new features and bug fixes.
Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.
[rkt]: https://github.com/coreos/rkt/releases/ [rkt]: https://github.com/rkt/rkt/releases/
[github-release]: https://github.com/coreos/etcd/releases/ [github-release]: https://github.com/coreos/etcd/releases/
[branch-management]: ./Documentation/branch_management.md [branch-management]: ./Documentation/branch_management.md
[dl-build]: ./Documentation/dl_build.md#build-the-latest-version [dl-build]: ./Documentation/dl_build.md#build-the-latest-version
...@@ -76,7 +73,7 @@ That's it! etcd is now running and serving client requests. For more ...@@ -76,7 +73,7 @@ That's it! etcd is now running and serving client requests. For more
### etcd TCP ports ### etcd TCP ports
The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication. The [official etcd ports][iana-ports] are 2379 for client requests, and 2380 for peer communication.
[iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt [iana-ports]: http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.txt
...@@ -96,7 +93,7 @@ Every cluster member and proxy accepts key value reads and key value writes. ...@@ -96,7 +93,7 @@ Every cluster member and proxy accepts key value reads and key value writes.
### Running etcd on Kubernetes ### Running etcd on Kubernetes
If you want to run etcd cluster on Kubernetes, try [etcd operator](https://github.com/coreos/etcd-operator). To run an etcd cluster on Kubernetes, try [etcd operator](https://github.com/coreos/etcd-operator).
### Next steps ### Next steps
...@@ -106,7 +103,7 @@ Now it's time to dig into the full etcd API and other guides. ...@@ -106,7 +103,7 @@ Now it's time to dig into the full etcd API and other guides.
- Explore the full gRPC [API][api]. - Explore the full gRPC [API][api].
- Set up a [multi-machine cluster][clustering]. - Set up a [multi-machine cluster][clustering].
- Learn the [config format, env variables and flags][configuration]. - Learn the [config format, env variables and flags][configuration].
- Find [language bindings and tools][libraries-and-tools]. - Find [language bindings and tools][integrations].
- Use TLS to [secure an etcd cluster][security]. - Use TLS to [secure an etcd cluster][security].
- [Tune etcd][tuning]. - [Tune etcd][tuning].
...@@ -114,7 +111,7 @@ Now it's time to dig into the full etcd API and other guides. ...@@ -114,7 +111,7 @@ Now it's time to dig into the full etcd API and other guides.
[api]: ./Documentation/dev-guide/api_reference_v3.md [api]: ./Documentation/dev-guide/api_reference_v3.md
[clustering]: ./Documentation/op-guide/clustering.md [clustering]: ./Documentation/op-guide/clustering.md
[configuration]: ./Documentation/op-guide/configuration.md [configuration]: ./Documentation/op-guide/configuration.md
[libraries-and-tools]: ./Documentation/libraries-and-tools.md [integrations]: ./Documentation/integrations.md
[security]: ./Documentation/op-guide/security.md [security]: ./Documentation/op-guide/security.md
[tuning]: ./Documentation/tuning.md [tuning]: ./Documentation/tuning.md
...@@ -131,7 +128,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the co ...@@ -131,7 +128,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) for details on submitting patches and the co
## Reporting bugs ## Reporting bugs
See [reporting bugs](Documentation/reporting_bugs.md) for details about reporting any issue you may encounter. See [reporting bugs](Documentation/reporting_bugs.md) for details about reporting any issues.
### License ### License
......
...@@ -6,7 +6,7 @@ This document defines a high level roadmap for etcd development. ...@@ -6,7 +6,7 @@ This document defines a high level roadmap for etcd development.
The dates below should not be considered authoritative, but rather indicative of the projected timeline of the project. The [milestones defined in GitHub](https://github.com/coreos/etcd/milestones) represent the most up-to-date and issue-for-issue plans. The dates below should not be considered authoritative, but rather indicative of the projected timeline of the project. The [milestones defined in GitHub](https://github.com/coreos/etcd/milestones) represent the most up-to-date and issue-for-issue plans.
etcd 3.1 is our current stable branch. The roadmap below outlines new features that will be added to etcd, and while subject to change, define what future stable will look like. etcd 3.2 is our current stable branch. The roadmap below outlines new features that will be added to etcd, and while subject to change, define what future stable will look like.
### etcd 3.2 (2017-May) ### etcd 3.2 (2017-May)
- Stable scalable proxy - Stable scalable proxy
......
[
{
"project": "bitbucket.org/ww/goautoneg",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 1
}
]
},
{
"project": "github.com/beorn7/perks/quantile",
"licenses": [
{
"type": "MIT License",
"confidence": 0.9891304347826086
}
]
},
{
"project": "github.com/bgentry/speakeasy",
"licenses": [
{
"type": "MIT License",
"confidence": 0.9441624365482234
}
]
},
{
"project": "github.com/boltdb/bolt",
"licenses": [
{
"type": "MIT License",
"confidence": 1
}
]
},
{
"project": "github.com/cockroachdb/cmux",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/coreos/etcd",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/coreos/go-semver/semver",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/coreos/go-systemd",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 0.9966703662597114
}
]
},
{
"project": "github.com/coreos/pkg",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/cpuguy83/go-md2man/md2man",
"licenses": [
{
"type": "MIT License",
"confidence": 1
}
]
},
{
"project": "github.com/dgrijalva/jwt-go",
"licenses": [
{
"type": "MIT License",
"confidence": 0.9891304347826086
}
]
},
{
"project": "github.com/dustin/go-humanize",
"licenses": [
{
"type": "MIT License",
"confidence": 0.96875
}
]
},
{
"project": "github.com/ghodss/yaml",
"licenses": [
{
"type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 1
}
]
},
{
"project": "github.com/gogo/protobuf/proto",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9090909090909091
}
]
},
{
"project": "github.com/golang/groupcache/lru",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 0.9966703662597114
}
]
},
{
"project": "github.com/golang/protobuf",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.92
}
]
},
{
"project": "github.com/google/btree",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/grpc-ecosystem/go-grpc-prometheus",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/grpc-ecosystem/grpc-gateway",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.979253112033195
}
]
},
{
"project": "github.com/inconshreveable/mousetrap",
"licenses": [
{
"type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 1
},
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/jonboulle/clockwork",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/mattn/go-runewidth",
"licenses": [
{
"type": "MIT License",
"confidence": 1
}
]
},
{
"project": "github.com/matttproud/golang_protobuf_extensions/pbutil",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/olekukonko/tablewriter",
"licenses": [
{
"type": "MIT License",
"confidence": 0.9891304347826086
}
]
},
{
"project": "github.com/prometheus/client_golang/prometheus",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/prometheus/client_model/go",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/prometheus/common",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/prometheus/procfs",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 1
}
]
},
{
"project": "github.com/russross/blackfriday",
"licenses": [
{
"type": "BSD 2-clause \"Simplified\" License",
"confidence": 0.9626168224299065
}
]
},
{
"project": "github.com/spf13/cobra",
"licenses": [
{
"type": "Apache License 2.0",
"confidence": 0.9573241061130334
}
]
},
{
"project": "github.com/spf13/pflag",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
},
{
"project": "github.com/ugorji/go/codec",
"licenses": [
{
"type": "MIT License",
"confidence": 0.9946524064171123
}
]
},
{
"project": "github.com/urfave/cli",
"licenses": [
{
"type": "MIT License",
"confidence": 1
}
]
},
{
"project": "github.com/xiang90/probing",
"licenses": [
{
"type": "MIT License",
"confidence": 1
}
]
},
{
"project": "golang.org/x/crypto",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
},
{
"project": "golang.org/x/net",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
},
{
"project": "golang.org/x/text",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
},
{
"project": "golang.org/x/time/rate",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9663865546218487
}
]
},
{
"project": "google.golang.org/grpc",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.979253112033195
}
]
},
{
"project": "gopkg.in/cheggaaa/pb.v1",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License",
"confidence": 0.9916666666666667
}
]
},
{
"project": "gopkg.in/yaml.v2",
"licenses": [
{
"type": "The Unlicense",
"confidence": 0.35294117647058826
},
{
"type": "MIT License",
"confidence": 0.8975609756097561
}
]
}
]
[
{
"project": "bitbucket.org/ww/goautoneg",
"licenses": [
{
"type": "BSD 3-clause \"New\" or \"Revised\" License"
}
]
},
{
"project": "github.com/ghodss/yaml",
"licenses": [
{
"type": "MIT License and BSD 3-clause \"New\" or \"Revised\" License"
}
]
},
{
"project": "github.com/inconshreveable/mousetrap",
"licenses": [
{
"type": "Apache License 2.0"
}
]
}
]
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
# set some environment variables # set some environment variables
ORG_PATH="github.com/coreos" ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/etcd" REPO_PATH="${ORG_PATH}/etcd"
export GO15VENDOREXPERIMENT="1"
eval $(go env)
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"` GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
if [ ! -z "$FAILPOINTS" ]; then if [ ! -z "$FAILPOINTS" ]; then
GIT_SHA="$GIT_SHA"-FAILPOINTS GIT_SHA="$GIT_SHA"-FAILPOINTS
...@@ -17,11 +15,7 @@ GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=$ ...@@ -17,11 +15,7 @@ GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=$
# enable/disable failpoints # enable/disable failpoints
toggle_failpoints() { toggle_failpoints() {
FAILPKGS="etcdserver/ mvcc/backend/" FAILPKGS="etcdserver/ mvcc/backend/"
mode="$1"
mode="disable"
if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
if [ ! -z "$1" ]; then mode="$1"; fi
if which gofail >/dev/null 2>&1; then if which gofail >/dev/null 2>&1; then
gofail "$mode" $FAILPKGS gofail "$mode" $FAILPKGS
elif [ "$mode" != "disable" ]; then elif [ "$mode" != "disable" ]; then
...@@ -30,19 +24,26 @@ toggle_failpoints() { ...@@ -30,19 +24,26 @@ toggle_failpoints() {
fi fi
} }
toggle_failpoints_default() {
mode="disable"
if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
toggle_failpoints "$mode"
}
etcd_build() { etcd_build() {
out="bin" out="bin"
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
toggle_failpoints toggle_failpoints_default
# Static compilation is useful when etcd is run in a container # Static compilation is useful when etcd is run in a container
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcd ${REPO_PATH}/cmd/etcd || return CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcd ${REPO_PATH}/cmd/etcd || return
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return
} }
etcd_setup_gopath() { etcd_setup_gopath() {
CDIR=$(cd `dirname "$0"` && pwd) d=$(dirname "$0")
CDIR=$(cd "$d" && pwd)
cd "$CDIR" cd "$CDIR"
etcdGOPATH=${CDIR}/gopath etcdGOPATH="${CDIR}/gopath"
# preserve old gopath to support building with unvendored tooling deps (e.g., gofail) # preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
if [ -n "$GOPATH" ]; then if [ -n "$GOPATH" ]; then
GOPATH=":$GOPATH" GOPATH=":$GOPATH"
...@@ -53,7 +54,7 @@ etcd_setup_gopath() { ...@@ -53,7 +54,7 @@ etcd_setup_gopath() {
ln -s ${CDIR}/cmd/vendor ${etcdGOPATH}/src ln -s ${CDIR}/cmd/vendor ${etcdGOPATH}/src
} }
toggle_failpoints toggle_failpoints_default
# only build when called directly, not sourced # only build when called directly, not sourced
if echo "$0" | grep "build$" >/dev/null; then if echo "$0" | grep "build$" >/dev/null; then
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
package client package client
import ( import (
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
...@@ -27,6 +28,8 @@ import ( ...@@ -27,6 +28,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/coreos/etcd/version"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
...@@ -201,6 +204,9 @@ type Client interface { ...@@ -201,6 +204,9 @@ type Client interface {
// returned // returned
SetEndpoints(eps []string) error SetEndpoints(eps []string) error
// GetVersion retrieves the current etcd server and cluster version
GetVersion(ctx context.Context) (*version.Versions, error)
httpClient httpClient
} }
...@@ -477,6 +483,33 @@ func (c *httpClusterClient) AutoSync(ctx context.Context, interval time.Duration ...@@ -477,6 +483,33 @@ func (c *httpClusterClient) AutoSync(ctx context.Context, interval time.Duration
} }
} }
func (c *httpClusterClient) GetVersion(ctx context.Context) (*version.Versions, error) {
act := &getAction{Prefix: "/version"}
resp, body, err := c.Do(ctx, act)
if err != nil {
return nil, err
}
switch resp.StatusCode {
case http.StatusOK:
if len(body) == 0 {
return nil, ErrEmptyBody
}
var vresp version.Versions
if err := json.Unmarshal(body, &vresp); err != nil {
return nil, ErrInvalidJSON
}
return &vresp, nil
default:
var etcdErr Error
if err := json.Unmarshal(body, &etcdErr); err != nil {
return nil, ErrInvalidJSON
}
return nil, etcdErr
}
}
type roundTripResponse struct { type roundTripResponse struct {
resp *http.Response resp *http.Response
err error err error
......
...@@ -28,6 +28,7 @@ import ( ...@@ -28,6 +28,7 @@ import (
"time" "time"
"github.com/coreos/etcd/pkg/testutil" "github.com/coreos/etcd/pkg/testutil"
"github.com/coreos/etcd/version"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
...@@ -860,6 +861,34 @@ func TestHTTPClusterClientAutoSyncFail(t *testing.T) { ...@@ -860,6 +861,34 @@ func TestHTTPClusterClientAutoSyncFail(t *testing.T) {
} }
} }
func TestHTTPClusterClientGetVersion(t *testing.T) {
body := []byte(`{"etcdserver":"2.3.2","etcdcluster":"2.3.0"}`)
cf := newStaticHTTPClientFactory([]staticHTTPResponse{
{
resp: http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Length": []string{"44"}}},
body: body,
},
})
hc := &httpClusterClient{
clientFactory: cf,
rand: rand.New(rand.NewSource(0)),
}
err := hc.SetEndpoints([]string{"http://127.0.0.1:4003", "http://127.0.0.1:2379", "http://127.0.0.1:4001", "http://127.0.0.1:4002"})
if err != nil {
t.Fatalf("unexpected error during setup: %#v", err)
}
actual, err := hc.GetVersion(context.Background())
if err != nil {
t.Errorf("non-nil error: %#v", err)
}
expected := version.Versions{Server: "2.3.2", Cluster: "2.3.0"}
if !reflect.DeepEqual(&expected, actual) {
t.Errorf("incorrect Response: want=%#v got=%#v", expected, actual)
}
}
// TestHTTPClusterClientSyncPinEndpoint tests that Sync() pins the endpoint when // TestHTTPClusterClientSyncPinEndpoint tests that Sync() pins the endpoint when
// it gets the exactly same member list as before. // it gets the exactly same member list as before.
func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) { func TestHTTPClusterClientSyncPinEndpoint(t *testing.T) {
......
...@@ -14,8 +14,27 @@ ...@@ -14,8 +14,27 @@
package client package client
import (
"github.com/coreos/etcd/pkg/srv"
)
// Discoverer is an interface that wraps the Discover method. // Discoverer is an interface that wraps the Discover method.
type Discoverer interface { type Discoverer interface {
// Discover looks up the etcd servers for the domain. // Discover looks up the etcd servers for the domain.
Discover(domain string) ([]string, error) Discover(domain string) ([]string, error)
} }
type srvDiscover struct{}
// NewSRVDiscover constructs a new Discoverer that uses the stdlib to lookup SRV records.
func NewSRVDiscover() Discoverer {
return &srvDiscover{}
}
func (d *srvDiscover) Discover(domain string) ([]string, error) {
srvs, err := srv.GetClient("etcd-client", domain)
if err != nil {
return nil, err
}
return srvs.Endpoints, nil
}
...@@ -35,7 +35,7 @@ max-snapshots: 5 ...@@ -35,7 +35,7 @@ max-snapshots: 5
max-wals: 5 max-wals: 5
# Comma-separated white list of origins for CORS (cross-origin resource sharing). # Comma-separated white list of origins for CORS (cross-origin resource sharing).
cors: cors:
# List of this member's peer URLs to advertise to the rest of the cluster. # List of this member's peer URLs to advertise to the rest of the cluster.
# The URLs needed to be a comma-separated list. # The URLs needed to be a comma-separated list.
...@@ -46,16 +46,16 @@ initial-advertise-peer-urls: http://localhost:2380 ...@@ -46,16 +46,16 @@ initial-advertise-peer-urls: http://localhost:2380
advertise-client-urls: http://localhost:2379 advertise-client-urls: http://localhost:2379
# Discovery URL used to bootstrap the cluster. # Discovery URL used to bootstrap the cluster.
discovery: discovery:
# Valid values include 'exit', 'proxy' # Valid values include 'exit', 'proxy'
discovery-fallback: 'proxy' discovery-fallback: 'proxy'
# HTTP proxy to use for traffic to discovery service. # HTTP proxy to use for traffic to discovery service.
discovery-proxy: discovery-proxy:
# DNS domain used to bootstrap initial cluster. # DNS domain used to bootstrap initial cluster.
discovery-srv: discovery-srv:
# Initial cluster configuration for bootstrapping. # Initial cluster configuration for bootstrapping.
initial-cluster: initial-cluster:
...@@ -69,6 +69,12 @@ initial-cluster-state: 'new' ...@@ -69,6 +69,12 @@ initial-cluster-state: 'new'
# Reject reconfiguration requests that would cause quorum loss. # Reject reconfiguration requests that would cause quorum loss.
strict-reconfig-check: false strict-reconfig-check: false
# Accept etcd V2 client requests
enable-v2: true
# Enable runtime profiling data via HTTP server
enable-pprof: true
# Valid values include 'on', 'readonly', 'off' # Valid values include 'on', 'readonly', 'off'
proxy: 'off' proxy: 'off'
...@@ -87,40 +93,40 @@ proxy-write-timeout: 5000 ...@@ -87,40 +93,40 @@ proxy-write-timeout: 5000
# Time (in milliseconds) for a read to timeout. # Time (in milliseconds) for a read to timeout.
proxy-read-timeout: 0 proxy-read-timeout: 0
client-transport-security: client-transport-security:
# DEPRECATED: Path to the client server TLS CA file. # DEPRECATED: Path to the client server TLS CA file.
ca-file: ca-file:
# Path to the client server TLS cert file. # Path to the client server TLS cert file.
cert-file: cert-file:
# Path to the client server TLS key file. # Path to the client server TLS key file.
key-file: key-file:
# Enable client cert authentication. # Enable client cert authentication.
client-cert-auth: false client-cert-auth: false
# Path to the client server TLS trusted CA key file. # Path to the client server TLS trusted CA key file.
trusted-ca-file: trusted-ca-file:
# Client TLS using generated certificates # Client TLS using generated certificates
auto-tls: false auto-tls: false
peer-transport-security: peer-transport-security:
# DEPRECATED: Path to the peer server TLS CA file. # DEPRECATED: Path to the peer server TLS CA file.
ca-file: ca-file:
# Path to the peer server TLS cert file. # Path to the peer server TLS cert file.
cert-file: cert-file:
# Path to the peer server TLS key file. # Path to the peer server TLS key file.
key-file: key-file:
# Enable peer client cert authentication. # Enable peer client cert authentication.
client-cert-auth: false client-cert-auth: false
# Path to the peer server TLS trusted CA key file. # Path to the peer server TLS trusted CA key file.
trusted-ca-file: trusted-ca-file:
# Peer TLS using generated certificates. # Peer TLS using generated certificates.
auto-tls: false auto-tls: false
...@@ -129,7 +135,7 @@ peer-transport-security: ...@@ -129,7 +135,7 @@ peer-transport-security:
debug: false debug: false
# Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG'. # Specify a particular log level for each etcd package (eg: 'etcdmain=CRITICAL,etcdserver=DEBUG'.
log-package-levels: log-package-levels:
# Force to create a new one member cluster. # Force to create a new one member cluster.
force-new-cluster: false force-new-cluster: false
hash: ca3c895fa60c9ca9f53408202fb7643705f9960212d342967ed0da8e93606cc4 hash: cee1f2629857e9c2384ad89ff6014db09498c9af53771e5144ad3a4b510ff00e
updated: 2017-01-18T10:26:48.990115455-08:00 updated: 2017-05-30T10:29:08.22609283-07:00
imports: imports:
- name: github.com/beorn7/perks - name: github.com/beorn7/perks
version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9
subpackages: subpackages:
- quantile - quantile
- name: github.com/bgentry/speakeasy - name: github.com/bgentry/speakeasy
version: 36e9cfdd690967f4f690c6edcc9ffacd006014a0 version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
- name: github.com/boltdb/bolt - name: github.com/boltdb/bolt
version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9 version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9
- name: github.com/cockroachdb/cmux - name: github.com/cockroachdb/cmux
version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92 version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92
- name: github.com/coreos/go-semver - name: github.com/coreos/go-semver
version: 568e959cd89871e61434c1143528d9162da89ef2 version: 8ab6407b697782a06568d4b7f1db25550ec2e4c6
subpackages: subpackages:
- semver - semver
- name: github.com/coreos/go-systemd - name: github.com/coreos/go-systemd
...@@ -27,17 +27,23 @@ imports: ...@@ -27,17 +27,23 @@ imports:
- capnslog - capnslog
- dlopen - dlopen
- name: github.com/cpuguy83/go-md2man - name: github.com/cpuguy83/go-md2man
version: a65d4d2de4d5f7c74868dfa9b202a3c8be315aaa version: bcc0a711c5e6bbe72c7cb13d81c7109b45267fd2
subpackages: subpackages:
- md2man - md2man
- name: github.com/dgrijalva/jwt-go
version: d2709f9f1f31ebcda9651b03077758c1f3a0018c
- name: github.com/dustin/go-humanize - name: github.com/dustin/go-humanize
version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0 version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
- name: github.com/ghodss/yaml - name: github.com/ghodss/yaml
version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee version: 0ca9ea5df5451ffdf184b4428c902747c2c11cd7
- name: github.com/gogo/protobuf - name: github.com/gogo/protobuf
version: 909568be09de550ed094403c2bf8a261b5bb730a version: 909568be09de550ed094403c2bf8a261b5bb730a
subpackages: subpackages:
- proto - proto
- name: github.com/golang/groupcache
version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
subpackages:
- lru
- name: github.com/golang/protobuf - name: github.com/golang/protobuf
version: 4bd1920723d7b7c925de087aa32e2187708897f7 version: 4bd1920723d7b7c925de087aa32e2187708897f7
subpackages: subpackages:
...@@ -48,7 +54,7 @@ imports: ...@@ -48,7 +54,7 @@ imports:
- name: github.com/grpc-ecosystem/go-grpc-prometheus - name: github.com/grpc-ecosystem/go-grpc-prometheus
version: 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 version: 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
- name: github.com/grpc-ecosystem/grpc-gateway - name: github.com/grpc-ecosystem/grpc-gateway
version: 84398b94e188ee336f307779b57b3aa91af7063c version: 18d159699f2e83fc5bb9ef2f79465ca3f3122676
subpackages: subpackages:
- runtime - runtime
- runtime/internal - runtime/internal
...@@ -57,46 +63,42 @@ imports: ...@@ -57,46 +63,42 @@ imports:
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
- name: github.com/jonboulle/clockwork - name: github.com/jonboulle/clockwork
version: 2eee05ed794112d45db504eb05aa693efd2b8b09 version: 2eee05ed794112d45db504eb05aa693efd2b8b09
- name: github.com/karlseguin/ccache
version: a2d62155777b39595c825ed3824279e642a5db3c
- name: github.com/kr/pty - name: github.com/kr/pty
version: f7ee69f31298ecbe5d2b349c711e2547a617d398 version: 2c10821df3c3cf905230d078702dfbe9404c9b23
- name: github.com/mattn/go-runewidth - name: github.com/mattn/go-runewidth
version: 737072b4e32b7a5018b4a7125da8d12de90e8045 version: 9e777a8366cce605130a531d2cd6363d07ad7317
subpackages:
- runewidth.go
- name: github.com/matttproud/golang_protobuf_extensions - name: github.com/matttproud/golang_protobuf_extensions
version: c12348ce28de40eed0136aa2b644d0ee0650e56c version: c12348ce28de40eed0136aa2b644d0ee0650e56c
subpackages: subpackages:
- pbutil - pbutil
- name: github.com/olekukonko/tablewriter - name: github.com/olekukonko/tablewriter
version: cca8bbc0798408af109aaaa239cbd2634846b340 version: a0225b3f23b5ce0cbec6d7a66a968f8a59eca9c4
- name: github.com/prometheus/client_golang - name: github.com/prometheus/client_golang
version: c5b7fccd204277076155f10851dad72b76a49317 version: c5b7fccd204277076155f10851dad72b76a49317
subpackages: subpackages:
- prometheus - prometheus
- name: github.com/prometheus/client_model - name: github.com/prometheus/client_model
version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6 version: 6f3806018612930941127f2a7c6c453ba2c527d2
subpackages: subpackages:
- go - go
- name: github.com/prometheus/common - name: github.com/prometheus/common
version: 195bde7883f7c39ea62b0d92ab7359b5327065cb version: 49fee292b27bfff7f354ee0f64e1bc4850462edf
subpackages: subpackages:
- expfmt - expfmt
- internal/bitbucket.org/ww/goautoneg - internal/bitbucket.org/ww/goautoneg
- model - model
- name: github.com/prometheus/procfs - name: github.com/prometheus/procfs
version: fcdb11ccb4389efb1b210b7ffb623ab71c5fdd60 version: a1dba9ce8baed984a2495b658c82687f8157b98f
subpackages:
- xfs
- name: github.com/russross/blackfriday - name: github.com/russross/blackfriday
version: 5f33e7b7878355cd2b7e6b8eefc48a5472c69f70 version: 0ba0f2b6ed7c475a92e4df8641825cb7a11d1fa3
- name: github.com/shurcooL/sanitized_anchor_name
version: 1dba4b3954bc059efc3991ec364f9f9a35f597d2
- name: github.com/spf13/cobra - name: github.com/spf13/cobra
version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b
- name: github.com/spf13/pflag - name: github.com/spf13/pflag
version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5 version: 08b1a584251b5b62f458943640fc8ebd4d50aaa5
- name: github.com/stretchr/testify
version: 976c720a22c8eb4eb6a0b4348ad85ad12491a506
subpackages:
- assert
- name: github.com/ugorji/go - name: github.com/ugorji/go
version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74 version: ded73eae5db7e7a0ef6f55aace87a2873c5d2b74
subpackages: subpackages:
...@@ -111,7 +113,7 @@ imports: ...@@ -111,7 +113,7 @@ imports:
- bcrypt - bcrypt
- blowfish - blowfish
- name: golang.org/x/net - name: golang.org/x/net
version: f2499483f923065a842d38eb4c7f1927e6fc6e6d version: c8c74377599bd978aee1cf3b9b63a8634051cec2
subpackages: subpackages:
- context - context
- http2 - http2
...@@ -121,34 +123,36 @@ imports: ...@@ -121,34 +123,36 @@ imports:
- lex/httplex - lex/httplex
- trace - trace
- name: golang.org/x/sys - name: golang.org/x/sys
version: 478fcf54317e52ab69f40bb4c7a1520288d7f7ea version: e48874b42435b4347fc52bdee0424a52abc974d7
subpackages: subpackages:
- unix - unix
- name: golang.org/x/text
version: 4ee4af566555f5fbe026368b75596286a312663a
subpackages:
- secure/bidirule
- transform
- unicode/bidi
- unicode/norm
- name: golang.org/x/time - name: golang.org/x/time
version: a4bde12657593d5e90d0533a3e4fd95e635124cb version: c06e80d9300e4443158a03817b8a8cb37d230320
subpackages: subpackages:
- rate - rate
- name: google.golang.org/grpc - name: google.golang.org/grpc
version: 777daa17ff9b5daef1cfdf915088a2ada3332bf0 version: 8050b9cbc271307e5a716a9d782803d09b0d6f2d
subpackages: subpackages:
- codes - codes
- credentials - credentials
- grpclog - grpclog
- internal - internal
- keepalive
- metadata - metadata
- naming - naming
- peer - peer
- stats
- tap
- transport - transport
- name: gopkg.in/cheggaaa/pb.v1 - name: gopkg.in/cheggaaa/pb.v1
version: 226d21d43a305fac52b3a104ef83e721b15275e0 version: 226d21d43a305fac52b3a104ef83e721b15275e0
- name: gopkg.in/yaml.v2 - name: gopkg.in/yaml.v2
version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
testImports: testImports: []
- name: github.com/davecgh/go-spew
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
subpackages:
- spew
- name: github.com/pmezard/go-difflib
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
subpackages:
- difflib
package: github.com/coreos/etcd package: github.com/coreos/etcd
import: import:
- package: github.com/bgentry/speakeasy - package: github.com/bgentry/speakeasy
version: 36e9cfdd690967f4f690c6edcc9ffacd006014a0 version: 4aabc24848ce5fd31929f7d1e4ea74d3709c14cd
- package: github.com/boltdb/bolt - package: github.com/boltdb/bolt
version: v1.3.0 version: v1.3.0
- package: github.com/cockroachdb/cmux - package: github.com/cockroachdb/cmux
version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92 version: 112f0506e7743d64a6eb8fedbcff13d9979bbf92
- package: github.com/coreos/go-semver - package: github.com/coreos/go-semver
version: 568e959cd89871e61434c1143528d9162da89ef2 version: v0.2.0
subpackages: subpackages:
- semver - semver
- package: github.com/coreos/go-systemd - package: github.com/coreos/go-systemd
...@@ -23,11 +23,15 @@ import: ...@@ -23,11 +23,15 @@ import:
- package: github.com/dustin/go-humanize - package: github.com/dustin/go-humanize
version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0 version: 8929fe90cee4b2cb9deb468b51fb34eba64d1bf0
- package: github.com/ghodss/yaml - package: github.com/ghodss/yaml
version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee version: v1.0.0
- package: github.com/gogo/protobuf - package: github.com/gogo/protobuf
version: v0.3 version: v0.3
subpackages: subpackages:
- proto - proto
- package: github.com/golang/groupcache
version: 02826c3e79038b59d737d3b1c0a1d937f71a4433
subpackages:
- lru
- package: github.com/golang/protobuf - package: github.com/golang/protobuf
version: 4bd1920723d7b7c925de087aa32e2187708897f7 version: 4bd1920723d7b7c925de087aa32e2187708897f7
subpackages: subpackages:
...@@ -36,7 +40,7 @@ import: ...@@ -36,7 +40,7 @@ import:
- package: github.com/google/btree - package: github.com/google/btree
version: 925471ac9e2131377a91e1595defec898166fe49 version: 925471ac9e2131377a91e1595defec898166fe49
- package: github.com/grpc-ecosystem/grpc-gateway - package: github.com/grpc-ecosystem/grpc-gateway
version: 84398b94e188ee336f307779b57b3aa91af7063c version: v1.2.0
subpackages: subpackages:
- runtime - runtime
- runtime/internal - runtime/internal
...@@ -44,13 +48,21 @@ import: ...@@ -44,13 +48,21 @@ import:
- package: github.com/jonboulle/clockwork - package: github.com/jonboulle/clockwork
version: v0.1.0 version: v0.1.0
- package: github.com/kr/pty - package: github.com/kr/pty
version: f7ee69f31298ecbe5d2b349c711e2547a617d398 version: v1.0.0
- package: github.com/olekukonko/tablewriter - package: github.com/olekukonko/tablewriter
version: cca8bbc0798408af109aaaa239cbd2634846b340 version: a0225b3f23b5ce0cbec6d7a66a968f8a59eca9c4
- package: github.com/mattn/go-runewidth
version: v0.0.2
subpackages:
- runewidth.go
- package: github.com/prometheus/client_golang - package: github.com/prometheus/client_golang
version: v0.8.0 version: v0.8.0
subpackages: subpackages:
- prometheus - prometheus
- package: github.com/prometheus/common
version: 49fee292b27bfff7f354ee0f64e1bc4850462edf
- package: github.com/prometheus/procfs
version: a1dba9ce8baed984a2495b658c82687f8157b98f
- package: github.com/spf13/cobra - package: github.com/spf13/cobra
version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b version: 1c44ec8d3f1552cac48999f9306da23c4d8a288b
- package: github.com/spf13/pflag - package: github.com/spf13/pflag
...@@ -71,19 +83,21 @@ import: ...@@ -71,19 +83,21 @@ import:
- bcrypt - bcrypt
- blowfish - blowfish
- package: golang.org/x/net - package: golang.org/x/net
version: f2499483f923065a842d38eb4c7f1927e6fc6e6d version: c8c74377599bd978aee1cf3b9b63a8634051cec2
subpackages: subpackages:
- context - context
- http2 - http2
- http2/hpack - http2/hpack
- internal/timeseries - internal/timeseries
- trace - trace
- package: golang.org/x/sys
version: e48874b42435b4347fc52bdee0424a52abc974d7
- package: golang.org/x/time - package: golang.org/x/time
version: a4bde12657593d5e90d0533a3e4fd95e635124cb version: c06e80d9300e4443158a03817b8a8cb37d230320
subpackages: subpackages:
- rate - rate
- package: google.golang.org/grpc - package: google.golang.org/grpc
version: v1.0.4 version: v1.2.1
subpackages: subpackages:
- codes - codes
- credentials - credentials
...@@ -96,10 +110,6 @@ import: ...@@ -96,10 +110,6 @@ import:
- package: gopkg.in/cheggaaa/pb.v1 - package: gopkg.in/cheggaaa/pb.v1
version: v1.0.2 version: v1.0.2
- package: gopkg.in/yaml.v2 - package: gopkg.in/yaml.v2
version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
- package: github.com/stretchr/testify - package: github.com/dgrijalva/jwt-go
version: 976c720a22c8eb4eb6a0b4348ad85ad12491a506 version: v3.0.0
subpackages:
- assert
- package: github.com/karlseguin/ccache
version: v2.0.2
// Copyright 2016 Google Inc. All Rights Reserved. // Copyright 2017 The etcd Authors
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -12,53 +12,24 @@ ...@@ -12,53 +12,24 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package internal package main
import ( import (
"errors" "os"
"os/signal"
"strings"
"syscall"
"testing" "testing"
"time"
"golang.org/x/net/context"
gax "github.com/googleapis/gax-go"
) )
func TestRetry(t *testing.T) { func TestMain(t *testing.T) {
ctx := context.Background() // don't launch etcd server when invoked via go test
// Without a context deadline, retry will run until the function if strings.HasSuffix(os.Args[0], "etcd.test") {
// says not to retry any more. return
n := 0
endRetry := errors.New("end retry")
err := retry(ctx, gax.Backoff{},
func() (bool, error) {
n++
if n < 10 {
return false, nil
}
return true, endRetry
},
func(context.Context, time.Duration) error { return nil })
if got, want := err, endRetry; got != want {
t.Errorf("got %v, want %v", err, endRetry)
}
if n != 10 {
t.Errorf("n: got %d, want %d", n, 10)
} }
// If the context has a deadline, sleep will return an error notifier := make(chan os.Signal, 1)
// and end the function. signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)
n = 0 go main()
err = retry(ctx, gax.Backoff{}, <-notifier
func() (bool, error) { return false, nil },
func(context.Context, time.Duration) error {
n++
if n < 10 {
return nil
}
return context.DeadlineExceeded
})
if err == nil {
t.Error("got nil, want error")
}
} }
// Copyright 2015 The etcd Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Package srv looks up DNS SRV records.
package srv
import (
"fmt"
"net"
"net/url"
"strings"
"github.com/coreos/etcd/pkg/types"
)
var (
// indirection for testing
lookupSRV = net.LookupSRV // net.DefaultResolver.LookupSRV when ctxs don't conflict
resolveTCPAddr = net.ResolveTCPAddr
)
// GetCluster gets the cluster information via DNS discovery.
// Also sees each entry as a separate instance.
func GetCluster(service, name, dns string, apurls types.URLs) ([]string, error) {
tempName := int(0)
tcp2ap := make(map[string]url.URL)
// First, resolve the apurls
for _, url := range apurls {
tcpAddr, err := resolveTCPAddr("tcp", url.Host)
if err != nil {
return nil, err
}
tcp2ap[tcpAddr.String()] = url
}
stringParts := []string{}
updateNodeMap := func(service, scheme string) error {
_, addrs, err := lookupSRV(service, "tcp", dns)
if err != nil {
return err
}
for _, srv := range addrs {
port := fmt.Sprintf("%d", srv.Port)
host := net.JoinHostPort(srv.Target, port)
tcpAddr, terr := resolveTCPAddr("tcp", host)
if terr != nil {
err = terr
continue
}
n := ""
url, ok := tcp2ap[tcpAddr.String()]
if ok {
n = name
}
if n == "" {
n = fmt.Sprintf("%d", tempName)
tempName++
}
// SRV records have a trailing dot but URL shouldn't.
shortHost := strings.TrimSuffix(srv.Target, ".")
urlHost := net.JoinHostPort(shortHost, port)
stringParts = append(stringParts, fmt.Sprintf("%s=%s://%s", n, scheme, urlHost))
if ok && url.Scheme != scheme {
err = fmt.Errorf("bootstrap at %s from DNS for %s has scheme mismatch with expected peer %s", scheme+"://"+urlHost, service, url.String())
}
}
if len(stringParts) == 0 {
return err
}
return nil
}
failCount := 0
err := updateNodeMap(service+"-ssl", "https")
srvErr := make([]string, 2)
if err != nil {
srvErr[0] = fmt.Sprintf("error querying DNS SRV records for _%s-ssl %s", service, err)
failCount++
}
err = updateNodeMap(service, "http")
if err != nil {
srvErr[1] = fmt.Sprintf("error querying DNS SRV records for _%s %s", service, err)
failCount++
}
if failCount == 2 {
return nil, fmt.Errorf("srv: too many errors querying DNS SRV records (%q, %q)", srvErr[0], srvErr[1])
}
return stringParts, nil
}
type SRVClients struct {
Endpoints []string
SRVs []*net.SRV
}
// GetClient looks up the client endpoints for a service and domain.
func GetClient(service, domain string) (*SRVClients, error) {
var urls []*url.URL
var srvs []*net.SRV
updateURLs := func(service, scheme string) error {
_, addrs, err := lookupSRV(service, "tcp", domain)
if err != nil {
return err
}
for _, srv := range addrs {
urls = append(urls, &url.URL{
Scheme: scheme,
Host: net.JoinHostPort(srv.Target, fmt.Sprintf("%d", srv.Port)),
})
}
srvs = append(srvs, addrs...)
return nil
}
errHTTPS := updateURLs(service+"-ssl", "https")
errHTTP := updateURLs(service, "http")
if errHTTPS != nil && errHTTP != nil {
return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP)
}
endpoints := make([]string, len(urls))
for i := range urls {
endpoints[i] = urls[i].String()
}
return &SRVClients{Endpoints: endpoints, SRVs: srvs}, nil
}
...@@ -12,15 +12,115 @@ ...@@ -12,15 +12,115 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package client package srv
import ( import (
"errors" "errors"
"net" "net"
"reflect" "reflect"
"strings"
"testing" "testing"
"github.com/coreos/etcd/pkg/testutil"
) )
func TestSRVGetCluster(t *testing.T) {
defer func() {
lookupSRV = net.LookupSRV
resolveTCPAddr = net.ResolveTCPAddr
}()
name := "dnsClusterTest"
dns := map[string]string{
"1.example.com.:2480": "10.0.0.1:2480",
"2.example.com.:2480": "10.0.0.2:2480",
"3.example.com.:2480": "10.0.0.3:2480",
"4.example.com.:2380": "10.0.0.3:2380",
}
srvAll := []*net.SRV{
{Target: "1.example.com.", Port: 2480},
{Target: "2.example.com.", Port: 2480},
{Target: "3.example.com.", Port: 2480},
}
tests := []struct {
withSSL []*net.SRV
withoutSSL []*net.SRV
urls []string
expected string
}{
{
[]*net.SRV{},
[]*net.SRV{},
nil,
"",
},
{
srvAll,
[]*net.SRV{},
nil,
"0=https://1.example.com:2480,1=https://2.example.com:2480,2=https://3.example.com:2480",
},
{
srvAll,
[]*net.SRV{{Target: "4.example.com.", Port: 2380}},
nil,
"0=https://1.example.com:2480,1=https://2.example.com:2480,2=https://3.example.com:2480,3=http://4.example.com:2380",
},
{
srvAll,
[]*net.SRV{{Target: "4.example.com.", Port: 2380}},
[]string{"https://10.0.0.1:2480"},
"dnsClusterTest=https://1.example.com:2480,0=https://2.example.com:2480,1=https://3.example.com:2480,2=http://4.example.com:2380",
},
// matching local member with resolved addr and return unresolved hostnames
{
srvAll,
nil,
[]string{"https://10.0.0.1:2480"},
"dnsClusterTest=https://1.example.com:2480,0=https://2.example.com:2480,1=https://3.example.com:2480",
},
// invalid
}
resolveTCPAddr = func(network, addr string) (*net.TCPAddr, error) {
if strings.Contains(addr, "10.0.0.") {
// accept IP addresses when resolving apurls
return net.ResolveTCPAddr(network, addr)
}
if dns[addr] == "" {
return nil, errors.New("missing dns record")
}
return net.ResolveTCPAddr(network, dns[addr])
}
for i, tt := range tests {
lookupSRV = func(service string, proto string, domain string) (string, []*net.SRV, error) {
if service == "etcd-server-ssl" {
return "", tt.withSSL, nil
}
if service == "etcd-server" {
return "", tt.withoutSSL, nil
}
return "", nil, errors.New("Unknown service in mock")
}
urls := testutil.MustNewURLs(t, tt.urls)
str, err := GetCluster("etcd-server", name, "example.com", urls)
if err != nil {
t.Fatalf("%d: err: %#v", i, err)
}
if strings.Join(str, ",") != tt.expected {
t.Errorf("#%d: cluster = %s, want %s", i, str, tt.expected)
}
}
}
func TestSRVDiscover(t *testing.T) { func TestSRVDiscover(t *testing.T) {
defer func() { lookupSRV = net.LookupSRV }() defer func() { lookupSRV = net.LookupSRV }()
...@@ -87,15 +187,13 @@ func TestSRVDiscover(t *testing.T) { ...@@ -87,15 +187,13 @@ func TestSRVDiscover(t *testing.T) {
return "", nil, errors.New("Unknown service in mock") return "", nil, errors.New("Unknown service in mock")
} }
d := NewSRVDiscover() srvs, err := GetClient("etcd-client", "example.com")
endpoints, err := d.Discover("example.com")
if err != nil { if err != nil {
t.Fatalf("%d: err: %#v", i, err) t.Fatalf("%d: err: %#v", i, err)
} }
if !reflect.DeepEqual(endpoints, tt.expected) { if !reflect.DeepEqual(srvs.Endpoints, tt.expected) {
t.Errorf("#%d: endpoints = %v, want %v", i, endpoints, tt.expected) t.Errorf("#%d: endpoints = %v, want %v", i, srvs.Endpoints, tt.expected)
} }
} }
......
This diff is collapsed.
...@@ -12,54 +12,45 @@ ...@@ -12,54 +12,45 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package client // Package version implements etcd version parsing and contains latest version
// information.
package version
import ( import (
"fmt" "fmt"
"net" "strings"
"net/url"
)
var ( "github.com/coreos/go-semver/semver"
// indirection for testing
lookupSRV = net.LookupSRV
) )
type srvDiscover struct{} var (
// MinClusterVersion is the min cluster version this etcd binary is compatible with.
// NewSRVDiscover constructs a new Discoverer that uses the stdlib to lookup SRV records. MinClusterVersion = "3.0.0"
func NewSRVDiscover() Discoverer { Version = "3.2.6"
return &srvDiscover{} APIVersion = "unknown"
}
// Discover looks up the etcd servers for the domain. // Git SHA Value will be set during build
func (d *srvDiscover) Discover(domain string) ([]string, error) { GitSHA = "Not provided (use ./build instead of go build)"
var urls []*url.URL )
updateURLs := func(service, scheme string) error { func init() {
_, addrs, err := lookupSRV(service, "tcp", domain) ver, err := semver.NewVersion(Version)
if err != nil { if err == nil {
return err APIVersion = fmt.Sprintf("%d.%d", ver.Major, ver.Minor)
}
for _, srv := range addrs {
urls = append(urls, &url.URL{
Scheme: scheme,
Host: net.JoinHostPort(srv.Target, fmt.Sprintf("%d", srv.Port)),
})
}
return nil
} }
}
errHTTPS := updateURLs("etcd-client-ssl", "https") type Versions struct {
errHTTP := updateURLs("etcd-client", "http") Server string `json:"etcdserver"`
Cluster string `json:"etcdcluster"`
if errHTTPS != nil && errHTTP != nil { // TODO: raft state machine version
return nil, fmt.Errorf("dns lookup errors: %s and %s", errHTTPS, errHTTP) }
}
endpoints := make([]string, len(urls)) // Cluster only keeps the major.minor.
for i := range urls { func Cluster(v string) string {
endpoints[i] = urls[i].String() vs := strings.Split(v, ".")
if len(vs) <= 2 {
return v
} }
return endpoints, nil return fmt.Sprintf("%s.%s", vs[0], vs[1])
} }
...@@ -91,7 +91,12 @@ func expires(date, expires string) (time.Duration, bool, error) { ...@@ -91,7 +91,12 @@ func expires(date, expires string) (time.Duration, bool, error) {
return 0, false, nil return 0, false, nil
} }
te, err := time.Parse(time.RFC1123, expires) var te time.Time
var err error
if expires == "0" {
return 0, false, nil
}
te, err = time.Parse(time.RFC1123, expires)
if err != nil { if err != nil {
return 0, false, err return 0, false, err
} }
......
...@@ -177,6 +177,13 @@ func TestExpiresPass(t *testing.T) { ...@@ -177,6 +177,13 @@ func TestExpiresPass(t *testing.T) {
wantTTL: 0, wantTTL: 0,
wantOK: false, wantOK: false,
}, },
// Expires set to false
{
date: "Thu, 01 Dec 1983 22:00:00 GMT",
exp: "0",
wantTTL: 0,
wantOK: false,
},
// Expires < Date // Expires < Date
{ {
date: "Fri, 02 Dec 1983 01:00:00 GMT", date: "Fri, 02 Dec 1983 01:00:00 GMT",
......
...@@ -2,7 +2,6 @@ package oidc ...@@ -2,7 +2,6 @@ package oidc
import ( import (
"context" "context"
"encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
...@@ -182,14 +181,16 @@ func (r *remoteKeySet) updateKeys() ([]jose.JSONWebKey, time.Time, error) { ...@@ -182,14 +181,16 @@ func (r *remoteKeySet) updateKeys() ([]jose.JSONWebKey, time.Time, error) {
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("oidc: read response body: %v", err) return nil, time.Time{}, fmt.Errorf("unable to read response body: %v", err)
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return nil, time.Time{}, fmt.Errorf("oidc: get keys failed: %s %s", resp.Status, body) return nil, time.Time{}, fmt.Errorf("oidc: get keys failed: %s %s", resp.Status, body)
} }
var keySet jose.JSONWebKeySet var keySet jose.JSONWebKeySet
if err := json.Unmarshal(body, &keySet); err != nil { err = unmarshalResp(resp, body, &keySet)
if err != nil {
return nil, time.Time{}, fmt.Errorf("oidc: failed to decode keys: %v %s", err, body) return nil, time.Time{}, fmt.Errorf("oidc: failed to decode keys: %v %s", err, body)
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"mime"
"net/http" "net/http"
"strings" "strings"
"time" "time"
...@@ -93,18 +94,23 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) { ...@@ -93,18 +94,23 @@ func NewProvider(ctx context.Context, issuer string) (*Provider, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, fmt.Errorf("unable to read response body: %v", err)
} }
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%s: %s", resp.Status, body) return nil, fmt.Errorf("%s: %s", resp.Status, body)
} }
defer resp.Body.Close()
var p providerJSON var p providerJSON
if err := json.Unmarshal(body, &p); err != nil { err = unmarshalResp(resp, body, &p)
if err != nil {
return nil, fmt.Errorf("oidc: failed to decode provider discovery object: %v", err) return nil, fmt.Errorf("oidc: failed to decode provider discovery object: %v", err)
} }
if p.Issuer != issuer { if p.Issuer != issuer {
return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer) return nil, fmt.Errorf("oidc: issuer did not match the issuer returned by provider, expected %q got %q", issuer, p.Issuer)
} }
...@@ -307,3 +313,16 @@ func (j *jsonTime) UnmarshalJSON(b []byte) error { ...@@ -307,3 +313,16 @@ func (j *jsonTime) UnmarshalJSON(b []byte) error {
*j = jsonTime(time.Unix(unix, 0)) *j = jsonTime(time.Unix(unix, 0))
return nil return nil
} }
func unmarshalResp(r *http.Response, body []byte, v interface{}) error {
err := json.Unmarshal(body, &v)
if err == nil {
return nil
}
ct := r.Header.Get("Content-Type")
mediaType, _, parseErr := mime.ParseMediaType(ct)
if parseErr == nil && mediaType == "application/json" {
return fmt.Errorf("got Content-Type = application/json, but could not unmarshal as JSON: %v", err)
}
return fmt.Errorf("expected Content-Type = application/json, got %q: %v", ct, err)
}
...@@ -473,8 +473,9 @@ func (g *fakeProviderConfigGetterSetter) Set(cfg ProviderConfig) error { ...@@ -473,8 +473,9 @@ func (g *fakeProviderConfigGetterSetter) Set(cfg ProviderConfig) error {
} }
type fakeProviderConfigHandler struct { type fakeProviderConfigHandler struct {
cfg ProviderConfig cfg ProviderConfig
maxAge time.Duration maxAge time.Duration
noExpires bool
} }
func (s *fakeProviderConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (s *fakeProviderConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...@@ -482,6 +483,9 @@ func (s *fakeProviderConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Req ...@@ -482,6 +483,9 @@ func (s *fakeProviderConfigHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
if s.maxAge.Seconds() >= 0 { if s.maxAge.Seconds() >= 0 {
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(s.maxAge.Seconds()))) w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d", int(s.maxAge.Seconds())))
} }
if s.noExpires {
w.Header().Set("Expires", "0")
}
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
w.Write(b) w.Write(b)
} }
...@@ -552,10 +556,11 @@ func TestHTTPProviderConfigGetter(t *testing.T) { ...@@ -552,10 +556,11 @@ func TestHTTPProviderConfigGetter(t *testing.T) {
now := fc.Now().UTC() now := fc.Now().UTC()
tests := []struct { tests := []struct {
dsc string dsc string
age time.Duration age time.Duration
cfg ProviderConfig cfg ProviderConfig
ok bool noExpires bool
ok bool
}{ }{
// everything is good // everything is good
{ {
...@@ -596,6 +601,17 @@ func TestHTTPProviderConfigGetter(t *testing.T) { ...@@ -596,6 +601,17 @@ func TestHTTPProviderConfigGetter(t *testing.T) {
}, },
ok: true, ok: true,
}, },
// An expires header set to 0
{
dsc: "https://example.com",
age: time.Minute,
cfg: ProviderConfig{
Issuer: &url.URL{Scheme: "https", Host: "example.com"},
ExpiresAt: now.Add(time.Minute),
},
ok: true,
noExpires: true,
},
} }
for i, tt := range tests { for i, tt := range tests {
......
language: go
sudo: false
go:
- 1.4
- 1.5
- 1.6
- tip
script: cd semver && go test
This diff is collapsed.
# go-semver - Semantic Versioning Library
[![Build Status](https://travis-ci.org/coreos/go-semver.svg?branch=master)](https://travis-ci.org/coreos/go-semver)
[![GoDoc](https://godoc.org/github.com/coreos/go-semver/semver?status.svg)](https://godoc.org/github.com/coreos/go-semver/semver)
go-semver is a [semantic versioning][semver] library for Go. It lets you parse
and compare two semantic version strings.
[semver]: http://semver.org/
## Usage
```go
vA := semver.New("1.2.3")
vB := semver.New("3.2.1")
fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
```
## Example Application
```
$ go run example.go 1.2.3 3.2.1
1.2.3 < 3.2.1 == true
$ go run example.go 5.2.3 3.2.1
5.2.3 < 3.2.1 == false
```
package main
import (
"fmt"
"github.com/coreos/go-semver/semver"
"os"
)
func main() {
vA, err := semver.NewVersion(os.Args[1])
if err != nil {
fmt.Println(err.Error())
}
vB, err := semver.NewVersion(os.Args[2])
if err != nil {
fmt.Println(err.Error())
}
fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
}
// Copyright 2013-2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Semantic Versions http://semver.org
package semver
import (
"bytes"
"errors"
"fmt"
"strconv"
"strings"
)
type Version struct {
Major int64
Minor int64
Patch int64
PreRelease PreRelease
Metadata string
}
type PreRelease string
func splitOff(input *string, delim string) (val string) {
parts := strings.SplitN(*input, delim, 2)
if len(parts) == 2 {
*input = parts[0]
val = parts[1]
}
return val
}
func New(version string) *Version {
return Must(NewVersion(version))
}
func NewVersion(version string) (*Version, error) {
v := Version{}
if err := v.Set(version); err != nil {
return nil, err
}
return &v, nil
}
// Must is a helper for wrapping NewVersion and will panic if err is not nil.
func Must(v *Version, err error) *Version {
if err != nil {
panic(err)
}
return v
}
// Set parses and updates v from the given version string. Implements flag.Value
func (v *Version) Set(version string) error {
metadata := splitOff(&version, "+")
preRelease := PreRelease(splitOff(&version, "-"))
dotParts := strings.SplitN(version, ".", 3)
if len(dotParts) != 3 {
return fmt.Errorf("%s is not in dotted-tri format", version)
}
parsed := make([]int64, 3, 3)
for i, v := range dotParts[:3] {
val, err := strconv.ParseInt(v, 10, 64)
parsed[i] = val
if err != nil {
return err
}
}
v.Metadata = metadata
v.PreRelease = preRelease
v.Major = parsed[0]
v.Minor = parsed[1]
v.Patch = parsed[2]
return nil
}
func (v Version) String() string {
var buffer bytes.Buffer
fmt.Fprintf(&buffer, "%d.%d.%d", v.Major, v.Minor, v.Patch)
if v.PreRelease != "" {
fmt.Fprintf(&buffer, "-%s", v.PreRelease)
}
if v.Metadata != "" {
fmt.Fprintf(&buffer, "+%s", v.Metadata)
}
return buffer.String()
}
func (v *Version) UnmarshalYAML(unmarshal func(interface{}) error) error {
var data string
if err := unmarshal(&data); err != nil {
return err
}
return v.Set(data)
}
func (v Version) MarshalJSON() ([]byte, error) {
return []byte(`"` + v.String() + `"`), nil
}
func (v *Version) UnmarshalJSON(data []byte) error {
l := len(data)
if l == 0 || string(data) == `""` {
return nil
}
if l < 2 || data[0] != '"' || data[l-1] != '"' {
return errors.New("invalid semver string")
}
return v.Set(string(data[1 : l-1]))
}
// Compare tests if v is less than, equal to, or greater than versionB,
// returning -1, 0, or +1 respectively.
func (v Version) Compare(versionB Version) int {
if cmp := recursiveCompare(v.Slice(), versionB.Slice()); cmp != 0 {
return cmp
}
return preReleaseCompare(v, versionB)
}
// Equal tests if v is equal to versionB.
func (v Version) Equal(versionB Version) bool {
return v.Compare(versionB) == 0
}
// LessThan tests if v is less than versionB.
func (v Version) LessThan(versionB Version) bool {
return v.Compare(versionB) < 0
}
// Slice converts the comparable parts of the semver into a slice of integers.
func (v Version) Slice() []int64 {
return []int64{v.Major, v.Minor, v.Patch}
}
func (p PreRelease) Slice() []string {
preRelease := string(p)
return strings.Split(preRelease, ".")
}
func preReleaseCompare(versionA Version, versionB Version) int {
a := versionA.PreRelease
b := versionB.PreRelease
/* Handle the case where if two versions are otherwise equal it is the
* one without a PreRelease that is greater */
if len(a) == 0 && (len(b) > 0) {
return 1
} else if len(b) == 0 && (len(a) > 0) {
return -1
}
// If there is a prerelease, check and compare each part.
return recursivePreReleaseCompare(a.Slice(), b.Slice())
}
func recursiveCompare(versionA []int64, versionB []int64) int {
if len(versionA) == 0 {
return 0
}
a := versionA[0]
b := versionB[0]
if a > b {
return 1
} else if a < b {
return -1
}
return recursiveCompare(versionA[1:], versionB[1:])
}
func recursivePreReleaseCompare(versionA []string, versionB []string) int {
// A larger set of pre-release fields has a higher precedence than a smaller set,
// if all of the preceding identifiers are equal.
if len(versionA) == 0 {
if len(versionB) > 0 {
return -1
}
return 0
} else if len(versionB) == 0 {
// We're longer than versionB so return 1.
return 1
}
a := versionA[0]
b := versionB[0]
aInt := false
bInt := false
aI, err := strconv.Atoi(versionA[0])
if err == nil {
aInt = true
}
bI, err := strconv.Atoi(versionB[0])
if err == nil {
bInt = true
}
// Handle Integer Comparison
if aInt && bInt {
if aI > bI {
return 1
} else if aI < bI {
return -1
}
}
// Handle String Comparison
if a > b {
return 1
} else if a < b {
return -1
}
return recursivePreReleaseCompare(versionA[1:], versionB[1:])
}
// BumpMajor increments the Major field by 1 and resets all other fields to their default values
func (v *Version) BumpMajor() {
v.Major += 1
v.Minor = 0
v.Patch = 0
v.PreRelease = PreRelease("")
v.Metadata = ""
}
// BumpMinor increments the Minor field by 1 and resets all other fields to their default values
func (v *Version) BumpMinor() {
v.Minor += 1
v.Patch = 0
v.PreRelease = PreRelease("")
v.Metadata = ""
}
// BumpPatch increments the Patch field by 1 and resets all other fields to their default values
func (v *Version) BumpPatch() {
v.Patch += 1
v.PreRelease = PreRelease("")
v.Metadata = ""
}
// Copyright 2013-2015 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package semver
import (
"bytes"
"encoding/json"
"errors"
"flag"
"fmt"
"math/rand"
"reflect"
"testing"
"time"
"gopkg.in/yaml.v2"
)
type fixture struct {
GreaterVersion string
LesserVersion string
}
var fixtures = []fixture{
fixture{"0.0.0", "0.0.0-foo"},
fixture{"0.0.1", "0.0.0"},
fixture{"1.0.0", "0.9.9"},
fixture{"0.10.0", "0.9.0"},
fixture{"0.99.0", "0.10.0"},
fixture{"2.0.0", "1.2.3"},
fixture{"0.0.0", "0.0.0-foo"},
fixture{"0.0.1", "0.0.0"},
fixture{"1.0.0", "0.9.9"},
fixture{"0.10.0", "0.9.0"},
fixture{"0.99.0", "0.10.0"},
fixture{"2.0.0", "1.2.3"},
fixture{"0.0.0", "0.0.0-foo"},
fixture{"0.0.1", "0.0.0"},
fixture{"1.0.0", "0.9.9"},
fixture{"0.10.0", "0.9.0"},
fixture{"0.99.0", "0.10.0"},
fixture{"2.0.0", "1.2.3"},
fixture{"1.2.3", "1.2.3-asdf"},
fixture{"1.2.3", "1.2.3-4"},
fixture{"1.2.3", "1.2.3-4-foo"},
fixture{"1.2.3-5-foo", "1.2.3-5"},
fixture{"1.2.3-5", "1.2.3-4"},
fixture{"1.2.3-5-foo", "1.2.3-5-Foo"},
fixture{"3.0.0", "2.7.2+asdf"},
fixture{"3.0.0+foobar", "2.7.2"},
fixture{"1.2.3-a.10", "1.2.3-a.5"},
fixture{"1.2.3-a.b", "1.2.3-a.5"},
fixture{"1.2.3-a.b", "1.2.3-a"},
fixture{"1.2.3-a.b.c.10.d.5", "1.2.3-a.b.c.5.d.100"},
fixture{"1.0.0", "1.0.0-rc.1"},
fixture{"1.0.0-rc.2", "1.0.0-rc.1"},
fixture{"1.0.0-rc.1", "1.0.0-beta.11"},
fixture{"1.0.0-beta.11", "1.0.0-beta.2"},
fixture{"1.0.0-beta.2", "1.0.0-beta"},
fixture{"1.0.0-beta", "1.0.0-alpha.beta"},
fixture{"1.0.0-alpha.beta", "1.0.0-alpha.1"},
fixture{"1.0.0-alpha.1", "1.0.0-alpha"},
}
func TestCompare(t *testing.T) {
for _, v := range fixtures {
gt, err := NewVersion(v.GreaterVersion)
if err != nil {
t.Error(err)
}
lt, err := NewVersion(v.LesserVersion)
if err != nil {
t.Error(err)
}
if gt.LessThan(*lt) {
t.Errorf("%s should not be less than %s", gt, lt)
}
if gt.Equal(*lt) {
t.Errorf("%s should not be equal to %s", gt, lt)
}
if gt.Compare(*lt) <= 0 {
t.Errorf("%s should be greater than %s", gt, lt)
}
if !lt.LessThan(*gt) {
t.Errorf("%s should be less than %s", lt, gt)
}
if !lt.Equal(*lt) {
t.Errorf("%s should be equal to %s", lt, lt)
}
if lt.Compare(*gt) > 0 {
t.Errorf("%s should not be greater than %s", lt, gt)
}
}
}
func testString(t *testing.T, orig string, version *Version) {
if orig != version.String() {
t.Errorf("%s != %s", orig, version)
}
}
func TestString(t *testing.T) {
for _, v := range fixtures {
gt, err := NewVersion(v.GreaterVersion)
if err != nil {
t.Error(err)
}
testString(t, v.GreaterVersion, gt)
lt, err := NewVersion(v.LesserVersion)
if err != nil {
t.Error(err)
}
testString(t, v.LesserVersion, lt)
}
}
func shuffleStringSlice(src []string) []string {
dest := make([]string, len(src))
rand.Seed(time.Now().Unix())
perm := rand.Perm(len(src))
for i, v := range perm {
dest[v] = src[i]
}
return dest
}
func TestSort(t *testing.T) {
sortedVersions := []string{"1.0.0", "1.0.2", "1.2.0", "3.1.1"}
unsortedVersions := shuffleStringSlice(sortedVersions)
semvers := []*Version{}
for _, v := range unsortedVersions {
sv, err := NewVersion(v)
if err != nil {
t.Fatal(err)
}
semvers = append(semvers, sv)
}
Sort(semvers)
for idx, sv := range semvers {
if sv.String() != sortedVersions[idx] {
t.Fatalf("incorrect sort at index %v", idx)
}
}
}
func TestBumpMajor(t *testing.T) {
version, _ := NewVersion("1.0.0")
version.BumpMajor()
if version.Major != 2 {
t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
}
version, _ = NewVersion("1.5.2")
version.BumpMajor()
if version.Minor != 0 && version.Patch != 0 {
t.Fatalf("bumping major on 1.5.2 resulted in %v", version)
}
version, _ = NewVersion("1.0.0+build.1-alpha.1")
version.BumpMajor()
if version.PreRelease != "" && version.PreRelease != "" {
t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
}
}
func TestBumpMinor(t *testing.T) {
version, _ := NewVersion("1.0.0")
version.BumpMinor()
if version.Major != 1 {
t.Fatalf("bumping minor on 1.0.0 resulted in %v", version)
}
if version.Minor != 1 {
t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
}
version, _ = NewVersion("1.0.0+build.1-alpha.1")
version.BumpMinor()
if version.PreRelease != "" && version.PreRelease != "" {
t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
}
}
func TestBumpPatch(t *testing.T) {
version, _ := NewVersion("1.0.0")
version.BumpPatch()
if version.Major != 1 {
t.Fatalf("bumping minor on 1.0.0 resulted in %v", version)
}
if version.Minor != 0 {
t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
}
if version.Patch != 1 {
t.Fatalf("bumping major on 1.0.0 resulted in %v", version)
}
version, _ = NewVersion("1.0.0+build.1-alpha.1")
version.BumpPatch()
if version.PreRelease != "" && version.PreRelease != "" {
t.Fatalf("bumping major on 1.0.0+build.1-alpha.1 resulted in %v", version)
}
}
func TestMust(t *testing.T) {
tests := []struct {
versionStr string
version *Version
recov interface{}
}{
{
versionStr: "1.0.0",
version: &Version{Major: 1},
},
{
versionStr: "version number",
recov: errors.New("version number is not in dotted-tri format"),
},
}
for _, tt := range tests {
func() {
defer func() {
recov := recover()
if !reflect.DeepEqual(tt.recov, recov) {
t.Fatalf("incorrect panic for %q: want %v, got %v", tt.versionStr, tt.recov, recov)
}
}()
version := Must(NewVersion(tt.versionStr))
if !reflect.DeepEqual(tt.version, version) {
t.Fatalf("incorrect version for %q: want %+v, got %+v", tt.versionStr, tt.version, version)
}
}()
}
}
type fixtureJSON struct {
GreaterVersion *Version
LesserVersion *Version
}
func TestJSON(t *testing.T) {
fj := make([]fixtureJSON, len(fixtures))
for i, v := range fixtures {
var err error
fj[i].GreaterVersion, err = NewVersion(v.GreaterVersion)
if err != nil {
t.Fatal(err)
}
fj[i].LesserVersion, err = NewVersion(v.LesserVersion)
if err != nil {
t.Fatal(err)
}
}
fromStrings, err := json.Marshal(fixtures)
if err != nil {
t.Fatal(err)
}
fromVersions, err := json.Marshal(fj)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(fromStrings, fromVersions) {
t.Errorf("Expected: %s", fromStrings)
t.Errorf("Unexpected: %s", fromVersions)
}
fromJson := make([]fixtureJSON, 0, len(fj))
err = json.Unmarshal(fromStrings, &fromJson)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(fromJson, fj) {
t.Error("Expected: ", fj)
t.Error("Unexpected: ", fromJson)
}
}
func TestYAML(t *testing.T) {
document, err := yaml.Marshal(fixtures)
if err != nil {
t.Fatal(err)
}
expected := make([]fixtureJSON, len(fixtures))
for i, v := range fixtures {
var err error
expected[i].GreaterVersion, err = NewVersion(v.GreaterVersion)
if err != nil {
t.Fatal(err)
}
expected[i].LesserVersion, err = NewVersion(v.LesserVersion)
if err != nil {
t.Fatal(err)
}
}
fromYAML := make([]fixtureJSON, 0, len(fixtures))
err = yaml.Unmarshal(document, &fromYAML)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(fromYAML, expected) {
t.Error("Expected: ", expected)
t.Error("Unexpected: ", fromYAML)
}
}
func TestBadInput(t *testing.T) {
bad := []string{
"1.2",
"1.2.3x",
"0x1.3.4",
"-1.2.3",
"1.2.3.4",
}
for _, b := range bad {
if _, err := NewVersion(b); err == nil {
t.Error("Improperly accepted value: ", b)
}
}
}
func TestFlag(t *testing.T) {
v := Version{}
f := flag.NewFlagSet("version", flag.ContinueOnError)
f.Var(&v, "version", "set version")
if err := f.Set("version", "1.2.3"); err != nil {
t.Fatal(err)
}
if v.String() != "1.2.3" {
t.Errorf("Set wrong value %q", v)
}
}
func ExampleVersion_LessThan() {
vA := New("1.2.3")
vB := New("3.2.1")
fmt.Printf("%s < %s == %t\n", vA, vB, vA.LessThan(*vB))
// Output:
// 1.2.3 < 3.2.1 == true
}
// Copyright 2016 Google Inc. All Rights Reserved. // Copyright 2013-2015 CoreOS, Inc.
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
...@@ -12,44 +12,27 @@ ...@@ -12,44 +12,27 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package internal package semver
import ( import (
"fmt" "sort"
"time" )
gax "github.com/googleapis/gax-go" type Versions []*Version
"golang.org/x/net/context" func (s Versions) Len() int {
) return len(s)
}
func (s Versions) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
// Retry calls the supplied function f repeatedly according to the provided func (s Versions) Less(i, j int) bool {
// backoff parameters. It returns when one of the following occurs: return s[i].LessThan(*s[j])
// When f's first return value is true, Retry immediately returns with f's second
// return value.
// When the provided context is done, Retry returns with ctx.Err().
func Retry(ctx context.Context, bo gax.Backoff, f func() (stop bool, err error)) error {
return retry(ctx, bo, f, gax.Sleep)
} }
func retry(ctx context.Context, bo gax.Backoff, f func() (stop bool, err error), // Sort sorts the given slice of Version
sleep func(context.Context, time.Duration) error) error { func Sort(versions []*Version) {
var lastErr error sort.Sort(Versions(versions))
for {
stop, err := f()
if stop {
return err
}
// Remember the last "real" error from f.
if err != nil && err != context.Canceled && err != context.DeadlineExceeded {
lastErr = err
}
p := bo.Pause()
if cerr := sleep(ctx, p); cerr != nil {
if lastErr != nil {
return fmt.Errorf("%v; last function err: %v", cerr, lastErr)
}
return cerr
}
}
} }
.deps/
.dirstamp
.libs/
*.pb-c.c
*.pb-c.h
*.pb.cc
*.pb.h
*.pb.go
*_pb2.py
*_pb2.pyc
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
dnstap: flexible, structured event replication format for DNS software
----------------------------------------------------------------------
This directory contains only the protobuf schemas for dnstap, and is the root of
a repository named "dnstap.pb".
/*
* Copyright (c) 2013-2014 by Farsight Security, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"runtime"
"syscall"
"github.com/dnstap/golang-dnstap"
)
var (
flagReadFile = flag.String("r", "", "read dnstap payloads from file")
flagReadSock = flag.String("u", "", "read dnstap payloads from unix socket")
flagWriteFile = flag.String("w", "-", "write output to file")
flagQuietText = flag.Bool("q", false, "use quiet text output")
flagYamlText = flag.Bool("y", false, "use verbose YAML output")
)
func usage() {
fmt.Fprintf(os.Stderr, "Usage: %s [OPTION]...\n", os.Args[0])
flag.PrintDefaults()
fmt.Fprintf(os.Stderr, `
Quiet text output format mnemonics:
AQ: AUTH_QUERY
AR: AUTH_RESPONSE
RQ: RESOLVER_QUERY
RR: RESOLVER_RESPONSE
CQ: CLIENT_QUERY
CR: CLIENT_RESPONSE
FQ: FORWARDER_QUERY
FR: FORWARDER_RESPONSE
SQ: STUB_QUERY
SR: STUB_RESPONSE
TQ: TOOL_QUERY
TR: TOOL_RESPONSE
`)
}
func outputOpener(fname string, text, yaml bool) func() dnstap.Output {
return func() dnstap.Output {
var o dnstap.Output
var err error
if text {
o, err = dnstap.NewTextOutputFromFilename(fname, dnstap.TextFormat)
} else if yaml {
o, err = dnstap.NewTextOutputFromFilename(fname, dnstap.YamlFormat)
} else {
o, err = dnstap.NewFrameStreamOutputFromFilename(fname)
}
if err != nil {
fmt.Fprintf(os.Stderr, "dnstap: Failed to open output file: %s\n", err)
os.Exit(1)
}
go o.RunOutputLoop()
return o
}
}
func outputLoop(opener func() dnstap.Output, data <-chan []byte, done chan<- struct{}) {
sigch := make(chan os.Signal, 1)
signal.Notify(sigch, os.Interrupt, syscall.SIGHUP)
o := opener()
defer func() {
o.Close()
close(done)
os.Exit(0)
}()
for {
select {
case b, ok := <-data:
if !ok {
return
}
o.GetOutputChannel() <- b
case sig := <-sigch:
if sig == syscall.SIGHUP {
o.Close()
o = opener()
continue
}
return
}
}
}
func main() {
var err error
var i dnstap.Input
runtime.GOMAXPROCS(runtime.NumCPU())
log.SetFlags(0)
flag.Usage = usage
// Handle command-line arguments.
flag.Parse()
if *flagReadFile == "" && *flagReadSock == "" {
fmt.Fprintf(os.Stderr, "dnstap: Error: no inputs specified.\n")
os.Exit(1)
}
if *flagWriteFile == "-" {
if *flagQuietText == false && *flagYamlText == false {
*flagQuietText = true
}
}
if *flagReadFile != "" && *flagReadSock != "" {
fmt.Fprintf(os.Stderr, "dnstap: Error: specify exactly one of -r or -u.\n")
os.Exit(1)
}
// Start the output loop.
output := make(chan []byte, 1)
opener := outputOpener(*flagWriteFile, *flagQuietText, *flagYamlText)
outDone := make(chan struct{})
go outputLoop(opener, output, outDone)
// Open the input and start the input loop.
if *flagReadFile != "" {
i, err = dnstap.NewFrameStreamInputFromFilename(*flagReadFile)
if err != nil {
fmt.Fprintf(os.Stderr, "dnstap: Failed to open input file: %s\n", err)
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "dnstap: opened input file %s\n", *flagReadFile)
} else if *flagReadSock != "" {
i, err = dnstap.NewFrameStreamSockInputFromPath(*flagReadSock)
if err != nil {
fmt.Fprintf(os.Stderr, "dnstap: Failed to open input socket: %s\n", err)
os.Exit(1)
}
fmt.Fprintf(os.Stderr, "dnstap: opened input socket %s\n", *flagReadSock)
}
i.ReadInto(output)
// Wait for input loop to finish.
i.Wait()
close(output)
<-outDone
}
...@@ -16,3 +16,4 @@ davidli <wenquan.li@hp.com> davidli <wenquan.li@hpe.com> ...@@ -16,3 +16,4 @@ davidli <wenquan.li@hp.com> davidli <wenquan.li@hpe.com>
Omer Cohen <git@omer.io> Omer Cohen <git@omerc.net> Omer Cohen <git@omer.io> Omer Cohen <git@omerc.net>
Eric Yang <windfarer@gmail.com> Eric Yang <Windfarer@users.noreply.github.com> Eric Yang <windfarer@gmail.com> Eric Yang <Windfarer@users.noreply.github.com>
Nikita Tarasov <nikita@mygento.ru> Nikita <luckyraul@users.noreply.github.com> Nikita Tarasov <nikita@mygento.ru> Nikita <luckyraul@users.noreply.github.com>
Misty Stanley-Jones <misty@docker.com> Misty Stanley-Jones <misty@apache.org>
...@@ -197,6 +197,35 @@ func TestCircularRefsExpansion(t *testing.T) { ...@@ -197,6 +197,35 @@ func TestCircularRefsExpansion(t *testing.T) {
}, "Calling expand schema with circular refs, should not panic!") }, "Calling expand schema with circular refs, should not panic!")
} }
func TestContinueOnErrorExpansion(t *testing.T) {
missingRefDoc, err := jsonDoc("fixtures/expansion/missingRef.json")
assert.NoError(t, err)
testCase := struct {
Input *Swagger `json:"input"`
Expected *Swagger `json:"expected"`
}{}
err = json.Unmarshal(missingRefDoc, &testCase)
assert.NoError(t, err)
opts := &ExpandOptions{
ContinueOnError: true,
}
err = ExpandSpec(testCase.Input, opts)
assert.NoError(t, err)
assert.Equal(t, testCase.Input, testCase.Expected, "Should continue expanding spec when a definition can't be found.")
doc, err := jsonDoc("fixtures/expansion/missingItemRef.json")
spec := new(Swagger)
err = json.Unmarshal(doc, spec)
assert.NoError(t, err)
assert.NotPanics(t, func() {
err = ExpandSpec(spec, opts)
assert.NoError(t, err)
}, "Array of missing refs should not cause a panic, and continue to expand spec.")
}
func TestIssue415(t *testing.T) { func TestIssue415(t *testing.T) {
doc, err := jsonDoc("fixtures/expansion/clickmeter.json") doc, err := jsonDoc("fixtures/expansion/clickmeter.json")
assert.NoError(t, err) assert.NoError(t, err)
......
...@@ -120,25 +120,18 @@ func NewRef(refURI string) (Ref, error) { ...@@ -120,25 +120,18 @@ func NewRef(refURI string) (Ref, error) {
return Ref{Ref: ref}, nil return Ref{Ref: ref}, nil
} }
// MustCreateRef creates a ref object but // MustCreateRef creates a ref object but panics when refURI is invalid.
// Use the NewRef method for a version that returns an error.
func MustCreateRef(refURI string) Ref { func MustCreateRef(refURI string) Ref {
return Ref{Ref: jsonreference.MustCreateRef(refURI)} return Ref{Ref: jsonreference.MustCreateRef(refURI)}
} }
// // NewResolvedRef creates a resolved ref
// func NewResolvedRef(refURI string, data interface{}) Ref {
// return Ref{
// Ref: jsonreference.MustCreateRef(refURI),
// Resolved: data,
// }
// }
// MarshalJSON marshals this ref into a JSON object // MarshalJSON marshals this ref into a JSON object
func (r Ref) MarshalJSON() ([]byte, error) { func (r Ref) MarshalJSON() ([]byte, error) {
str := r.String() str := r.String()
if str == "" { if str == "" {
if r.IsRoot() { if r.IsRoot() {
return []byte(`{"$ref":"#"}`), nil return []byte(`{"$ref":""}`), nil
} }
return []byte("{}"), nil return []byte("{}"), nil
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
This diff is collapsed.
This diff is collapsed.
File mode changed from 100755 to 100644
This diff is collapsed.
This diff is collapsed.
File mode changed from 100755 to 100644
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment