vendor: update all dependencies

* Update all dependencies
  * Remove all `[[constraint]]` from Gopkg.toml
  * Add in the minimum number of `[[override]]` to build
  * Remove go get of github.com/inconshreveable/mousetrap as it is vendored
  * Update docs with new policy on constraints
This commit is contained in:
Nick Craig-Wood
2018-05-05 15:52:24 +01:00
parent 21383877df
commit 6427029c4e
4902 changed files with 1443412 additions and 227278 deletions
+43 -12
View File
@@ -1074,12 +1074,12 @@ func doSet(ctx context.Context, args ...string) {
func doSetGCPolicy(ctx context.Context, args ...string) {
if len(args) < 3 {
log.Fatalf("usage: cbt setgcpolicy <table> <family> ( maxage=<d> | maxversions=<n> )")
log.Fatalf("usage: cbt setgcpolicy <table> <family> ( maxage=<d> | maxversions=<n> | maxage=<d> (and|or) maxversions=<n> )")
}
table := args[0]
fam := args[1]
pol, err := parseGCPolicy(args[2])
pol, err := parseGCPolicy(strings.Join(args[2:], " "))
if err != nil {
log.Fatal(err)
}
@@ -1101,24 +1101,55 @@ func doWaitForReplicaiton(ctx context.Context, args ...string) {
}
func parseGCPolicy(policyStr string) (bigtable.GCPolicy, error) {
var pol bigtable.GCPolicy
switch p := policyStr; {
case strings.HasPrefix(p, "maxage="):
d, err := parseDuration(p[7:])
words := strings.Fields(policyStr)
switch len(words) {
case 1:
return parseSinglePolicy(words[0])
case 3:
p1, err := parseSinglePolicy(words[0])
if err != nil {
return nil, err
}
pol = bigtable.MaxAgePolicy(d)
case strings.HasPrefix(p, "maxversions="):
n, err := strconv.ParseUint(p[12:], 10, 16)
p2, err := parseSinglePolicy(words[2])
if err != nil {
return nil, err
}
pol = bigtable.MaxVersionsPolicy(int(n))
switch words[1] {
case "and":
return bigtable.IntersectionPolicy(p1, p2), nil
case "or":
return bigtable.UnionPolicy(p1, p2), nil
default:
return nil, fmt.Errorf("Expected 'and' or 'or', saw %q", words[1])
}
default:
return nil, fmt.Errorf("Bad GC policy %q", p)
return nil, fmt.Errorf("Expected '1' or '3' parameter count, saw %d", len(words))
}
return pol, nil
return nil, nil
}
func parseSinglePolicy(s string) (bigtable.GCPolicy, error) {
words := strings.Split(s, "=")
if len(words) != 2 {
return nil, fmt.Errorf("Expected 'name=value', got %q", words)
}
switch words[0] {
case "maxage":
d, err := parseDuration(words[1])
if err != nil {
return nil, err
}
return bigtable.MaxAgePolicy(d), nil
case "maxversions":
n, err := strconv.ParseUint(words[1], 10, 16)
if err != nil {
return nil, err
}
return bigtable.MaxVersionsPolicy(int(n)), nil
default:
return nil, fmt.Errorf("Expected 'maxage' or 'maxversions', got %q", words[1])
}
return nil, nil
}
func parseStorageType(storageTypeStr string) (bigtable.StorageType, error) {
+54
View File
@@ -17,6 +17,9 @@ package main
import (
"testing"
"time"
"cloud.google.com/go/bigtable"
"github.com/google/go-cmp/cmp"
)
func TestParseDuration(t *testing.T) {
@@ -57,3 +60,54 @@ func TestParseDuration(t *testing.T) {
}
}
}
func TestParseGCPolicy(t *testing.T) {
tests := []struct {
in string
out bigtable.GCPolicy
fail bool
}{
{in: "maxage=1h", out: bigtable.MaxAgePolicy(time.Hour * 1)},
{in: "maxversions=2", out: bigtable.MaxVersionsPolicy(int(2))},
{in: "maxversions=2 and maxage=1h", out: bigtable.IntersectionPolicy([]bigtable.GCPolicy{bigtable.MaxVersionsPolicy(int(2)), bigtable.MaxAgePolicy(time.Hour * 1)}...)},
{in: "maxversions=2 or maxage=1h", out: bigtable.UnionPolicy([]bigtable.GCPolicy{bigtable.MaxVersionsPolicy(int(2)), bigtable.MaxAgePolicy(time.Hour * 1)}...)},
{in: "maxage=1", fail: true},
{in: "maxage = 1h", fail: true},
{in: "maxage =1h", fail: true},
{in: "maxage= 1h", fail: true},
{in: "foomaxage=1h", fail: true},
{in: "maxversions=1h", fail: true},
{in: "maxversions= 1", fail: true},
{in: "maxversions = 1", fail: true},
{in: "maxversions =1", fail: true},
{in: "barmaxversions=1", fail: true},
{in: "maxage = 1h or maxversions=1h", fail: true},
{in: "foomaxversions=2 or maxage=1h", fail: true},
{in: "maxversions=2 or barmaxage=1h", fail: true},
{in: "foomaxversions=2 or barmaxage=1h", fail: true},
{in: "maxage = 1h and maxversions=1h", fail: true},
{in: "foomaxage=1h and maxversions=1", fail: true},
{in: "maxage=1h and barmaxversions=1", fail: true},
{in: "foomaxage=1h and barmaxversions=1", fail: true},
}
for _, tc := range tests {
got, err := parseGCPolicy(tc.in)
if !tc.fail && err != nil {
t.Errorf("parseGCPolicy(%q) unexpectedly failed: %v", tc.in, err)
continue
}
if tc.fail && err == nil {
t.Errorf("parseGCPolicy(%q) did not fail", tc.in)
continue
}
if tc.fail {
continue
}
var cmpOpts cmp.Options
cmpOpts = append(cmpOpts, cmp.AllowUnexported(bigtable.IntersectionPolicy([]bigtable.GCPolicy{}...)), cmp.AllowUnexported(bigtable.UnionPolicy([]bigtable.GCPolicy{}...)))
if !cmp.Equal(got, tc.out, cmpOpts) {
t.Errorf("parseGCPolicy(%q) =%v, want %v", tc.in, got, tc.out)
}
}
}